Bug 1074536 - Hide statubar tint whenever statusbar is hidden (r=mfinkle)
authorLucas Rocha <lucasr@lucasr.org>
Fri, 10 Oct 2014 16:09:06 +0100
changeset 233004 433cb9e553e117c9d3c46c43774a2b819866788a
parent 233003 320dd3495026132dda46ca14cae852070787209e
child 233005 03fd3fb2d48c9b5bde4a141f054e8c109ad6c823
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs1074536
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1074536 - Hide statubar tint whenever statusbar is hidden (r=mfinkle)
mobile/android/base/BaseGeckoInterface.java
mobile/android/base/BrowserApp.java
mobile/android/base/GeckoApp.java
mobile/android/base/resources/layout/gecko_app.xml
--- a/mobile/android/base/BaseGeckoInterface.java
+++ b/mobile/android/base/BaseGeckoInterface.java
@@ -70,22 +70,31 @@ public class BaseGeckoInterface implemen
     public void doRestart() {}
 
     public void setFullScreen(final boolean fullscreen) {
         ThreadUtils.postToUiThread(new Runnable() {
             @Override
             public void run() {
                 // Hide/show the system notification bar
                 Window window = getActivity().getWindow();
-                window.setFlags(fullscreen ?
-                                WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
-                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
 
                 if (Versions.feature11Plus) {
-                    window.getDecorView().setSystemUiVisibility(fullscreen ? 1 : 0);
+                    final int newVis;
+                    if (fullscreen) {
+                        newVis = View.SYSTEM_UI_FLAG_FULLSCREEN |
+                                 View.SYSTEM_UI_FLAG_LOW_PROFILE;
+                    } else {
+                        newVis = View.SYSTEM_UI_FLAG_VISIBLE;
+                    }
+
+                    window.getDecorView().setSystemUiVisibility(newVis);
+                } else {
+                    window.setFlags(fullscreen ?
+                                    WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
+                                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
                 }
             }
         });
     }
 
     // Bug 908779: Implement this
     public void addPluginView(final View view, final RectF rect, final boolean isFullScreen) {}
 
--- a/mobile/android/base/BrowserApp.java
+++ b/mobile/android/base/BrowserApp.java
@@ -680,17 +680,30 @@ public class BrowserApp extends GeckoApp
         if (!Versions.feature19Plus) {
             return;
         }
 
         getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
 
         mTintManager = new SystemBarTintManager(this);
         mTintManager.setTintColor(getResources().getColor(R.color.background_tabs));
-        mTintManager.setStatusBarTintEnabled(true);
+        updateSystemUITinting(mRootLayout.getSystemUiVisibility());
+
+        mRootLayout.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
+            @Override
+            public void onSystemUiVisibilityChange(int visibility) {
+                updateSystemUITinting(visibility);
+            }
+        });
+    }
+
+    private void updateSystemUITinting(int visibility) {
+        final boolean shouldTint = (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0 &&
+                                   (visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0;
+        mTintManager.setStatusBarTintEnabled(shouldTint);
     }
 
     /**
      * Check and show Onboarding start pane if Firefox has never been launched and
      * is not opening an external link from another application.
      *
      * @param context Context of application; used to show Start Pane if appropriate
      * @param intentAction Intent that launched this activity
@@ -2651,20 +2664,16 @@ public class BrowserApp extends GeckoApp
                     }
                 } else {
                     mBrowserChrome.setVisibility(View.VISIBLE);
                     if (mDynamicToolbar.isEnabled()) {
                         mDynamicToolbar.setVisible(true, VisibilityTransition.IMMEDIATE);
                         mLayerView.getLayerMarginsAnimator().setMaxMargins(0, mToolbarHeight, 0, 0);
                     }
                 }
-
-                if (mTintManager != null) {
-                    mTintManager.setStatusBarTintEnabled(!fullscreen);
-                }
             }
         });
     }
 
     @Override
     public boolean onPrepareOptionsMenu(Menu aMenu) {
         if (aMenu == null)
             return false;
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -153,16 +153,17 @@ public abstract class GeckoApp
 
     public static final String SAVED_STATE_IN_BACKGROUND   = "inBackground";
     public static final String SAVED_STATE_PRIVATE_SESSION = "privateSession";
 
     // Delay before running one-time "cleanup" tasks that may be needed
     // after a version upgrade.
     private static final int CLEANUP_DEFERRAL_SECONDS = 15;
 
+    protected RelativeLayout mRootLayout;
     protected RelativeLayout mMainLayout;
     protected RelativeLayout mGeckoLayout;
     private View mCameraView;
     private OrientationEventListener mCameraOrientationEventListener;
     public List<GeckoAppShell.AppStateListener> mAppStateListeners = new LinkedList<GeckoAppShell.AppStateListener>();
     protected MenuPanel mMenuPanel;
     protected Menu mMenu;
     protected GeckoProfile mProfile;
@@ -1071,22 +1072,31 @@ public abstract class GeckoApp
     }
 
     public void setFullScreen(final boolean fullscreen) {
         ThreadUtils.postToUiThread(new Runnable() {
             @Override
             public void run() {
                 // Hide/show the system notification bar
                 Window window = getWindow();
-                window.setFlags(fullscreen ?
-                                WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
-                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
 
                 if (Versions.feature11Plus) {
-                    window.getDecorView().setSystemUiVisibility(fullscreen ? 1 : 0);
+                    final int newVis;
+                    if (fullscreen) {
+                        newVis = View.SYSTEM_UI_FLAG_FULLSCREEN |
+                                 View.SYSTEM_UI_FLAG_LOW_PROFILE;
+                    } else {
+                        newVis = View.SYSTEM_UI_FLAG_VISIBLE;
+                    }
+
+                    window.getDecorView().setSystemUiVisibility(newVis);
+                } else {
+                    window.setFlags(fullscreen ?
+                                    WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
+                                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
                 }
             }
         });
     }
 
     /**
      * Check and start the Java profiler if MOZ_PROFILER_STARTUP env var is specified.
      **/
@@ -1257,16 +1267,17 @@ public abstract class GeckoApp
 
         super.onCreate(savedInstanceState);
 
         GeckoScreenOrientation.getInstance().update(getResources().getConfiguration().orientation);
 
         setContentView(getLayout());
 
         // Set up Gecko layout.
+        mRootLayout = (RelativeLayout) findViewById(R.id.root_layout);
         mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
         mMainLayout = (RelativeLayout) findViewById(R.id.main_layout);
 
         // Determine whether we should restore tabs.
         mShouldRestore = getSessionRestoreState(savedInstanceState);
         if (mShouldRestore && savedInstanceState != null) {
             boolean wasInBackground =
                 savedInstanceState.getBoolean(SAVED_STATE_IN_BACKGROUND, false);
--- a/mobile/android/base/resources/layout/gecko_app.xml
+++ b/mobile/android/base/resources/layout/gecko_app.xml
@@ -1,15 +1,16 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 xmlns:gecko="http://schemas.android.com/apk/res-auto"
+                android:id="@+id/root_layout"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:fitsSystemWindows="true">
 
     <ViewStub android:id="@+id/tabs_panel"
               android:layout="@layout/tabs_panel_view"
               android:layout_width="match_parent"
               android:layout_height="match_parent"/>