Bug 1366661 - Cover a mask on toolbar when light weight theme is applied. r?walkingice draft
authorJing-wei Wu <topwu.tw@gmail.com>
Mon, 07 Aug 2017 16:13:07 +0800
changeset 641538 8b6c4fc35636168159e7852118592bfac02a0319
parent 641534 4fda1ff36219d7c9465736089b26e29b295c9826
child 724829 85100b02beeaa9b7564ed3a27922cd7635fae2b8
push id72568
push userbmo:topwu.tw@gmail.com
push dateMon, 07 Aug 2017 08:14:11 +0000
reviewerswalkingice
bugs1366661
milestone57.0a1
Bug 1366661 - Cover a mask on toolbar when light weight theme is applied. r?walkingice MozReview-Commit-ID: HhZIjhgnxql
mobile/android/app/src/australis/res/values/colors.xml
mobile/android/app/src/photon/java/org/mozilla/gecko/toolbar/ForwardButton.java
mobile/android/app/src/photon/res/drawable/tab_strip_item_bg.xml
mobile/android/app/src/photon/res/values/colors.xml
mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbar.java
mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbarPhone.java
mobile/android/base/java/org/mozilla/gecko/toolbar/NavButton.java
--- a/mobile/android/app/src/australis/res/values/colors.xml
+++ b/mobile/android/app/src/australis/res/values/colors.xml
@@ -39,16 +39,24 @@
   <color name="status_bar_bg_color">@android:color/transparent</color>
   <color name="status_bar_bg_color_private">@android:color/transparent</color>
   <color name="status_bar_bg_color_tablet">@android:color/transparent</color>
 
   <!-- Toolbar menu item tint color -->
   <color name="menu_item_tint">@color/toolbar_icon_grey</color>
   <color name="menu_item_tint_private">@color/toolbar_icon_grey</color>
 
+  <!-- Navigation button background color -->
+  <color name="nav_button_bg_color_disabled">#0D272727</color>
+  <color name="nav_button_bg_color_focused">@color/tablet_highlight_focused</color>
+  <color name="nav_button_bg_color_pressed">@color/toolbar_grey_pressed</color>
+  <color name="nav_button_bg_color_private">@color/tabs_tray_grey_pressed</color>
+  <color name="nav_button_bg_color_private_focused">@color/text_and_tabs_tray_grey</color>
+  <color name="nav_button_bg_color_private_pressed">@color/placeholder_active_grey</color>
+
   <!-- Non-palette colors -->
 
   <!-- Synced w/ toolbar_grey -->
   <color name="background_normal_lwt">#DDEBEBF0</color>
 
   <color name="highlight">#33000000</color>
   <color name="highlight_focused">#1A000000</color>
   <color name="highlight_dark">#33FFFFFF</color>
--- a/mobile/android/app/src/photon/java/org/mozilla/gecko/toolbar/ForwardButton.java
+++ b/mobile/android/app/src/photon/java/org/mozilla/gecko/toolbar/ForwardButton.java
@@ -2,16 +2,18 @@
  * 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/. */
 
 package org.mozilla.gecko.toolbar;
 
 import android.content.Context;
 import android.graphics.Path;
 import android.graphics.RectF;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.StateListDrawable;
 import android.util.AttributeSet;
 
 import org.mozilla.gecko.R;
 
 public class ForwardButton extends NavButton {
     public ForwardButton(Context context, AttributeSet attrs) {
         super(context, attrs);
     }
@@ -21,11 +23,32 @@ public class ForwardButton extends NavBu
         super.onSizeChanged(width, height, oldWidth, oldHeight);
 
         mPath.reset();
         mPath.setFillType(Path.FillType.INVERSE_EVEN_ODD);
 
         final RectF rect = new RectF(0, 0, width, height);
         final int radius = getResources().getDimensionPixelSize(R.dimen.browser_toolbar_menu_radius);
         mPath.addRoundRect(rect, radius, radius, Path.Direction.CW);
+    }
 
