Provide a banal 'paste' postmessage implementation. (#4189)

Provide a banal 'paste' postmessage implementation.
This commit is contained in:
Tobias Kaminsky 2019-08-20 09:54:40 +02:00 committed by GitHub
commit 5373660f90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,6 +35,7 @@ import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.webkit.JavascriptInterface; import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback; import android.webkit.ValueCallback;
@ -418,6 +419,15 @@ public class RichDocumentsWebView extends ExternalSiteWebView {
Log_OC.e(this, "Failed to parse rename json message: " + e); Log_OC.e(this, "Failed to parse rename json message: " + e);
} }
} }
@JavascriptInterface
public void paste() {
// Javascript cannot do this by itself, so help out.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
webview.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_PASTE));
webview.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_PASTE));
}
}
} }