Commit 435c5666 authored by Ignacio Solla's avatar Ignacio Solla
Browse files

[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
parent eb33a44e
......@@ -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();
......
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