Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(980)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ActivityContentVideoViewClient.java

Issue 303263004: play fullscreen video in immersive mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moving some logic into setSystemVisibility Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/ActivityContentVideoViewClient.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ActivityContentVideoViewClient.java b/content/public/android/java/src/org/chromium/content/browser/ActivityContentVideoViewClient.java
index 6acf8dca57046e5d142c90f2a54b58125e90d8ab..292993229b8ba8ba9e7b845c667914da770216a5 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ActivityContentVideoViewClient.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ActivityContentVideoViewClient.java
@@ -5,6 +5,7 @@
package org.chromium.content.browser;
import android.app.Activity;
+import android.os.Build;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
@@ -24,24 +25,22 @@ public class ActivityContentVideoViewClient implements ContentVideoViewClient {
@Override
public boolean onShowCustomView(View view) {
- mActivity.getWindow().setFlags(
- WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
-
- mActivity.getWindow().addContentView(view,
- new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT,
- Gravity.CENTER));
+ FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView();
+ decor.addView(view, 0,
+ new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ Gravity.CENTER));
+ setSystemUiVisibility(decor, true);
mView = view;
return true;
}
@Override
public void onDestroyContentVideoView() {
- mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView();
decor.removeView(mView);
+ setSystemUiVisibility(decor, false);
mView = null;
}
@@ -49,4 +48,35 @@ public class ActivityContentVideoViewClient implements ContentVideoViewClient {
public View getVideoLoadingProgressView() {
return null;
}
+
+ /**
+ * Returns the system ui visibility after entering or exiting fullscreen.
+ * @param view The decor view belongs to the activity window
+ * @param enterFullscreen True if video is going fullscreen, or false otherwise.
+ */
+ private void setSystemUiVisibility(View view, boolean enterFullscreen) {
+ if (enterFullscreen) {
+ mActivity.getWindow().setFlags(
+ WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ } else {
+ mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
+ return;
+ }
+
+ int systemUiVisibility = view.getSystemUiVisibility();
+ int flags = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
+ if (enterFullscreen) {
+ systemUiVisibility |= flags;
+ } else {
+ systemUiVisibility &= ~flags;
+ }
+ view.setSystemUiVisibility(systemUiVisibility);
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698