summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgnacio Solla <igsolla@google.com>2014-11-17 22:01:57 +0000
committerIgnacio Solla <igsolla@google.com>2014-11-21 20:32:32 +0000
commit435c5666f334eef2a59b6cc28532ca4af0c62b74 (patch)
treea3e9f625d9b0b028629300444741cdf04c97a3f9
parenteb33a44eef586f62300547e65a8f666276540b64 (diff)
downloadchromium_org-435c5666f334eef2a59b6cc28532ca4af0c62b74.tar.gz
[WebView] Set back button to exit fullscreen.
This patch fixes a regression from K to L. Tapping the back button while in fullscreen should exit fullscreen instead of the current activity. BUG:17985005 Change-Id: I7a5eb4edebb54ce1e7d6a2b578a87dd7e7de9dbf
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
index a091d775ff..cdccba91bf 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
@@ -38,6 +38,21 @@ public class AwContentViewClient extends ContentViewClient {
}
View fullscreenView = mAwContents.enterFullScreen();
if (fullscreenView != null) {
+ fullscreenView.setOnKeyListener(new View.OnKeyListener() {
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ if (event.getKeyCode() == KeyEvent.KEYCODE_BACK
+ && event.getAction() == KeyEvent.ACTION_UP
+ && mAwContents.isFullScreen()) {
+ exitFullscreen();
+ return true;
+ }
+ return false;
+ }
+ });
+ fullscreenView.setFocusable(true);
+ fullscreenView.setFocusableInTouchMode(true);
+ fullscreenView.requestFocus();
viewGroup.addView(fullscreenView);
}
}
@@ -45,15 +60,19 @@ public class AwContentViewClient extends ContentViewClient {
WebChromeClient.CustomViewCallback cb = new WebChromeClient.CustomViewCallback() {
@Override
public void onCustomViewHidden() {
- ContentVideoView contentVideoView = ContentVideoView.getContentVideoView();
- if (contentVideoView != null)
- contentVideoView.exitFullscreen(false);
+ exitFullscreen();
}
};
mAwContentsClient.onShowCustomView(viewGroup, cb);
return true;
}
+ private void exitFullscreen() {
+ ContentVideoView contentVideoView = ContentVideoView.getContentVideoView();
+ if (contentVideoView != null)
+ contentVideoView.exitFullscreen(false);
+ }
+
@Override
public void onDestroyContentVideoView() {
mAwContents.exitFullScreen();