Bug 1076260 - Adjust new tablet divider size and color. r=lucasr
authorMichael Comella <michael.l.comella@gmail.com>
Fri, 03 Oct 2014 18:00:59 -0700
changeset 208747 15d93e79679e04a824cf9f05c39401d13b653b74
parent 208746 b28e496d535b80d31c00d3561514e6d5dd9f55fa
child 208748 ec342eaecda36f8ee5dd5ce7153b4d9dfa7969b4
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerslucasr
bugs1076260
milestone35.0a1
Bug 1076260 - Adjust new tablet divider size and color. r=lucasr
mobile/android/base/newtablet/res/drawable-large-v11/new_tablet_tab_strip_divider.xml
mobile/android/base/tabs/TabStripView.java
--- a/mobile/android/base/newtablet/res/drawable-large-v11/new_tablet_tab_strip_divider.xml
+++ b/mobile/android/base/newtablet/res/drawable-large-v11/new_tablet_tab_strip_divider.xml
@@ -1,17 +1,18 @@
 <?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/. -->
 
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
 
-    <gradient
-        android:startColor="#D1D5DA"
-        android:endColor="@android:color/transparent"
-        android:angle="90"/>
+    <solid android:color="#555555"/>
 
     <size android:width="1dp"
-          android:height="32dp"/>
+          android:height="30dp"/>
+
+    <!-- We draw this ourselves in TabStripView.draw() and to avoid implementing more
+         than we have to, only bottom padding is taken into account. -->
+    <padding android:bottom="6dp"/>
 
 </shape>
--- a/mobile/android/base/tabs/TabStripView.java
+++ b/mobile/android/base/tabs/TabStripView.java
@@ -3,16 +3,17 @@
  * 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 android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Canvas;
+import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 import android.view.View;
 import android.view.ViewGroup;
 
 import java.util.ArrayList;
 import java.util.List;
 
@@ -22,30 +23,35 @@ import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.widget.TwoWayView;
 
 public class TabStripView extends TwoWayView {
     private static final String LOGTAG = "GeckoTabStrip";
 
     private final TabStripAdapter adapter;
     private final Drawable divider;
 
+    // Filled by calls to ShapeDrawable.getPadding();
+    // saved to prevent allocation in draw().
+    private final Rect dividerPadding = new Rect();
+
     private boolean isPrivate;
 
     public TabStripView(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         setOrientation(Orientation.HORIZONTAL);
         setChoiceMode(ChoiceMode.SINGLE);
         setItemsCanFocus(true);
         setChildrenDrawingOrderEnabled(true);
         setWillNotDraw(false);
 
         final Resources resources = getResources();
 
         divider = resources.getDrawable(R.drawable.new_tablet_tab_strip_divider);
+        divider.getPadding(dividerPadding);
 
         final int itemMargin =
                 resources.getDimensionPixelSize(R.dimen.new_tablet_tab_strip_item_margin);
         setItemMargin(itemMargin);
 
         adapter = new TabStripAdapter(context);
         setAdapter(adapter);
     }
@@ -136,17 +142,17 @@ public class TabStripView extends TwoWay
             return i;
         }
     }
 
     @Override
     public void draw(Canvas canvas) {
         super.draw(canvas);
 
-        final int bottom = getHeight() - getPaddingBottom();
+        final int bottom = getHeight() - getPaddingBottom() - dividerPadding.bottom;
         final int top = bottom - divider.getIntrinsicHeight();
 
         final int dividerWidth = divider.getIntrinsicWidth();
         final int itemMargin = getItemMargin();
 
         final int childCount = getChildCount();
         final int checkedIndex = getCheckedIndex(childCount);