summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2016-11-08 10:40:34 -0800
committerTony Wickham <twickham@google.com>2016-11-11 10:59:17 -0800
commit6b910a235db74b1965c5f5bb16c7fe44b1dc4cdd (patch)
tree8f0d535e757499437fed6f356714302aae4a62f4 /src
parentf4a0d1886fe5fcce3a3b722f675832b44f6e31c4 (diff)
downloadandroid_packages_apps_Trebuchet-6b910a235db74b1965c5f5bb16c7fe44b1dc4cdd.tar.gz
android_packages_apps_Trebuchet-6b910a235db74b1965c5f5bb16c7fe44b1dc4cdd.tar.bz2
android_packages_apps_Trebuchet-6b910a235db74b1965c5f5bb16c7fe44b1dc4cdd.zip
Keep disabled FastBitmapDrawables disabled while fast scrolling.
Previously, they were animating to be colored because they were set to have a FAST_SCROLL_UNLHIGHLIGHTED state. Now they retain their disabled color when changing fast scroll states. Specfically, we remove the DISABLED state and instead make it a property of the FastBitmapDrawable. Bug: 32642959 Change-Id: I6cb2da134a550c267eebfc756eff8c91a33f028c
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/BubbleTextView.java9
-rw-r--r--src/com/android/launcher3/FastBitmapDrawable.java30
-rw-r--r--src/com/android/launcher3/PendingAppWidgetHostView.java2
-rw-r--r--src/com/android/launcher3/PreloadIconDrawable.java6
4 files changed, 27 insertions, 20 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index bb4b2cec1..dbb797dc5 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -191,9 +191,7 @@ public class BubbleTextView extends TextView
private void applyIconAndLabel(Bitmap icon, ItemInfo info) {
FastBitmapDrawable iconDrawable = mLauncher.createIconDrawable(icon);
- if (info.isDisabled()) {
- iconDrawable.setState(FastBitmapDrawable.State.DISABLED);
- }
+ iconDrawable.setIsDisabled(info.isDisabled());
setIcon(iconDrawable);
setText(info.title);
if (info.contentDescription != null) {
@@ -262,10 +260,7 @@ public class BubbleTextView extends TextView
private void updateIconState() {
if (mIcon instanceof FastBitmapDrawable) {
FastBitmapDrawable d = (FastBitmapDrawable) mIcon;
- if (getTag() instanceof ItemInfo
- && ((ItemInfo) getTag()).isDisabled()) {
- d.animateState(FastBitmapDrawable.State.DISABLED);
- } else if (isPressed() || mStayPressed) {
+ if (isPressed() || mStayPressed) {
d.animateState(FastBitmapDrawable.State.PRESSED);
} else {
d.animateState(FastBitmapDrawable.State.NORMAL);
diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java
index 38700805f..7eaae5a44 100644
--- a/src/com/android/launcher3/FastBitmapDrawable.java
+++ b/src/com/android/launcher3/FastBitmapDrawable.java
@@ -34,6 +34,8 @@ import android.util.SparseArray;
import android.view.animation.DecelerateInterpolator;
public class FastBitmapDrawable extends Drawable {
+ private static final float DISABLED_DESATURATION = 1f;
+ private static final float DISABLED_BRIGHTNESS = 0.5f;
/**
* The possible states that a FastBitmapDrawable can be in.
@@ -43,8 +45,7 @@ public class FastBitmapDrawable extends Drawable {
NORMAL (0f, 0f, 1f, new DecelerateInterpolator()),
PRESSED (0f, 100f / 255f, 1f, CLICK_FEEDBACK_INTERPOLATOR),
FAST_SCROLL_HIGHLIGHTED (0f, 0f, 1.15f, new DecelerateInterpolator()),
- FAST_SCROLL_UNHIGHLIGHTED (0f, 0f, 1f, new DecelerateInterpolator()),
- DISABLED (1f, 0.5f, 1f, new DecelerateInterpolator());
+ FAST_SCROLL_UNHIGHLIGHTED (0f, 0f, 1f, new DecelerateInterpolator());
public final float desaturation;
public final float brightness;
@@ -96,6 +97,7 @@ public class FastBitmapDrawable extends Drawable {
private final Paint mPaint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
private final Bitmap mBitmap;
private State mState = State.NORMAL;
+ private boolean mIsDisabled;
// The saturation and brightness are values that are mapped to REDUCED_FILTER_VALUE_SPACE and
// as a result, can be used to compose the key for the cached ColorMatrixColorFilters
@@ -177,13 +179,14 @@ public class FastBitmapDrawable extends Drawable {
if (mState != newState) {
mState = newState;
+ float desaturation = mIsDisabled ? DISABLED_DESATURATION : newState.desaturation;
+ float brightness = mIsDisabled ? DISABLED_BRIGHTNESS: newState.brightness;
+
mPropertyAnimator = cancelAnimator(mPropertyAnimator);
mPropertyAnimator = new AnimatorSet();
mPropertyAnimator.playTogether(
- ObjectAnimator
- .ofFloat(this, "desaturation", newState.desaturation),
- ObjectAnimator
- .ofFloat(this, "brightness", newState.brightness));
+ ObjectAnimator.ofFloat(this, "desaturation", desaturation),
+ ObjectAnimator.ofFloat(this, "brightness", brightness));
mPropertyAnimator.setInterpolator(newState.interpolator);
mPropertyAnimator.setDuration(getDurationForStateChange(prevState, newState));
mPropertyAnimator.setStartDelay(getStartDelayForStateChange(prevState, newState));
@@ -204,13 +207,17 @@ public class FastBitmapDrawable extends Drawable {
mPropertyAnimator = cancelAnimator(mPropertyAnimator);
- setDesaturation(newState.desaturation);
- setBrightness(newState.brightness);
+ invalidateDesaturationAndBrightness();
return true;
}
return false;
}
+ private void invalidateDesaturationAndBrightness() {
+ setDesaturation(mIsDisabled ? DISABLED_DESATURATION : mState.desaturation);
+ setBrightness(mIsDisabled ? DISABLED_BRIGHTNESS: mState.brightness);
+ }
+
/**
* Returns the current state.
*/
@@ -218,6 +225,13 @@ public class FastBitmapDrawable extends Drawable {
return mState;
}
+ public void setIsDisabled(boolean isDisabled) {
+ if (mIsDisabled != isDisabled) {
+ mIsDisabled = isDisabled;
+ invalidateDesaturationAndBrightness();
+ }
+ }
+
/**
* Returns the duration for the state change animation.
*/
diff --git a/src/com/android/launcher3/PendingAppWidgetHostView.java b/src/com/android/launcher3/PendingAppWidgetHostView.java
index f01c7f259..bf397744b 100644
--- a/src/com/android/launcher3/PendingAppWidgetHostView.java
+++ b/src/com/android/launcher3/PendingAppWidgetHostView.java
@@ -134,7 +134,7 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implemen
// 3) Setup icon in the center and app icon in the top right corner.
if (mDisabledForSafeMode) {
FastBitmapDrawable disabledIcon = mLauncher.createIconDrawable(mIcon);
- disabledIcon.setState(FastBitmapDrawable.State.DISABLED);
+ disabledIcon.setIsDisabled(true);
mCenterDrawable = disabledIcon;
mSettingIconDrawable = null;
} else if (isReadyForClickSetup()) {
diff --git a/src/com/android/launcher3/PreloadIconDrawable.java b/src/com/android/launcher3/PreloadIconDrawable.java
index 8295b45e8..efc0eaca2 100644
--- a/src/com/android/launcher3/PreloadIconDrawable.java
+++ b/src/com/android/launcher3/PreloadIconDrawable.java
@@ -177,10 +177,8 @@ public class PreloadIconDrawable extends Drawable {
// Set the paint color only when the level changes, so that the dominant color
// is only calculated when needed.
mPaint.setColor(getIndicatorColor());
- }
- if (mIcon instanceof FastBitmapDrawable) {
- ((FastBitmapDrawable) mIcon).setState(level <= 0 ?
- FastBitmapDrawable.State.DISABLED : FastBitmapDrawable.State.NORMAL);
+ } else if (mIcon instanceof FastBitmapDrawable) {
+ ((FastBitmapDrawable) mIcon).setIsDisabled(true);
}
invalidateSelf();