diff options
author | Alan Viverette <alanv@google.com> | 2014-12-12 22:00:24 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-12-12 22:00:26 +0000 |
commit | 7c3212b2f4f2f4b5ee18f2db925db95ee420d489 (patch) | |
tree | 5e7ead107eb2e7a847106583ddbf9f9384527d42 /graphics | |
parent | 9a1b4c29672f7b7a8cfdeedfc2421854439c0af0 (diff) | |
parent | 419aa7ad14926a30220aa3b71d045855ea54040a (diff) | |
download | frameworks_base-7c3212b2f4f2f4b5ee18f2db925db95ee420d489.zip frameworks_base-7c3212b2f4f2f4b5ee18f2db925db95ee420d489.tar.gz frameworks_base-7c3212b2f4f2f4b5ee18f2db925db95ee420d489.tar.bz2 |
Merge "Propagate DrawableContainer state on mutate, fix ColorDrawable theming" into lmp-mr1-dev
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/drawable/ColorDrawable.java | 5 | ||||
-rw-r--r-- | graphics/java/android/graphics/drawable/DrawableContainer.java | 78 |
2 files changed, 53 insertions, 30 deletions
diff --git a/graphics/java/android/graphics/drawable/ColorDrawable.java b/graphics/java/android/graphics/drawable/ColorDrawable.java index 0f0c844..e3b50ea 100644 --- a/graphics/java/android/graphics/drawable/ColorDrawable.java +++ b/graphics/java/android/graphics/drawable/ColorDrawable.java @@ -252,6 +252,11 @@ public class ColorDrawable extends Drawable { } @Override + public boolean canApplyTheme() { + return mColorState.canApplyTheme() || super.canApplyTheme(); + } + + @Override public void applyTheme(Theme t) { super.applyTheme(t); diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java index 3fe408a..39ef10c 100644 --- a/graphics/java/android/graphics/drawable/DrawableContainer.java +++ b/graphics/java/android/graphics/drawable/DrawableContainer.java @@ -447,36 +447,10 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { mCurrDrawable = d; mCurIndex = idx; if (d != null) { - d.mutate(); if (mDrawableContainerState.mEnterFadeDuration > 0) { mEnterAnimationEnd = now + mDrawableContainerState.mEnterFadeDuration; - } else if (mHasAlpha) { - d.setAlpha(mAlpha); - } - if (mDrawableContainerState.mHasColorFilter) { - // Color filter always overrides tint. - d.setColorFilter(mDrawableContainerState.mColorFilter); - } else { - if (mDrawableContainerState.mHasTintList) { - d.setTintList(mDrawableContainerState.mTintList); - } - if (mDrawableContainerState.mHasTintMode) { - d.setTintMode(mDrawableContainerState.mTintMode); - } - } - d.setVisible(isVisible(), true); - d.setDither(mDrawableContainerState.mDither); - d.setState(getState()); - d.setLevel(getLevel()); - d.setBounds(getBounds()); - d.setLayoutDirection(getLayoutDirection()); - d.setAutoMirrored(mDrawableContainerState.mAutoMirrored); - - final Rect hotspotBounds = mHotspotBounds; - if (hotspotBounds != null) { - d.setHotspotBounds(hotspotBounds.left, hotspotBounds.top, - hotspotBounds.right, hotspotBounds.bottom); } + initializeDrawableForDisplay(d); } } else { mCurrDrawable = null; @@ -503,6 +477,45 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { return true; } + /** + * Initializes a drawable for display in this container. + * + * @param d The drawable to initialize. + */ + private void initializeDrawableForDisplay(Drawable d) { + d.mutate(); + + if (mDrawableContainerState.mEnterFadeDuration <= 0 && mHasAlpha) { + d.setAlpha(mAlpha); + } + + if (mDrawableContainerState.mHasColorFilter) { + // Color filter always overrides tint. + d.setColorFilter(mDrawableContainerState.mColorFilter); + } else { + if (mDrawableContainerState.mHasTintList) { + d.setTintList(mDrawableContainerState.mTintList); + } + if (mDrawableContainerState.mHasTintMode) { + d.setTintMode(mDrawableContainerState.mTintMode); + } + } + + d.setVisible(isVisible(), true); + d.setDither(mDrawableContainerState.mDither); + d.setState(getState()); + d.setLevel(getLevel()); + d.setBounds(getBounds()); + d.setLayoutDirection(getLayoutDirection()); + d.setAutoMirrored(mDrawableContainerState.mAutoMirrored); + + final Rect hotspotBounds = mHotspotBounds; + if (hotspotBounds != null) { + d.setHotspotBounds(hotspotBounds.left, hotspotBounds.top, + hotspotBounds.right, hotspotBounds.bottom); + } + } + void animate(boolean schedule) { mHasAlpha = true; @@ -1136,9 +1149,14 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { // The locally cached drawables may have changed. if (mCurIndex >= 0) { mCurrDrawable = state.getChild(mCurIndex); + if (mCurrDrawable != null) { + initializeDrawableForDisplay(mCurrDrawable); + } } - if (mLastIndex >= 0) { - mLastDrawable = state.getChild(mLastIndex); - } + + // Clear out the last drawable. We don't have enough information to + // propagate local state from the past. + mLastIndex = -1; + mLastDrawable = null; } } |