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

Commit 63e4e4ce authored by Alex Chau's avatar Alex Chau
Browse files

Avoid IconView's setModalAlpha interfere with setContentAlpha

- Because ag/27301532 we have restriction in setModalness that forbid setModalAlpha be called multiple times, this was a hack to avoid setModalAlpha interferring with setContentAlpha
- As part of ag/27301532 modalness.set no longer have the field != value check, which cause the regression that icon appears in quick switch carousel
- Now it follows IconAppChipView's implementation to use MuiliValueAlpha

Bug: 339787593
Test: Swipe up from app, or quick switch then swipe up, icon shouldn't be visible
Flag: EXEMPT refactor
Change-Id: I0abb8df951ef32ba8a0f9bbfa385c0aa3b96dd7f
parent 5a4b813d
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import androidx.annotation.Nullable;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.views.ActivityContext;
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
import com.android.quickstep.util.RecentsOrientedState;
@@ -37,21 +38,33 @@ import com.android.quickstep.util.RecentsOrientedState;
 * when the drawable changes.
 */
public class IconView extends View implements TaskViewIcon {
    private static final int NUM_ALPHA_CHANNELS = 2;
    private static final int INDEX_CONTENT_ALPHA = 0;
    private static final int INDEX_MODAL_ALPHA = 1;

    private final MultiValueAlpha mMultiValueAlpha;

    @Nullable
    private Drawable mDrawable;
    private int mDrawableWidth, mDrawableHeight;

    public IconView(Context context) {
        super(context);
        this(context, null);
    }

    public IconView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this(context, attrs, 0);
    }

    public IconView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this(context, attrs, defStyleAttr, 0);
    }

    public IconView(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
            int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        mMultiValueAlpha = new MultiValueAlpha(this, NUM_ALPHA_CHANNELS);
        mMultiValueAlpha.setUpdateVisibility(/* updateVisibility= */ true);
    }

    /**
@@ -143,22 +156,12 @@ public class IconView extends View implements TaskViewIcon {

    @Override
    public void setContentAlpha(float alpha) {
        setAlpha(alpha);
        mMultiValueAlpha.get(INDEX_CONTENT_ALPHA).setValue(alpha);
    }

    @Override
    public void setModalAlpha(float alpha) {
        setAlpha(alpha);
    }

    @Override
    public void setAlpha(float alpha) {
        super.setAlpha(alpha);
        if (alpha > 0) {
            setVisibility(VISIBLE);
        } else {
            setVisibility(INVISIBLE);
        }
        mMultiValueAlpha.get(INDEX_MODAL_ALPHA).setValue(alpha);
    }

    /**