Bug 1197413 - Switch setColorFilter to setPrivateMode in tablet toolbar. r=sebastian
authorMichael Comella <michael.l.comella@gmail.com>
Fri, 21 Aug 2015 17:10:30 -0700
changeset 291723 e1738296ea5fb7109d404b04a57e031bd3b6e23f
parent 291722 86782173d9b84f58982db4f5ccb81290e113caba
child 291724 238b8417cf2a5a8d97db20faaf5df456b14f30be
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1197413
milestone43.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 1197413 - Switch setColorFilter to setPrivateMode in tablet toolbar. r=sebastian This patch has a side effect of changing the color of the forward button as it animates forward and back, but it's minimal enough that I'm okay with it, and it cleans up disabled/private state color management (particularly after the following patch).
mobile/android/base/resources/layout-large-v11/browser_toolbar.xml
mobile/android/base/resources/values-large-v11/styles.xml
mobile/android/base/toolbar/BrowserToolbarTabletBase.java
--- a/mobile/android/base/resources/layout-large-v11/browser_toolbar.xml
+++ b/mobile/android/base/resources/layout-large-v11/browser_toolbar.xml
@@ -32,17 +32,17 @@
 	     to the right of the back button.
 
          (for layout_marginLeft) We left align with back,
          but only need to hide halfway underneath.
 
          (for paddingLeft) We use left padding to center the
          arrow in the visible area as opposed to the true width. -->
     <org.mozilla.gecko.toolbar.ForwardButton
-            style="@style/UrlBar.ImageButton"
+            style="@style/UrlBar.ImageButton.BrowserToolbarColors"
             android:id="@+id/forward"
             android:layout_alignLeft="@id/back"
             android:contentDescription="@string/forward"
             android:layout_height="match_parent"
             android:paddingTop="0dp"
             android:paddingBottom="0dp"
             android:layout_marginTop="11.5dp"
             android:layout_marginBottom="11.5dp"
@@ -51,17 +51,17 @@
             android:src="@drawable/ic_menu_forward"
             android:background="@drawable/url_bar_nav_button"
             android:alpha="0"
             android:layout_width="@dimen/tablet_nav_button_width_plus_half"
             android:layout_marginLeft="@dimen/tablet_nav_button_width_half"
             android:paddingLeft="18dp"/>
 
     <org.mozilla.gecko.toolbar.BackButton android:id="@id/back"
-                                          style="@style/UrlBar.ImageButton"
+                                          style="@style/UrlBar.ImageButton.BrowserToolbarColors"
                                           android:layout_width="@dimen/tablet_nav_button_width"
                                           android:layout_height="@dimen/tablet_nav_button_width"
                                           android:layout_centerVertical="true"
                                           android:layout_marginLeft="12dp"
                                           android:layout_alignParentLeft="true"
                                           android:src="@drawable/ic_menu_back"
                                           android:contentDescription="@string/back"
                                           android:background="@drawable/url_bar_nav_button"/>
@@ -115,17 +115,17 @@
             android:layout_alignParentRight="true"
             android:layout_marginRight="6dp"
             android:contentDescription="@string/menu"
             android:background="@drawable/browser_toolbar_action_bar_button"
             android:visibility="gone"/>
 
     <org.mozilla.gecko.widget.ThemedImageView
             android:id="@+id/menu_icon"
-            style="@style/UrlBar.ImageButton"
+            style="@style/UrlBar.ImageButton.BrowserToolbarColors"
             android:layout_alignLeft="@id/menu"
             android:layout_alignRight="@id/menu"
             android:src="@drawable/tablet_menu"
             android:visibility="gone"/>
 
     <!-- We draw after the menu items so when they are hidden, the cancel button,
          which is thus drawn on top, may be pressed. -->
     <org.mozilla.gecko.widget.ThemedImageView
--- a/mobile/android/base/resources/values-large-v11/styles.xml
+++ b/mobile/android/base/resources/values-large-v11/styles.xml
@@ -4,16 +4,22 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <resources>
 
     <style name="UrlBar.ImageButton" parent="UrlBar.ImageButtonBase">
         <item name="android:layout_width">@dimen/tablet_browser_toolbar_menu_item_width</item>
     </style>
 
+    <!-- If this style wasn't actually shared outside the
+         url bar, this name could be improved (bug 1197424). -->
+    <style name="UrlBar.ImageButton.BrowserToolbarColors">
+        <item name="drawableTintList">@color/action_bar_menu_item_colors</item>
+    </style>
+
     <style name="UrlBar.ImageButton.TabCount">
         <item name="android:background">@drawable/tabs_count</item>
     </style>
 
     <style name="UrlBar.Button.Container">
         <item name="android:layout_marginTop">6dp</item>
         <item name="android:layout_marginBottom">6dp</item>
         <!-- Start with forward hidden -->
--- a/mobile/android/base/toolbar/BrowserToolbarTabletBase.java
+++ b/mobile/android/base/toolbar/BrowserToolbarTabletBase.java
@@ -125,29 +125,25 @@ abstract class BrowserToolbarTabletBase 
         backButton.setNextFocusDownId(nextId);
         forwardButton.setNextFocusDownId(nextId);
     }
 
     @Override
     public void setPrivateMode(final boolean isPrivate) {
         super.setPrivateMode(isPrivate);
 
-        // Better done with android:tint but it doesn't take a ColorStateList:
-        //   https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=18220
-        // Nor can we use DrawableCompat because the drawables (as opposed
-        // to the Views) don't receive gecko:state_private.
+        // If we had backgroundTintList, we could remove the colorFilter
+        // code in favor of setPrivateMode (bug 1197432).
         final PorterDuffColorFilter colorFilter =
                 isPrivate ? privateBrowsingTabletMenuItemColorFilter : null;
-        backButton.setColorFilter(colorFilter);
-        forwardButton.setColorFilter(colorFilter);
         setTabsCounterPrivateMode(isPrivate, colorFilter);
-        menuIcon.setColorFilter(colorFilter);
 
         backButton.setPrivateMode(isPrivate);
         forwardButton.setPrivateMode(isPrivate);
+        menuIcon.setPrivateMode(isPrivate);
         for (int i = 0; i < actionItemBar.getChildCount(); ++i) {
             final MenuItemActionBar child = (MenuItemActionBar) actionItemBar.getChildAt(i);
             child.setPrivateMode(isPrivate);
         }
     }
 
     private void setTabsCounterPrivateMode(final boolean isPrivate, final PorterDuffColorFilter colorFilter) {
         // The TabsCounter is a TextSwitcher which cycles two views