Bug 1110149 - [Tablet] Insert vertical divider between back button and normal browsing button in Tabs Panel. r=mcomella, a=sledru
authorMartyn Haigh <martyn.haigh@gmail.com>
Thu, 29 Jan 2015 16:29:03 +0000
changeset 243634 f308adc4e97c
parent 243633 bc4e060096bd
child 243635 25a28c2481d2
push id4421
push userryanvm@gmail.com
push date2015-02-02 19:52 +0000
treeherdermozilla-beta@08a02585bc60 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella, sledru
bugs1110149
milestone36.0
Bug 1110149 - [Tablet] Insert vertical divider between back button and normal browsing button in Tabs Panel. r=mcomella, a=sledru
mobile/android/base/moz.build
mobile/android/base/newtablet/res/layout-large-v11/new_tablet_tabs_panel_back_button.xml
mobile/android/base/resources/layout/tabs_panel_default.xml
mobile/android/base/resources/values/attrs.xml
mobile/android/base/resources/values/dimens.xml
mobile/android/base/tabs/TabPanelBackButton.java
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -406,16 +406,17 @@ gbjar.sources += [
     'Tab.java',
     'Tabs.java',
     'tabs/PrivateTabsPanel.java',
     'tabs/TabCurve.java',
     'tabs/TabHistoryController.java',
     'tabs/TabHistoryFragment.java',
     'tabs/TabHistoryItemRow.java',
     'tabs/TabHistoryPage.java',
+    'tabs/TabPanelBackButton.java',
     'tabs/TabsGridLayout.java',
     'tabs/TabsLayoutAdapter.java',
     'tabs/TabsLayoutItemView.java',
     'tabs/TabsListLayout.java',
     'tabs/TabsPanel.java',
     'TabsAccessor.java',
     'Telemetry.java',
     'TelemetryContract.java',
--- a/mobile/android/base/newtablet/res/layout-large-v11/new_tablet_tabs_panel_back_button.xml
+++ b/mobile/android/base/newtablet/res/layout-large-v11/new_tablet_tabs_panel_back_button.xml
@@ -1,14 +1,17 @@
 <?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:id="@+id/nav_back"
-             android:layout_width="@dimen/tabs_panel_indicator_width"
-             android:layout_height="match_parent"
-             android:minWidth="@dimen/tabs_panel_indicator_width"
-             android:src="@drawable/new_tablet_nav_back"
-             android:contentDescription="@string/back"
-             android:background="@drawable/action_bar_button_inverse"/>
+<org.mozilla.gecko.tabs.TabPanelBackButton xmlns:android="http://schemas.android.com/apk/res/android"
+                                           xmlns:gecko="http://schemas.android.com/apk/res-auto"
+                                           android:id="@+id/nav_back"
+                                           android:layout_width="@dimen/tabs_panel_indicator_width"
+                                           android:layout_height="match_parent"
+                                           android:minWidth="@dimen/tabs_panel_indicator_width"
+                                           android:src="@drawable/new_tablet_nav_back"
+                                           android:contentDescription="@string/back"
+                                           android:background="@drawable/action_bar_button_inverse"
+                                           gecko:dividerVerticalPadding="@dimen/new_tablet_tab_panel_divider_vertical_padding"
+                                           gecko:rightDivider="@drawable/tab_indicator_divider"/>
 
--- a/mobile/android/base/resources/layout/tabs_panel_default.xml
+++ b/mobile/android/base/resources/layout/tabs_panel_default.xml
@@ -20,16 +20,17 @@
                       android:layout_width="wrap_content"
                       android:layout_height="match_parent"/>
 
             <org.mozilla.gecko.widget.IconTabWidget android:id="@+id/tab_widget"
                                                     android:layout_width="wrap_content"
                                                     android:layout_height="match_parent"
                                                     android:tabStripEnabled="false"
                                                     android:divider="@drawable/tab_indicator_divider"
+                                                    android:dividerPadding="@dimen/new_tablet_tab_panel_divider_vertical_padding"
                                                     android:layout="@layout/tabs_panel_indicator"/>
 
             <View android:layout_width="0dip"
                   android:layout_height="match_parent"
                   android:layout_weight="1.0"/>
 
             <ImageButton android:id="@+id/add_tab"
                          style="@style/UrlBar.ImageButton"
--- a/mobile/android/base/resources/values/attrs.xml
+++ b/mobile/android/base/resources/values/attrs.xml
@@ -175,16 +175,21 @@
         <attr name="android:horizontalSpacing"/>
         <attr name="android:verticalSpacing"/>
     </declare-styleable>
 
     <declare-styleable name="TabMenuStrip">
         <attr name="strip" format="reference"/>
     </declare-styleable>
 
+    <declare-styleable name="TabPanelBackButton">
+        <attr name="rightDivider" format="reference"/>
+        <attr name="dividerVerticalPadding" format="dimension"/>
+    </declare-styleable>
+
     <declare-styleable name="EllipsisTextView">
         <attr name="ellipsizeAtLine" format="integer"/>
     </declare-styleable>
 
     <declare-styleable name="FloatingHintEditText">
         <attr name="floatingHintEditTextStyle" format="reference" />
     </declare-styleable>
 
--- a/mobile/android/base/resources/values/dimens.xml
+++ b/mobile/android/base/resources/values/dimens.xml
@@ -17,16 +17,20 @@
     <dimen name="browser_toolbar_favicon_size">21.33dip</dimen>
     <dimen name="browser_toolbar_shadow_size">2dp</dimen>
 
     <!-- If you update one of these values, update the others. -->
     <dimen name="new_tablet_nav_button_width">42dp</dimen>
     <dimen name="new_tablet_nav_button_width_half">21dp</dimen>
     <dimen name="new_tablet_nav_button_width_plus_half">63dp</dimen>
 
+    <!-- This is the system default for the vertical padding for the divider of the TabWidget.
+         Used to mimic the divider padding on the tablet tabs panel back button. -->
+    <dimen name="new_tablet_tab_panel_divider_vertical_padding">12dp</dimen>
+
     <dimen name="new_tablet_tab_strip_height">48dp</dimen>
     <dimen name="new_tablet_tab_strip_item_width">208dp</dimen>
     <dimen name="new_tablet_tab_strip_item_margin">-28dp</dimen>
     <dimen name="new_tablet_tab_strip_favicon_size">16dp</dimen>
     <dimen name="new_tablet_tab_strip_fading_edge_size">15dp</dimen>
     <dimen name="new_tablet_site_security_height">60dp</dimen>
     <dimen name="new_tablet_site_security_width">34dp</dimen>
     <!-- We primarily use padding (instead of margins) to increase the hit area. -->
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/tabs/TabPanelBackButton.java
@@ -0,0 +1,55 @@
+/* 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.tabs;
+
+import org.mozilla.gecko.R;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.view.ViewGroup;
+import android.widget.ImageButton;
+
+public class TabPanelBackButton extends ImageButton {
+
+    private int dividerWidth = 0;
+
+    private final Drawable divider;
+    private final int dividerPadding;
+
+    public TabPanelBackButton(Context context, AttributeSet attrs) {
+        super(context, attrs);
+
+        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabPanelBackButton);
+        divider = a.getDrawable(R.styleable.TabPanelBackButton_rightDivider);
+        dividerPadding = (int) a.getDimension(R.styleable.TabPanelBackButton_dividerVerticalPadding, 0);
+        a.recycle();
+
+        if (divider != null) {
+            dividerWidth = divider.getIntrinsicWidth();
+        }
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+        setMeasuredDimension(getMeasuredWidth() + dividerWidth, getMeasuredHeight());
+    }
+
+    @Override
+    protected void onDraw(Canvas canvas) {
+        super.onDraw(canvas);
+        if (divider != null) {
+            final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) getLayoutParams();
+            final int left = getRight() - lp.rightMargin - dividerWidth;
+
+            divider.setBounds(left, getPaddingTop() + dividerPadding,
+                    left + dividerWidth, getHeight() - getPaddingBottom() - dividerPadding);
+            divider.draw(canvas);
+        }
+    }
+}