+    @Override
+    public void onLightweightThemeChanged() {
+        final Drawable drawable = BrowserToolbar.getLightweightThemeDrawable(this, getTheme(), R.color.toolbar_grey);
+
+        if (drawable == null) {
+            return;
+        }
+
+        final StateListDrawable stateList = new StateListDrawable();
+        stateList.addState(PRIVATE_PRESSED_STATE_SET, getColorDrawable(R.color.action_bar_item_bg_color_private_pressed));
+        stateList.addState(PRESSED_ENABLED_STATE_SET, getColorDrawable(R.color.action_bar_item_bg_color_pressed));
+        stateList.addState(PRIVATE_STATE_SET, getColorDrawable(android.R.color.transparent));
+        stateList.addState(EMPTY_STATE_SET, drawable);
+
+        setBackgroundDrawable(stateList);
+    }
+
+    @Override
+    public void onLightweightThemeReset() {
+        setBackgroundResource(R.drawable.url_bar_forward_button);
     }
 }
--- a/mobile/android/app/src/photon/res/drawable/tab_strip_item_bg.xml
+++ b/mobile/android/app/src/photon/res/drawable/tab_strip_item_bg.xml
@@ -14,21 +14,49 @@
     <item android:drawable="@color/photon_tab_strip_item_private_checked"
           android:state_checked="true"
           gecko:state_private="true"/>
 
     <item android:drawable="@color/photon_tab_strip_item_private_pressed"
           android:state_pressed="true"
           gecko:state_private="true"/>
 
+    <!-- dark theme -->
+    <item android:drawable="@color/photon_tab_strip_item_lwt_dark_checked_pressed"
+          android:state_checked="true"
+          android:state_pressed="true"
+          gecko:state_dark="true"/>
+
+    <item android:drawable="@color/photon_tab_strip_item_lwt_dark_checked"
+          android:state_checked="true"
+          gecko:state_dark="true"/>
+
+    <item android:drawable="@color/photon_tab_strip_item_lwt_dark_pressed"
+          android:state_pressed="true"
+          gecko:state_dark="true"/>
+
+    <!-- light theme -->
+    <item android:drawable="@color/photon_tab_strip_item_lwt_checked_pressed"
+          android:state_checked="true"
+          android:state_pressed="true"
+          gecko:state_light="true"/>
+
+    <item android:drawable="@color/photon_tab_strip_item_lwt_checked"
+          android:state_checked="true"
+          gecko:state_light="true"/>
+
+    <item android:drawable="@color/photon_tab_strip_item_lwt_dark_pressed"
+          android:state_pressed="true"
+          gecko:state_light="true"/>
+
     <item android:drawable="@color/photon_tab_strip_item_checked_pressed"
           android:state_checked="true"
           android:state_pressed="true"/>
 
     <item android:drawable="@color/photon_tab_strip_item_checked"
           android:state_checked="true"/>
 
     <item android:drawable="@color/photon_tab_strip_item_pressed"
           android:state_pressed="true"/>
 
-    <item android:drawable="@color/photon_tab_strip_item"/>
+    <item android:drawable="@android:color/transparent"/>
 
 </selector>
--- a/mobile/android/app/src/photon/res/values/colors.xml
+++ b/mobile/android/app/src/photon/res/values/colors.xml
@@ -96,16 +96,23 @@
     <color name="photon_tab_strip_item">#272727</color>
     <color name="photon_tab_strip_item_checked">#F9F9FA</color>
     <color name="photon_tab_strip_item_checked_pressed">#E4E4E5</color> <!-- #F9F9FA + #272727@10% Alpha -->
     <color name="photon_tab_strip_item_pressed">#3D3C3D</color> <!-- #272727 + #FFFFFF@10% Alpha -->
     <color name="photon_tab_strip_item_private_checked">#38383D</color>
     <color name="photon_tab_strip_item_private_checked_pressed">#4C4B51</color> <!-- #38383D + #FFFFFF@10% Alpha -->
     <color name="photon_tab_strip_item_private_pressed">#3D3C3D</color> <!-- #272727 + #FFFFFF@10% Alpha -->
 
