Bug 1177611 - Set tabs panel indicator to purple when private. r=mhaigh a=sylvestre
authorMichael Comella <michael.l.comella@gmail.com>
Thu, 06 Aug 2015 15:23:28 -0700
changeset 288845 024d7a27df7ea7de7b5c8c68791c31b56673e29f
parent 288844 15c6bb58116672c2673038c050dcf3413b094148
child 288846 1afdf536cb3bc95152b2e733a1f65beb60ac949a
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhaigh, sylvestre
bugs1177611
milestone42.0a2
Bug 1177611 - Set tabs panel indicator to purple when private. r=mhaigh a=sylvestre
mobile/android/base/resources/drawable/tabs_panel_indicator.xml
mobile/android/base/resources/drawable/tabs_panel_indicator_selected_private.xml
mobile/android/base/resources/layout/tabs_panel_indicator.xml
mobile/android/base/resources/values-large-v11/dimens.xml
mobile/android/base/resources/values/dimens.xml
mobile/android/base/tabs/TabsPanel.java
mobile/android/base/widget/IconTabWidget.java
--- a/mobile/android/base/resources/drawable/tabs_panel_indicator.xml
+++ b/mobile/android/base/resources/drawable/tabs_panel_indicator.xml
@@ -1,20 +1,27 @@
 <?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/. -->
 
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+          xmlns:gecko="http://schemas.android.com/apk/res-auto">
 
     <item android:state_focused="false"
           android:state_selected="false"
           android:state_pressed="false"
           android:drawable="@android:color/transparent"/>
 
+    <item gecko:state_private="true"
+          android:state_focused="false"
+          android:state_selected="true"
+          android:state_pressed="false"
+          android:drawable="@drawable/tabs_panel_indicator_selected_private"/>
+
     <item android:state_focused="false"
           android:state_selected="true"
           android:state_pressed="false"
           android:drawable="@drawable/tab_indicator_selected"/>
 
     <item android:state_focused="true"
           android:state_selected="false"
           android:state_pressed="false"
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/resources/drawable/tabs_panel_indicator_selected_private.xml
@@ -0,0 +1,9 @@
+<?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/. -->
+
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+       android:insetTop="@dimen/tabs_panel_indicator_selected_padding_top"
+       android:drawable="@color/private_browsing_purple"
+       />
--- a/mobile/android/base/resources/layout/tabs_panel_indicator.xml
+++ b/mobile/android/base/resources/layout/tabs_panel_indicator.xml
@@ -1,12 +1,13 @@
 <?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/. -->
 
-<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
-             android:layout_width="@dimen/tabs_panel_indicator_width"
-             android:layout_height="@dimen/browser_toolbar_height"
-             android:minWidth="@dimen/tabs_panel_indicator_width"
-             android:paddingTop="@dimen/browser_toolbar_button_padding"
-             android:paddingBottom="@dimen/browser_toolbar_button_padding"
-             android:background="@drawable/tabs_panel_indicator"/>
+<org.mozilla.gecko.widget.ThemedImageButton
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="@dimen/tabs_panel_indicator_width"
+        android:layout_height="@dimen/browser_toolbar_height"
+        android:minWidth="@dimen/tabs_panel_indicator_width"
+        android:paddingTop="@dimen/browser_toolbar_button_padding"
+        android:paddingBottom="@dimen/browser_toolbar_button_padding"
+        android:background="@drawable/tabs_panel_indicator"/>
--- a/mobile/android/base/resources/values-large-v11/dimens.xml
+++ b/mobile/android/base/resources/values-large-v11/dimens.xml
@@ -3,16 +3,21 @@
    - 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/. -->
 
 <resources>
 
     <dimen name="doorhanger_offsetY">100dp</dimen>
 
     <dimen name="browser_toolbar_height">56dp</dimen>
+    <!-- This value is the height of the Tabs Panel header view
+         (browser_toolbar_height) minus the height of the indicator
+         (6dp). This value should change when the height of the view changes. -->
+    <dimen name="tabs_panel_indicator_selected_padding_top">50dp</dimen>
+
     <dimen name="browser_toolbar_height_flipper">60dp</dimen>
     <dimen name="browser_toolbar_button_padding">16dp</dimen>
     <dimen name="browser_toolbar_favicon_size">16dp</dimen>
 
     <dimen name="browser_toolbar_site_security_height">60dp</dimen>
     <dimen name="browser_toolbar_site_security_width">34dp</dimen>
     <dimen name="browser_toolbar_site_security_margin_right">1dp</dimen>
     <!-- We primarily use padding (instead of margins) to increase the hit area. -->
