Chromium Code Reviews| Index: android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java |
| diff --git a/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java b/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java |
| index 15ed6f7b257544142cb9142f48aa3769454a166a..4fd251cc0b48bd7e2856085e28e5e25c902a13b8 100644 |
| --- a/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java |
| +++ b/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java |
| @@ -38,29 +38,29 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { |
| mContentsClient.onProgressChanged(progress); |
| } |
| - @Override |
| - public void handleKeyboardEvent(KeyEvent event) { |
| + // Converts a KeyEvent into the corresponding View.FOCUS_XXX integer type, iff the key |
| + // event is a key down action, and is a DPAD_XXX key code. |
| + static int getViewDirectionFromKeyEvent(KeyEvent event) { |
|
dmazzoni
2013/10/22 06:47:55
Would it be too verbose to say getViewFocusDirecti
joth
2013/10/22 22:02:41
Good suggestion, however in the end I reverted thi
|
| if (event.getAction() == KeyEvent.ACTION_DOWN) { |
| - int direction; |
| switch (event.getKeyCode()) { |
| case KeyEvent.KEYCODE_DPAD_DOWN: |
| - direction = View.FOCUS_DOWN; |
| - break; |
| + return View.FOCUS_DOWN; |
| case KeyEvent.KEYCODE_DPAD_UP: |
| - direction = View.FOCUS_UP; |
| - break; |
| + return View.FOCUS_UP; |
| case KeyEvent.KEYCODE_DPAD_LEFT: |
| - direction = View.FOCUS_LEFT; |
| - break; |
| + return View.FOCUS_LEFT; |
| case KeyEvent.KEYCODE_DPAD_RIGHT: |
| - direction = View.FOCUS_RIGHT; |
| - break; |
| - default: |
| - direction = 0; |
| - break; |
| + return View.FOCUS_RIGHT; |
| } |
| - if (direction != 0 && tryToMoveFocus(direction)) return; |
| } |
| + return 0; |
|
sgurun-gerrit only
2013/10/22 17:18:00
0 is a special number, i.e. View.FOCUSABLES_ALL, b
joth
2013/10/22 22:02:41
FOCUSABLES_ALL is used with addFocusables(), thes
|
| + } |
| + |
| + @Override |
| + public void handleKeyboardEvent(KeyEvent event) { |
| + int direction = getViewDirectionFromKeyEvent(event); |
| + if (direction != 0 && tryToMoveFocus(direction)) return; |
| + |
| mContentsClient.onUnhandledKeyEvent(event); |
| } |