+    <color name="photon_tab_strip_item_lwt_dark_checked">#1A38383D</color>
+    <color name="photon_tab_strip_item_lwt_dark_checked_pressed">#1AFFFFFF</color>
+    <color name="photon_tab_strip_item_lwt_dark_pressed">#1AFFFFFF</color>
+    <color name="photon_tab_strip_item_lwt_checked">#1AF9F9FA</color>
+    <color name="photon_tab_strip_item_lwt_checked_pressed">#1A272727</color>
+    <color name="photon_tab_strip_item_lwt_pressed">#1A272727</color>
+
     <!-- Status bar background color -->
     <color name="status_bar_bg_color">@color/photon_toolbar_bg</color>
     <color name="status_bar_bg_color_private">@color/photon_toolbar_bg_private</color>
     <color name="status_bar_bg_color_tablet">@color/photon_tabs_tray_bg</color>
 
     <!-- Toolbar menu item tint color -->
     <color name="menu_item_tint">@color/photon_icon</color>
     <color name="menu_item_tint_private">@color/photon_icon_private</color>
@@ -133,25 +140,25 @@
     <color name="action_orange_pressed">#DC5600</color>
     <color name="link_blue">#0096DD</color>
     <color name="link_blue_pressed">#0082C6</color>
     <color name="private_browsing_purple">#CF68FF</color>
 
     <color name="placeholder_active_grey">#222222</color>
     <color name="placeholder_grey">#777777</color>
     <color name="private_toolbar_grey">#292C29</color>
-    <color name="text_and_tabs_tray_grey">#363B40</color>
+    <color name="text_and_tabs_tray_grey">@color/photon_text_main</color>
     <color name="tabs_tray_grey_pressed">#45494E</color>
     <color name="toolbar_icon_grey">#5F6368</color>
 
     <color name="tabs_tray_icon_grey">#AFB1B3</color>
     <color name="disabled_grey">#BFBFBF</color>
     <color name="toolbar_grey_pressed">#D7D7DC</color>
     <color name="toolbar_menu_dark_grey">#E1E1E6</color>
