Properly desaturating the dragview if the icon is disabled
Change-Id: Ic53078750fab013ed07999c6e9a6bf5d9b4c2554
diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java
index 199baaf..2ec6b4c 100644
--- a/src/com/android/launcher3/FastBitmapDrawable.java
+++ b/src/com/android/launcher3/FastBitmapDrawable.java
@@ -36,8 +36,6 @@
public class FastBitmapDrawable extends Drawable {
- private static final int[] STATE_PRESSED = new int[] {android.R.attr.state_pressed};
-
private static final float PRESSED_BRIGHTNESS = 100f / 255f;
private static final float DISABLED_DESATURATION = 1f;
private static final float DISABLED_BRIGHTNESS = 0.5f;
@@ -185,6 +183,11 @@
}
@Override
+ public ColorFilter getColorFilter() {
+ return mPaint.getColorFilter();
+ }
+
+ @Override
protected boolean onStateChange(int[] state) {
boolean isPressed = false;
for (int s : state) {
diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java
index 0418d25..ab2f100 100644
--- a/src/com/android/launcher3/dragndrop/DragView.java
+++ b/src/com/android/launcher3/dragndrop/DragView.java
@@ -29,6 +29,7 @@
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.ColorFilter;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Matrix;
@@ -245,6 +246,15 @@
addView(mBgImageView);
addView(mFgImageView);
setWillNotDraw(true);
+
+ if (info.isDisabled()) {
+ FastBitmapDrawable d = new FastBitmapDrawable(null);
+ d.setIsDisabled(true);
+ ColorFilter cf = d.getColorFilter();
+ mBgImageView.setColorFilter(cf);
+ mFgImageView.setColorFilter(cf);
+ mBadge.setColorFilter(cf);
+ }
}
});
}