diff --git a/api/current.txt b/api/current.txt
index c8b3b3b570edf..6a8b2be9d8add 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -1239,6 +1239,8 @@ package android {
field public static final int thumbTintMode = 16843892; // 0x1010474
field public static final int thumbnail = 16843429; // 0x10102a5
field public static final int tileMode = 16843265; // 0x1010201
+ field public static final int tileModeX = 16843897; // 0x1010479
+ field public static final int tileModeY = 16843898; // 0x101047a
field public static final int timeZone = 16843724; // 0x10103cc
field public static final int tint = 16843041; // 0x1010121
field public static final int tintMode = 16843797; // 0x1010415
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 02a8863803a8a..a8a4d7a78ef30 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -4813,6 +4813,32 @@
mirror images so that adjacent images always seam. -->
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -4971,6 +4997,12 @@
+
+
+
+
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 6e9dc93c4188a..28e66d5e3aa20 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2210,6 +2210,8 @@
+
+
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java
index 0a394d56d3224..e080375996503 100644
--- a/graphics/java/android/graphics/drawable/BitmapDrawable.java
+++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java
@@ -757,7 +757,18 @@ public class BitmapDrawable extends Drawable {
final int tileMode = a.getInt(R.styleable.BitmapDrawable_tileMode, TILE_MODE_UNDEFINED);
if (tileMode != TILE_MODE_UNDEFINED) {
- setTileModeInternal(tileMode);
+ final Shader.TileMode mode = parseTileMode(tileMode);
+ setTileModeXY(mode, mode);
+ }
+
+ final int tileModeX = a.getInt(R.styleable.BitmapDrawable_tileModeX, TILE_MODE_UNDEFINED);
+ if (tileModeX != TILE_MODE_UNDEFINED) {
+ setTileModeX(parseTileMode(tileModeX));
+ }
+
+ final int tileModeY = a.getInt(R.styleable.BitmapDrawable_tileModeY, TILE_MODE_UNDEFINED);
+ if (tileModeY != TILE_MODE_UNDEFINED) {
+ setTileModeY(parseTileMode(tileModeY));
}
// Update local properties.
@@ -783,20 +794,16 @@ public class BitmapDrawable extends Drawable {
}
}
- private void setTileModeInternal(final int tileMode) {
+ private static Shader.TileMode parseTileMode(int tileMode) {
switch (tileMode) {
- case TILE_MODE_DISABLED:
- setTileModeXY(null, null);
- break;
case TILE_MODE_CLAMP:
- setTileModeXY(Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
- break;
+ return Shader.TileMode.CLAMP;
case TILE_MODE_REPEAT:
- setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
- break;
+ return Shader.TileMode.REPEAT;
case TILE_MODE_MIRROR:
- setTileModeXY(Shader.TileMode.MIRROR, Shader.TileMode.MIRROR);
- break;
+ return Shader.TileMode.MIRROR;
+ default:
+ return null;
}
}
@@ -919,7 +926,9 @@ public class BitmapDrawable extends Drawable {
}
/**
- * Initializes local dynamic properties from state.
+ * Initializes local dynamic properties from state. This should be called
+ * after significant state changes, e.g. from the One True Constructor and
+ * after inflating or applying a theme.
*/
private void initializeWithState(BitmapState state, Resources res) {
if (res != null) {
diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java
index 369bb591803dc..86765dd4d20f2 100644
--- a/graphics/java/android/graphics/drawable/ShapeDrawable.java
+++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java
@@ -396,6 +396,9 @@ public class ShapeDrawable extends Drawable {
" for ShapeDrawable " + this);
}
}
+
+ // Update local properties.
+ initializeWithState(mShapeState, r);
}
@Override
@@ -410,6 +413,9 @@ public class ShapeDrawable extends Drawable {
final TypedArray a = t.resolveAttributes(state.mThemeAttrs, R.styleable.ShapeDrawable);
updateStateFromTypedArray(a);
a.recycle();
+
+ // Update local properties.
+ initializeWithState(state, t.getResources());
}
private void updateStateFromTypedArray(TypedArray a) {
@@ -431,6 +437,16 @@ public class ShapeDrawable extends Drawable {
R.styleable.ShapeDrawable_width, state.mIntrinsicWidth));
setIntrinsicHeight((int) a.getDimension(
R.styleable.ShapeDrawable_height, state.mIntrinsicHeight));
+
+ final int tintMode = a.getInt(R.styleable.ShapeDrawable_tintMode, -1);
+ if (tintMode != -1) {
+ state.mTintMode = Drawable.parseTintMode(tintMode, Mode.SRC_IN);
+ }
+
+ final ColorStateList tint = a.getColorStateList(R.styleable.ShapeDrawable_tint);
+ if (tint != null) {
+ state.mTint = tint;
+ }
}
private void updateShape() {
@@ -545,6 +561,10 @@ public class ShapeDrawable extends Drawable {
}
}
+ /**
+ * The one constructor to rule them all. This is called by all public
+ * constructors to set the state and initialize local properties.
+ */
private ShapeDrawable(ShapeState state, Resources res, Theme theme) {
if (theme != null && state.canApplyTheme()) {
mShapeState = new ShapeState(state);
@@ -553,7 +573,16 @@ public class ShapeDrawable extends Drawable {
mShapeState = state;
}
- mTintFilter = updateTintFilter(mTintFilter, mShapeState.mTint, mShapeState.mTintMode);
+ initializeWithState(state, res);
+ }
+
+ /**
+ * Initializes local dynamic properties from state. This should be called
+ * after significant state changes, e.g. from the One True Constructor and
+ * after inflating or applying a theme.
+ */
+ private void initializeWithState(ShapeState state, Resources res) {
+ mTintFilter = updateTintFilter(mTintFilter, state.mTint, state.mTintMode);
}
/**