Bug 1058660 - Draw divider at the bottom of about:home's tab strip. r=margaret, a=lmandel
authorLucas Rocha <lucasr@lucasr.org>
Mon, 13 Oct 2014 15:50:38 +0100
changeset 225771 7d2f3db4567d
parent 225770 f6c14ee20738
child 225772 a73c379cfa5f
push id4013
push userryanvm@gmail.com
push date2014-10-22 23:14 +0000
treeherdermozilla-beta@a963eab53a09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, lmandel
bugs1058660
milestone34.0
Bug 1058660 - Draw divider at the bottom of about:home's tab strip. r=margaret, a=lmandel
mobile/android/base/home/HomePagerTabStrip.java
mobile/android/base/home/TabMenuStrip.java
mobile/android/base/resources/values/dimens.xml
--- a/mobile/android/base/home/HomePagerTabStrip.java
+++ b/mobile/android/base/home/HomePagerTabStrip.java
@@ -5,17 +5,20 @@
 
 package org.mozilla.gecko.home;
 
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.animation.BounceAnimator;
 import org.mozilla.gecko.animation.BounceAnimator.Attributes;
 
 import android.content.Context;
+import android.content.res.Resources;
 import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Paint;
 import android.support.v4.view.PagerTabStrip;
 import android.util.AttributeSet;
 import android.view.View;
 import android.view.ViewTreeObserver;
 
 import com.nineoldandroids.animation.AnimatorSet;
 import com.nineoldandroids.animation.ObjectAnimator;
 import com.nineoldandroids.animation.ValueAnimator;
@@ -32,40 +35,58 @@ class HomePagerTabStrip extends PagerTab
     private static final int ANIMATION_DELAY_MS = 250;
     private static final int ALPHA_MS = 10;
     private static final int BOUNCE1_MS = 350;
     private static final int BOUNCE2_MS = 200;
     private static final int BOUNCE3_MS = 100;
     private static final int BOUNCE4_MS = 100;
     private static final int INIT_OFFSET = 100;
 
+    private final Paint shadowPaint;
+    private final int shadowSize;
+
     public HomePagerTabStrip(Context context) {
-        super(context);
+        this(context, null);
     }
 
     public HomePagerTabStrip(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HomePagerTabStrip);
         int color = a.getColor(R.styleable.HomePagerTabStrip_tabIndicatorColor, 0x00);
         a.recycle();
 
         setTabIndicatorColor(color);
 
+        final Resources res = getResources();
+        shadowSize = res.getDimensionPixelSize(R.dimen.tabs_strip_shadow_size);
+
+        shadowPaint = new Paint();
+        shadowPaint.setColor(res.getColor(R.color.url_bar_shadow));
+        shadowPaint.setStrokeWidth(0.0f);
+
         getViewTreeObserver().addOnPreDrawListener(new PreDrawListener());
     }
 
     @Override
     public int getPaddingBottom() {
         // PagerTabStrip enforces a minimum bottom padding of 6dp which causes
         // misalignments when using 'center_vertical' gravity. Force padding bottom
         // to 0dp so that children are properly centered.
         return 0;
     }
 
+    @Override
+    public void draw(Canvas canvas) {
+        super.draw(canvas);
+
+        final int height = getHeight();
+        canvas.drawRect(0, height - shadowSize, getWidth(), height, shadowPaint);
+    }
+
     private void animateTitles() {
         final View prevTextView = getChildAt(0);
         final View nextTextView = getChildAt(getChildCount() - 1);
 
         if (prevTextView == null || nextTextView == null) {
             return;
         }
 
--- a/mobile/android/base/home/TabMenuStrip.java
+++ b/mobile/android/base/home/TabMenuStrip.java
@@ -3,18 +3,20 @@
  * 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.home;
 
 import org.mozilla.gecko.R;
 
 import android.content.Context;
+import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.graphics.Canvas;
+import android.graphics.Paint;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewTreeObserver;
 import android.view.accessibility.AccessibilityEvent;
 import android.widget.HorizontalScrollView;
 import android.widget.LinearLayout;
@@ -30,26 +32,45 @@ public class TabMenuStrip extends Horizo
 
     // Offset between the selected tab title and the edge of the screen,
     // except for the first and last tab in the tab strip.
     private static final int TITLE_OFFSET_DIPS = 24;
 
     private final int titleOffset;
     private final TabMenuStripLayout layout;
 
+    private final Paint shadowPaint;
+    private final int shadowSize;
+
     public TabMenuStrip(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         // Disable the scroll bar.
         setHorizontalScrollBarEnabled(false);
 
-        titleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density);
+        final Resources res = getResources();
+
+        titleOffset = (int) (TITLE_OFFSET_DIPS * res.getDisplayMetrics().density);
 
         layout = new TabMenuStripLayout(context, attrs);
         addView(layout, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
+
+        shadowSize = res.getDimensionPixelSize(R.dimen.tabs_strip_shadow_size);
+
+        shadowPaint = new Paint();
+        shadowPaint.setColor(res.getColor(R.color.url_bar_shadow));
+        shadowPaint.setStrokeWidth(0.0f);
+    }
+
+    @Override
+    public void draw(Canvas canvas) {
+        super.draw(canvas);
+
+        final int height = getHeight();
+        canvas.drawRect(0, height - shadowSize, getWidth(), height, shadowPaint);
     }
 
     @Override
     public void onAddPagerView(String title) {
         layout.onAddPagerView(title);
     }
 
     @Override
--- a/mobile/android/base/resources/values/dimens.xml
+++ b/mobile/android/base/resources/values/dimens.xml
@@ -67,16 +67,17 @@
     <dimen name="tab_thumbnail_width">160dp</dimen>
     <dimen name="tabs_counter_size">22sp</dimen>
     <dimen name="tabs_panel_indicator_width">60dp</dimen>
     <dimen name="tabs_panel_list_padding">16dip</dimen>
     <dimen name="tabs_list_divider_height">2dp</dimen>
     <dimen name="tabs_sidebar_width">200dp</dimen>
     <dimen name="tabs_strip_button_width">100dp</dimen>
     <dimen name="tabs_strip_button_padding">18dp</dimen>
+    <dimen name="tabs_strip_shadow_size">1dp</dimen>
     <dimen name="tabs_tray_horizontal_height">156dp</dimen>
     <dimen name="text_selection_handle_width">47dp</dimen>
     <dimen name="text_selection_handle_height">58dp</dimen>
     <dimen name="text_selection_handle_shadow">11dp</dimen>
     <dimen name="validation_message_height">50dp</dimen>
     <dimen name="validation_message_margin_top">6dp</dimen>
     <dimen name="forward_default_offset">-13dip</dimen>
     <dimen name="url_bar_offset_left">32dp</dimen>