summaryrefslogtreecommitdiffstats
path: root/core/java/android/webkit/WebViewClient.java
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2014-04-23 17:23:39 -0700
committerMichael Wright <michaelwr@google.com>2014-04-29 15:02:34 -0700
commit899d70568b565280dd33fa8892e25c5511f95769 (patch)
treed58ebe0d363aa6dadf972aa7a78c3e217e424519 /core/java/android/webkit/WebViewClient.java
parent3da2834f0ee77268e0076ad1e24f319635c38b89 (diff)
downloadframeworks_base-899d70568b565280dd33fa8892e25c5511f95769.zip
frameworks_base-899d70568b565280dd33fa8892e25c5511f95769.tar.gz
frameworks_base-899d70568b565280dd33fa8892e25c5511f95769.tar.bz2
Add unhandledInputEvent API to ViewRoot
Update WebViewClient to use it instead, and add a new public API, onUnhandledInputEvent. Note that WebViewClients won't receive this call back until WebView is updated to use it. Bug: 14279909 Change-Id: Ied49791b469849f5c4cf4471f2b26c56b03f4961
Diffstat (limited to 'core/java/android/webkit/WebViewClient.java')
-rw-r--r--core/java/android/webkit/WebViewClient.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/core/java/android/webkit/WebViewClient.java b/core/java/android/webkit/WebViewClient.java
index e8974c6..829b766 100644
--- a/core/java/android/webkit/WebViewClient.java
+++ b/core/java/android/webkit/WebViewClient.java
@@ -19,6 +19,7 @@ package android.webkit;
import android.graphics.Bitmap;
import android.net.http.SslError;
import android.os.Message;
+import android.view.InputEvent;
import android.view.KeyEvent;
import android.view.ViewRootImpl;
@@ -246,11 +247,42 @@ public class WebViewClient {
*
* @param view The WebView that is initiating the callback.
* @param event The key event.
+ * @deprecated This method is subsumed by the more generic onUnhandledInputEvent.
*/
+ @Deprecated
public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
+ onUnhandledInputEventInternal(view, event);
+ }
+
+ /**
+ * Notify the host application that a input event was not handled by the WebView.
+ * Except system keys, WebView always consumes input events in the normal flow
+ * or if shouldOverrideKeyEvent returns true. This is called asynchronously
+ * from where the event is dispatched. It gives the host application a chance
+ * to handle the unhandled input events.
+ *
+ * Note that if the event is a {@link MotionEvent}, then it's lifetime is only that of the
+ * function call. If the WebViewClient wishes to use the event beyond that, then it <i>must</i>
+ * create a copy of the event.
+ *
+ * It is the responsibility of overriders of this method to call {@link onUnhandledKeyEvent}
+ * when appropriate if they wish to continue receiving events through it.
+ *
+ * @param view The WebView that is initiating the callback.
+ * @param event The input event.
+ */
+ public void onUnhandledInputEvent(WebView view, InputEvent event) {
+ if (event instanceof KeyEvent) {
+ onUnhandledKeyEvent(view, (KeyEvent) event);
+ return;
+ }
+ onUnhandledInputEventInternal(view, event);
+ }
+
+ private void onUnhandledInputEventInternal(WebView view, InputEvent event) {
ViewRootImpl root = view.getViewRootImpl();
if (root != null) {
- root.dispatchUnhandledKey(event);
+ root.dispatchUnhandledInputEvent(event);
}
}