-    <color name="toolbar_grey">#EBEBF0</color>
+    <color name="toolbar_grey">@color/photon_browser_toolbar_bg</color>
     <color name="about_page_header_grey">#F5F5F5</color>
 
     <color name="url_bar_shadow_private">#272727</color>
 
     <!-- Restricted profiles palette -->
 
     <color name="restricted_profile_background_gold">#ffffcb51</color>
     <color name="restricted_profile_background_green">#1aaa86</color>
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbar.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbar.java
@@ -79,16 +79,17 @@ import android.support.annotation.NonNul
 * to state changes accordingly.
 */
 public abstract class BrowserToolbar extends ThemedRelativeLayout
                                      implements Tabs.OnTabsChangedListener,
                                                 GeckoMenu.ActionItemBarPresenter {
     private static final String LOGTAG = "GeckoToolbar";
 
     private static final int LIGHTWEIGHT_THEME_INVERT_ALPHA = 34; // 255 - alpha = invert_alpha
+    private static final int LIGHTWEIGHT_THEME_ALPHA = 77;
 
     public interface OnActivateListener {
         public void onActivate();
     }
 
     public interface OnCommitListener {
         public void onCommit();
     }
@@ -942,17 +943,21 @@ public abstract class BrowserToolbar ext
     }
 
     public static LightweightThemeDrawable getLightweightThemeDrawable(final View view,
             final LightweightTheme theme, final int colorResID) {
         final int color = ContextCompat.getColor(view.getContext(), colorResID);
 
         final LightweightThemeDrawable drawable = theme.getColorDrawable(view, color);
         if (drawable != null) {
-            drawable.setAlpha(LIGHTWEIGHT_THEME_INVERT_ALPHA, LIGHTWEIGHT_THEME_INVERT_ALPHA);
+            if (SkinConfig.isAustralis()) {
+                drawable.setAlpha(LIGHTWEIGHT_THEME_INVERT_ALPHA, LIGHTWEIGHT_THEME_INVERT_ALPHA);
+            } else {
+                drawable.setAlpha(LIGHTWEIGHT_THEME_ALPHA, LIGHTWEIGHT_THEME_ALPHA);
+            }
         }
 
         return drawable;
     }
 
     public static class TabEditingState {
         // The edited text from the most recent time this tab was unselected.
         protected String lastEditingText;
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbarPhone.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/BrowserToolbarPhone.java
@@ -1,22 +1,23 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * 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/. */
 
 package org.mozilla.gecko.toolbar;
 
+import org.mozilla.gecko.R;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.animation.PropertyAnimator;
 import org.mozilla.gecko.animation.PropertyAnimator.PropertyAnimationListener;
 import org.mozilla.gecko.skin.SkinConfig;
-import org.mozilla.gecko.util.HardwareUtils;
 
 import android.content.Context;
+import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 import android.view.View;
 
 /**
  * A toolbar implementation for phones.
  */
 class BrowserToolbarPhone extends BrowserToolbarPhoneBase {
 
@@ -125,9 +126,18 @@ class BrowserToolbarPhone extends Browse
 
         // bug 1375351: menuIcon only exists in Australis flavor
         if (SkinConfig.isAustralis()) {
             animator.attach(menuIcon,
                     PropertyAnimator.Property.TRANSLATION_X,
                     curveTranslation);
         }
     }
+
+    @Override
+    protected Drawable getLWTDefaultStateSetDrawable() {
+        if (SkinConfig.isAustralis()) {
+            return getTheme().getDrawable(this);
+        } else {
+            return BrowserToolbar.getLightweightThemeDrawable(this, getTheme(), R.color.toolbar_grey);
+        }
+    }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/NavButton.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/NavButton.java
@@ -73,21 +73,21 @@ abstract class NavButton extends ShapedB
     public void onLightweightThemeChanged() {
         final Drawable drawable = BrowserToolbar.getLightweightThemeDrawable(this, getTheme(), R.color.toolbar_grey);
 
         if (drawable == null) {
             return;
         }
 
         final StateListDrawable stateList = new StateListDrawable();
-        stateList.addState(PRIVATE_PRESSED_STATE_SET, getColorDrawable(R.color.placeholder_active_grey));
-        stateList.addState(PRESSED_ENABLED_STATE_SET, getColorDrawable(R.color.toolbar_grey_pressed));
-        stateList.addState(PRIVATE_FOCUSED_STATE_SET, getColorDrawable(R.color.text_and_tabs_tray_grey));
-        stateList.addState(FOCUSED_STATE_SET, getColorDrawable(R.color.tablet_highlight_focused));
-        stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.tabs_tray_grey_pressed));
+        stateList.addState(PRIVATE_PRESSED_STATE_SET, getColorDrawable(R.color.nav_button_bg_color_private_pressed));
+        stateList.addState(PRESSED_ENABLED_STATE_SET, getColorDrawable(R.color.nav_button_bg_color_pressed));
+        stateList.addState(PRIVATE_FOCUSED_STATE_SET, getColorDrawable(R.color.nav_button_bg_color_private_focused));
+        stateList.addState(FOCUSED_STATE_SET, getColorDrawable(R.color.nav_button_bg_color_focused));
+        stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.nav_button_bg_color_private));
         stateList.addState(EMPTY_STATE_SET, drawable);
 
         setBackgroundDrawable(stateList);
     }
 
     @Override
     public void onLightweightThemeReset() {
         setBackgroundResource(R.drawable.url_bar_nav_button);