Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28141129 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Properly desaturating the dragview if the icon is disabled

Change-Id: Ic53078750fab013ed07999c6e9a6bf5d9b4c2554
parent 318f567a
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -36,8 +36,6 @@ import com.android.launcher3.graphics.IconPalette;

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;
@@ -184,6 +182,11 @@ public class FastBitmapDrawable extends Drawable {
        return true;
    }

    @Override
    public ColorFilter getColorFilter() {
        return mPaint.getColorFilter();
    }

    @Override
    protected boolean onStateChange(int[] state) {
        boolean isPressed = false;
+10 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.content.pm.LauncherActivityInfo;
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 @@ public class DragView extends FrameLayout {
                            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);
                            }
                        }
                    });
                }