summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-01-10 22:10:14 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-01-10 22:10:14 +0000
commit7682e0396438320226408f23fc4bf04993d24f69 (patch)
treefe1ed40a827698ff556aa9d3bb0e70be7be13dbf /graphics
parentd4334718c76299bb6af71dc885dc6a5330bb8211 (diff)
parent729427d451bc4d4d268335b8dc1ff6404bc1c91e (diff)
downloadframeworks_base-7682e0396438320226408f23fc4bf04993d24f69.zip
frameworks_base-7682e0396438320226408f23fc4bf04993d24f69.tar.gz
frameworks_base-7682e0396438320226408f23fc4bf04993d24f69.tar.bz2
Merge "Fixes for DrawableContainer, LayerDrawable"
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/DrawableContainer.java30
-rw-r--r--graphics/java/android/graphics/drawable/LayerDrawable.java1
2 files changed, 25 insertions, 6 deletions
diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java
index a1e0772..a98b84f 100644
--- a/graphics/java/android/graphics/drawable/DrawableContainer.java
+++ b/graphics/java/android/graphics/drawable/DrawableContainer.java
@@ -50,6 +50,9 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
private Drawable mCurrDrawable;
private int mAlpha = 0xFF;
+ /** Whether setAlpha() has been called at least once. */
+ private boolean mHasAlpha;
+
private int mCurIndex = -1;
private boolean mMutated;
@@ -117,6 +120,8 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
@Override
public void setAlpha(int alpha) {
+ mHasAlpha = true;
+
if (mAlpha != alpha) {
mAlpha = alpha;
if (mCurrDrawable != null) {
@@ -146,8 +151,11 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
@Override
public void setColorFilter(ColorFilter cf) {
+ mDrawableContainerState.mHasColorFilter = true;
+
if (mDrawableContainerState.mColorFilter != cf) {
mDrawableContainerState.mColorFilter = cf;
+
if (mCurrDrawable != null) {
mCurrDrawable.mutate().setColorFilter(cf);
}
@@ -189,9 +197,11 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
@Override
public void setAutoMirrored(boolean mirrored) {
- mDrawableContainerState.mAutoMirrored = mirrored;
- if (mCurrDrawable != null) {
- mCurrDrawable.mutate().setAutoMirrored(mDrawableContainerState.mAutoMirrored);
+ if (mDrawableContainerState.mAutoMirrored != mirrored) {
+ mDrawableContainerState.mAutoMirrored = mirrored;
+ if (mCurrDrawable != null) {
+ mCurrDrawable.mutate().setAutoMirrored(mDrawableContainerState.mAutoMirrored);
+ }
}
}
@@ -210,7 +220,9 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
}
if (mCurrDrawable != null) {
mCurrDrawable.jumpToCurrentState();
- mCurrDrawable.mutate().setAlpha(mAlpha);
+ if (mHasAlpha) {
+ mCurrDrawable.mutate().setAlpha(mAlpha);
+ }
}
if (mExitAnimationEnd != 0) {
mExitAnimationEnd = 0;
@@ -353,12 +365,14 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
d.mutate();
if (mDrawableContainerState.mEnterFadeDuration > 0) {
mEnterAnimationEnd = now + mDrawableContainerState.mEnterFadeDuration;
- } else {
+ } else if (mHasAlpha) {
d.setAlpha(mAlpha);
}
+ if (mDrawableContainerState.mHasColorFilter) {
+ d.setColorFilter(mDrawableContainerState.mColorFilter);
+ }
d.setVisible(isVisible(), true);
d.setDither(mDrawableContainerState.mDither);
- d.setColorFilter(mDrawableContainerState.mColorFilter);
d.setState(getState());
d.setLevel(getLevel());
d.setBounds(getBounds());
@@ -394,6 +408,8 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
}
void animate(boolean schedule) {
+ mHasAlpha = true;
+
final long now = SystemClock.uptimeMillis();
boolean animating = false;
if (mCurrDrawable != null) {
@@ -507,6 +523,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
boolean mAutoMirrored;
ColorFilter mColorFilter;
+ boolean mHasColorFilter;
DrawableContainerState(DrawableContainerState orig, DrawableContainer owner,
Resources res) {
@@ -529,6 +546,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback {
mExitFadeDuration = orig.mExitFadeDuration;
mAutoMirrored = orig.mAutoMirrored;
mColorFilter = orig.mColorFilter;
+ mHasColorFilter = orig.mHasColorFilter;
// Cloning the following values may require creating futures.
mConstantPadding = orig.getConstantPadding();
diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java
index 7f00e50..feb193b 100644
--- a/graphics/java/android/graphics/drawable/LayerDrawable.java
+++ b/graphics/java/android/graphics/drawable/LayerDrawable.java
@@ -345,6 +345,7 @@ public class LayerDrawable extends Drawable implements Drawable.Callback {
childDrawable.mInsetT = t;
childDrawable.mInsetR = r;
childDrawable.mInsetB = b;
+ invalidatePadding();
}
/**