Commit d8727362 authored by joth@chromium.org's avatar joth@chromium.org

[Android WebView] Enable spatial navigation / DPAD

Turn on the --enable-spatial-navigation flag, and also bubble up
unhandled DPAD events to the neighboring views in the view tree.
Likewise, WebContentsDelegate::TakeFocus() bubble to logical next
or previous neighbor view.

Also disabled the FileSystem API while in the area updating flags.

BUG=286698

Review URL: https://chromiumcodereview.appspot.com/23619024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221946 0039d316-1c4b-4281-b951-d872f2087c98
parent 55488427
...@@ -490,7 +490,7 @@ public class AwContents { ...@@ -490,7 +490,7 @@ public class AwContents {
mLayoutSizer.setDelegate(new AwLayoutSizerDelegate()); mLayoutSizer.setDelegate(new AwLayoutSizerDelegate());
mLayoutSizer.setDIPScale(mDIPScale); mLayoutSizer.setDIPScale(mDIPScale);
mWebContentsDelegate = new AwWebContentsDelegateAdapter(contentsClient, mWebContentsDelegate = new AwWebContentsDelegateAdapter(contentsClient,
mLayoutSizer.getPreferredSizeChangedListener()); mLayoutSizer.getPreferredSizeChangedListener(), mContainerView);
mContentsClientBridge = new AwContentsClientBridge(contentsClient); mContentsClientBridge = new AwContentsClientBridge(contentsClient);
mZoomControls = new AwZoomControls(this); mZoomControls = new AwZoomControls(this);
mIoThreadClient = new IoThreadClientImpl(); mIoThreadClient = new IoThreadClientImpl();
......
...@@ -10,6 +10,7 @@ import android.os.Looper; ...@@ -10,6 +10,7 @@ import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View;
import android.webkit.ConsoleMessage; import android.webkit.ConsoleMessage;
import android.webkit.ValueCallback; import android.webkit.ValueCallback;
...@@ -37,11 +38,14 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { ...@@ -37,11 +38,14 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate {
final AwContentsClient mContentsClient; final AwContentsClient mContentsClient;
final PreferredSizeChangedListener mPreferredSizeChangedListener; final PreferredSizeChangedListener mPreferredSizeChangedListener;
final View mContainerView;
public AwWebContentsDelegateAdapter(AwContentsClient contentsClient, public AwWebContentsDelegateAdapter(AwContentsClient contentsClient,
PreferredSizeChangedListener preferredSizeChangedListener) { PreferredSizeChangedListener preferredSizeChangedListener,
View containerView) {
mContentsClient = contentsClient; mContentsClient = contentsClient;
mPreferredSizeChangedListener = preferredSizeChangedListener; mPreferredSizeChangedListener = preferredSizeChangedListener;
mContainerView = containerView;
} }
@Override @Override
...@@ -51,9 +55,45 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { ...@@ -51,9 +55,45 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate {
@Override @Override
public void handleKeyboardEvent(KeyEvent event) { public void handleKeyboardEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
int direction;
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_DOWN:
direction = View.FOCUS_DOWN;
break;
case KeyEvent.KEYCODE_DPAD_UP:
direction = View.FOCUS_UP;
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
direction = View.FOCUS_LEFT;
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
direction = View.FOCUS_RIGHT;
break;
default:
direction = 0;
break;
}
if (direction != 0 && tryToMoveFocus(direction)) return;
}
mContentsClient.onUnhandledKeyEvent(event); mContentsClient.onUnhandledKeyEvent(event);
} }
@Override
public boolean takeFocus(boolean reverse) {
int direction =
(reverse == (mContainerView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL)) ?
View.FOCUS_RIGHT : View.FOCUS_LEFT;
if (tryToMoveFocus(direction)) return true;
direction = reverse ? View.FOCUS_UP : View.FOCUS_DOWN;
return tryToMoveFocus(direction);
}
private boolean tryToMoveFocus(int direction) {
View focus = mContainerView.focusSearch(direction);
return focus != null && focus != mContainerView && focus.requestFocus();
}
@Override @Override
public boolean addMessageToConsole(int level, String message, int lineNumber, public boolean addMessageToConsole(int level, String message, int lineNumber,
String sourceId) { String sourceId) {
......
...@@ -64,6 +64,14 @@ bool AwMainDelegate::BasicStartupComplete(int* exit_code) { ...@@ -64,6 +64,14 @@ bool AwMainDelegate::BasicStartupComplete(int* exit_code) {
// Ganesh backed 2D-Canvas is not yet working and causes crashes. // Ganesh backed 2D-Canvas is not yet working and causes crashes.
cl->AppendSwitch(switches::kDisableAccelerated2dCanvas); cl->AppendSwitch(switches::kDisableAccelerated2dCanvas);
// File system API not supported (requires some new API; internal bug 6930981)
// TODO(joth): export and use switches::kDisableFileSystem
cl->AppendSwitch("disable-file-system");
// Enable D-PAD navigation for application compatibility.
// TODO(joth): export and use switches::EnableSpatialNavigation.
cl->AppendSwitch("enable-spatial-navigation");
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment