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).
This commit is contained in:
Michael Comella 2015-08-21 17:10:30 -07:00
parent b6b331b6fb
commit 829ec864c8
3 changed files with 12 additions and 10 deletions

View File

@ -37,7 +37,7 @@
(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"
@ -56,7 +56,7 @@
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"
@ -120,7 +120,7 @@
<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"

View File

@ -9,6 +9,12 @@
<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>

View File

@ -130,19 +130,15 @@ abstract class BrowserToolbarTabletBase extends BrowserToolbar {
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);