Bug 1076260 - Adjust new tablet divider size and color. r=lucasr
--- 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);