Skip to content

Commit 5373660

Browse files
Provide a banal 'paste' postmessage implementation. (#4189)
Provide a banal 'paste' postmessage implementation.
2 parents f26095f + c0588a0 commit 5373660

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main/java/com/owncloud/android/ui/activity/RichDocumentsWebView.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import android.os.Build;
3636
import android.os.Bundle;
3737
import android.text.TextUtils;
38+
import android.view.KeyEvent;
3839
import android.view.View;
3940
import android.webkit.JavascriptInterface;
4041
import android.webkit.ValueCallback;
@@ -418,6 +419,15 @@ public void fileRename(String renameString) {
418419
Log_OC.e(this, "Failed to parse rename json message: " + e);
419420
}
420421
}
422+
423+
@JavascriptInterface
424+
public void paste() {
425+
// Javascript cannot do this by itself, so help out.
426+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
427+
webview.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_PASTE));
428+
webview.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_PASTE));
429+
}
430+
}
421431
}
422432

423433

0 commit comments

Comments
 (0)