--- a/mobile/android/base/resources/values/dimens.xml
+++ b/mobile/android/base/resources/values/dimens.xml
@@ -6,16 +6,21 @@
 <resources>
 
     <dimen name="button_corner_radius">3dp</dimen>
 
     <dimen name="autocomplete_min_width">200dp</dimen>
     <dimen name="autocomplete_row_height">32dp</dimen>
 
     <dimen name="browser_toolbar_height">48dp</dimen>
+    <!-- This value is the height of the Tabs Panel header view
+         (browser_toolbar_height) minus the height of the indicator
+         (6dp). This value should change when the height of the view changes. -->
+    <dimen name="tabs_panel_indicator_selected_padding_top">42dp</dimen>
+
     <!-- We use two different values for browser_toolbar_height on tablet
          which is inconsistent. Temporary value until bug 1150730 is fixed. -->
     <dimen name="browser_toolbar_height_flipper">48dp</dimen>
     <dimen name="browser_toolbar_button_padding">12dp</dimen>
     <dimen name="browser_toolbar_icon_width">48dp</dimen>
 
     <!-- favicon_size includes 4dp of right padding. We can't use margin (which would allow us to
          specify the actual size) because that would decrease the size of our hit target. -->
--- a/mobile/android/base/tabs/TabsPanel.java
+++ b/mobile/android/base/tabs/TabsPanel.java
@@ -33,16 +33,17 @@ import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewStub;
 import android.widget.Button;
 import android.widget.FrameLayout;
 import android.widget.ImageButton;
 import android.widget.LinearLayout;
 import android.widget.RelativeLayout;
+import org.mozilla.gecko.widget.ThemedImageButton;
 
 public class TabsPanel extends LinearLayout
                        implements GeckoPopupMenu.OnMenuItemClickListener,
                                   LightweightTheme.OnChangeListener,
                                   IconTabWidget.OnTabChangedListener {
     private static final String LOGTAG = "Gecko" + TabsPanel.class.getSimpleName();
 
     public static enum Panel {
@@ -134,17 +135,19 @@ public class TabsPanel extends LinearLay
             public void onClick(View v) {
                 TabsPanel.this.addTab();
             }
         });
 
         mTabWidget = (IconTabWidget) findViewById(R.id.tab_widget);
 
         mTabWidget.addTab(R.drawable.tabs_normal, R.string.tabs_normal);
-        mTabWidget.addTab(R.drawable.tabs_private, R.string.tabs_private);
+        final ThemedImageButton privateTabsPanel =
+                (ThemedImageButton) mTabWidget.addTab(R.drawable.tabs_private, R.string.tabs_private);
+        privateTabsPanel.setPrivateMode(true);
 
         if (!RestrictedProfiles.isAllowed(mContext, Restriction.DISALLOW_PRIVATE_BROWSING)) {
             mTabWidget.setVisibility(View.GONE);
         }
 
         mTabWidget.setTabSelectionListener(this);
 
         mMenuButton = (ImageButton) findViewById(R.id.menu);
--- a/mobile/android/base/widget/IconTabWidget.java
+++ b/mobile/android/base/widget/IconTabWidget.java
@@ -33,28 +33,29 @@ public class IconTabWidget extends TabWi
         mIsIcon = (a.getInt(R.styleable.IconTabWidget_display, 0x00) == 0x00);
         a.recycle();
 
         if (mButtonLayoutId == 0) {
             throw new RuntimeException("You must supply layout attribute");
         }
     }
 
-    public void addTab(int imageResId, int stringResId) {
+    public View addTab(final int imageResId, final int stringResId) {
         View button = LayoutInflater.from(getContext()).inflate(mButtonLayoutId, this, false);
         if (mIsIcon) {
             ((ImageButton) button).setImageResource(imageResId);
             button.setContentDescription(getContext().getString(stringResId));
         } else {
             ((TextView) button).setText(getContext().getString(stringResId));
         }
 
         addView(button);
         button.setOnClickListener(new TabClickListener(getTabCount() - 1));
         button.setOnFocusChangeListener(this);
+        return button;
     }
 
     public void setTabSelectionListener(OnTabChangedListener listener) {
         mListener = listener;
     }
 
     @Override
     public void onFocusChange(View view, boolean hasFocus) {