diff --git a/mobile/android/base/newtablet/res/drawable-large-v11/new_tablet_tab_strip_item_bg.xml b/mobile/android/base/newtablet/res/drawable-large-v11/new_tablet_tab_strip_item_bg.xml
index b07399ac331..e5b8b978d67 100644
--- a/mobile/android/base/newtablet/res/drawable-large-v11/new_tablet_tab_strip_item_bg.xml
+++ b/mobile/android/base/newtablet/res/drawable-large-v11/new_tablet_tab_strip_item_bg.xml
@@ -8,45 +8,27 @@
-
-
-
-
-
+ gecko:state_private="true"
+ android:color="@color/highlight_nav_pb" />
-
-
-
-
-
+ gecko:state_private="true"
+ android:color="@color/background_private" />
-
-
-
-
-
+ gecko:state_private="true"
+ android:color="@color/highlight_dark_focused" />
-
-
-
-
-
+ android:state_checked="true"
+ android:color="@color/new_tablet_highlight" />
- -
-
-
-
-
+
- -
-
-
-
-
+
-
+
diff --git a/mobile/android/base/newtablet/res/layout-large-v11/tab_strip.xml b/mobile/android/base/newtablet/res/layout-large-v11/tab_strip.xml
index b5ae8e5bc1f..ed319b3a11d 100644
--- a/mobile/android/base/newtablet/res/layout-large-v11/tab_strip.xml
+++ b/mobile/android/base/newtablet/res/layout-large-v11/tab_strip.xml
@@ -10,8 +10,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
- android:requiresFadingEdge="horizontal"
- android:fadingEdgeLength="10dp"
android:paddingTop="8dp"/>
diff --git a/mobile/android/base/tabs/TabCurve.java b/mobile/android/base/tabs/TabCurve.java
index eb7e7259cc4..e56785c81ae 100644
--- a/mobile/android/base/tabs/TabCurve.java
+++ b/mobile/android/base/tabs/TabCurve.java
@@ -40,12 +40,12 @@ public class TabCurve {
private TabCurve() {
}
- public static int getWidthForHeight(int height) {
+ public static float getWidthForHeight(float height) {
return (int) (height * ASPECT_RATIO);
}
- public static void drawFromTop(Path path, int from, int height, Direction dir) {
- final int width = getWidthForHeight(height);
+ public static void drawFromTop(Path path, float from, float height, Direction dir) {
+ final float width = getWidthForHeight(height);
path.cubicTo(from + width * W_M1 * dir.value, 0.0f,
from + width * W_M2 * dir.value, height * H_M1,
@@ -55,8 +55,8 @@ public class TabCurve {
from + width * dir.value, height);
}
- public static void drawFromBottom(Path path, int from, int height, Direction dir) {
- final int width = getWidthForHeight(height);
+ public static void drawFromBottom(Path path, float from, float height, Direction dir) {
+ final float width = getWidthForHeight(height);
path.cubicTo(from + width * (1f - W_M3) * dir.value, height * H_M4,
from + width * (1f - W_M2) * dir.value, height * H_M3,
diff --git a/mobile/android/base/tabs/TabStripItemView.java b/mobile/android/base/tabs/TabStripItemView.java
index 878b506b650..7f43a28a9ba 100644
--- a/mobile/android/base/tabs/TabStripItemView.java
+++ b/mobile/android/base/tabs/TabStripItemView.java
@@ -9,11 +9,15 @@ import org.mozilla.gecko.AboutPages;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Tab;
import org.mozilla.gecko.Tabs;
+import org.mozilla.gecko.widget.ResizablePathDrawable;
+import org.mozilla.gecko.widget.ResizablePathDrawable.NonScaledPathShape;
import org.mozilla.gecko.widget.ThemedImageButton;
import org.mozilla.gecko.widget.ThemedLinearLayout;
import org.mozilla.gecko.widget.ThemedTextView;
import android.content.Context;
+import android.content.res.ColorStateList;
+import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -45,10 +49,10 @@ public class TabStripItemView extends ThemedLinearLayout
private final ThemedTextView titleView;
private final ThemedImageButton closeView;
- private final Paint tabPaint;
- private final Path tabShape;
+ private final ResizablePathDrawable backgroundDrawable;
private final Region tabRegion;
private final Region tabClipRegion;
+ private boolean tabRegionNeedsUpdate;
private final int faviconSize;
private Bitmap lastFavicon;
@@ -61,17 +65,17 @@ public class TabStripItemView extends ThemedLinearLayout
super(context, attrs);
setOrientation(HORIZONTAL);
- tabShape = new Path();
tabRegion = new Region();
tabClipRegion = new Region();
- tabPaint = new Paint();
- tabPaint.setAntiAlias(true);
- tabPaint.setColor(0xFFFF0000);
- tabPaint.setStrokeWidth(0.0f);
- tabPaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
+ final Resources res = context.getResources();
- faviconSize = getResources().getDimensionPixelSize(R.dimen.new_tablet_tab_strip_favicon_size);
+ final ColorStateList tabColors =
+ res.getColorStateList(R.drawable.new_tablet_tab_strip_item_bg);
+ backgroundDrawable = new ResizablePathDrawable(new TabCurveShape(), tabColors);
+ setBackgroundDrawable(backgroundDrawable);
+
+ faviconSize = res.getDimensionPixelSize(R.dimen.new_tablet_tab_strip_favicon_size);
LayoutInflater.from(context).inflate(R.layout.tab_strip_item_view, this);
setOnClickListener(new View.OnClickListener() {
@@ -106,36 +110,10 @@ public class TabStripItemView extends ThemedLinearLayout
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
super.onSizeChanged(width, height, oldWidth, oldHeight);
- tabShape.reset();
-
- final int curveWidth = TabCurve.getWidthForHeight(height);
-
- tabShape.moveTo(0, height);
- TabCurve.drawFromBottom(tabShape, 0, height, TabCurve.Direction.RIGHT);
- tabShape.lineTo(width - curveWidth, 0);
-
- TabCurve.drawFromTop(tabShape, width - curveWidth, height, TabCurve.Direction.RIGHT);
- tabShape.lineTo(0, height);
-
- tabClipRegion.set(0, 0, width, height);
- tabRegion.setPath(tabShape, tabClipRegion);
- }
-
- @Override
- public void draw(Canvas canvas) {
- final int saveCount = canvas.saveLayer(0, 0,
- getWidth(), getHeight(), null,
- Canvas.MATRIX_SAVE_FLAG |
- Canvas.CLIP_SAVE_FLAG |
- Canvas.HAS_ALPHA_LAYER_SAVE_FLAG |
- Canvas.FULL_COLOR_LAYER_SAVE_FLAG |
- Canvas.CLIP_TO_LAYER_SAVE_FLAG);
-
- super.draw(canvas);
-
- canvas.drawPath(tabShape, tabPaint);
-
- canvas.restoreToCount(saveCount);
+ // Queue a tab region update in the next draw() call. We don't
+ // update it immediately here because we need the new path from
+ // the background drawable to be updated first.
+ tabRegionNeedsUpdate = true;
}
@Override
@@ -152,6 +130,18 @@ public class TabStripItemView extends ThemedLinearLayout
return super.onTouchEvent(event);
}
+ @Override
+ public void draw(Canvas canvas) {
+ super.draw(canvas);
+
+ if (tabRegionNeedsUpdate) {
+ final Path path = backgroundDrawable.getPath();
+ tabClipRegion.set(0, 0, getWidth(), getHeight());
+ tabRegion.setPath(path, tabClipRegion);
+ tabRegionNeedsUpdate = false;
+ }
+ }
+
@Override
public int[] onCreateDrawableState(int extraSpace) {
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
@@ -237,4 +227,22 @@ public class TabStripItemView extends ThemedLinearLayout
Bitmap.createScaledBitmap(favicon, faviconSize, faviconSize, false);
faviconView.setImageBitmap(scaledFavicon);
}
+
+ private static class TabCurveShape extends NonScaledPathShape {
+ @Override
+ protected void onResize(float width, float height) {
+ final Path path = getPath();
+
+ path.reset();
+
+ final float curveWidth = TabCurve.getWidthForHeight(height);
+
+ path.moveTo(0, height);
+ TabCurve.drawFromBottom(path, 0, height, TabCurve.Direction.RIGHT);
+ path.lineTo(width - curveWidth, 0);
+
+ TabCurve.drawFromTop(path, width - curveWidth, height, TabCurve.Direction.RIGHT);
+ path.lineTo(0, height);
+ }
+ }
}