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

Commit 364c73a9 authored by mpodolian's avatar mpodolian
Browse files

Fixed bubble badge position on stack move.

Badge was misplaced because of one boolean was used for both views - the
dot view which is animated and the badge view which is currently not
animated

Test: Visual
Fixes: 337939211
Flag: N/A
Change-Id: Id28a4f50aec30762835bb106f95ecddfab89c2a6
parent f0694c53
Loading
Loading
Loading
Loading
+13 −11
Original line number Original line Diff line number Diff line
@@ -82,8 +82,8 @@ public class BadgedImageView extends ConstraintLayout {


    private BubbleViewProvider mBubble;
    private BubbleViewProvider mBubble;
    private BubblePositioner mPositioner;
    private BubblePositioner mPositioner;
    private boolean mOnLeft;
    private boolean mBadgeOnLeft;

    private boolean mDotOnLeft;
    private DotRenderer mDotRenderer;
    private DotRenderer mDotRenderer;
    private DotRenderer.DrawParams mDrawParams;
    private DotRenderer.DrawParams mDrawParams;
    private int mDotColor;
    private int mDotColor;
@@ -153,7 +153,8 @@ public class BadgedImageView extends ConstraintLayout {


    public void hideDotAndBadge(boolean onLeft) {
    public void hideDotAndBadge(boolean onLeft) {
        addDotSuppressionFlag(BadgedImageView.SuppressionFlag.BEHIND_STACK);
        addDotSuppressionFlag(BadgedImageView.SuppressionFlag.BEHIND_STACK);
        mOnLeft = onLeft;
        mBadgeOnLeft = onLeft;
        mDotOnLeft = onLeft;
        hideBadge();
        hideBadge();
    }
    }


@@ -185,7 +186,7 @@ public class BadgedImageView extends ConstraintLayout {


        mDrawParams.dotColor = mDotColor;
        mDrawParams.dotColor = mDotColor;
        mDrawParams.iconBounds = mTempBounds;
        mDrawParams.iconBounds = mTempBounds;
        mDrawParams.leftAlign = mOnLeft;
        mDrawParams.leftAlign = mDotOnLeft;
        mDrawParams.scale = mDotScale;
        mDrawParams.scale = mDotScale;


        mDotRenderer.draw(canvas, mDrawParams);
        mDotRenderer.draw(canvas, mDrawParams);
@@ -255,7 +256,7 @@ public class BadgedImageView extends ConstraintLayout {
     * Whether decorations (badges or dots) are on the left.
     * Whether decorations (badges or dots) are on the left.
     */
     */
    boolean getDotOnLeft() {
    boolean getDotOnLeft() {
        return mOnLeft;
        return mDotOnLeft;
    }
    }


    /**
    /**
@@ -263,7 +264,7 @@ public class BadgedImageView extends ConstraintLayout {
     */
     */
    float[] getDotCenter() {
    float[] getDotCenter() {
        float[] dotPosition;
        float[] dotPosition;
        if (mOnLeft) {
        if (mDotOnLeft) {
            dotPosition = mDotRenderer.getLeftDotPosition();
            dotPosition = mDotRenderer.getLeftDotPosition();
        } else {
        } else {
            dotPosition = mDotRenderer.getRightDotPosition();
            dotPosition = mDotRenderer.getRightDotPosition();
@@ -291,22 +292,23 @@ public class BadgedImageView extends ConstraintLayout {
        if (onLeft != getDotOnLeft()) {
        if (onLeft != getDotOnLeft()) {
            if (shouldDrawDot()) {
            if (shouldDrawDot()) {
                animateDotScale(0f /* showDot */, () -> {
                animateDotScale(0f /* showDot */, () -> {
                    mOnLeft = onLeft;
                    mDotOnLeft = onLeft;
                    invalidate();
                    invalidate();
                    animateDotScale(1.0f, null /* after */);
                    animateDotScale(1.0f, null /* after */);
                });
                });
            } else {
            } else {
                mOnLeft = onLeft;
                mDotOnLeft = onLeft;
            }
            }
        }
        }
        mBadgeOnLeft = onLeft;
        // TODO animate badge
        // TODO animate badge
        showBadge();
        showBadge();

    }
    }


    /** Sets the position of the dot and badge. */
    /** Sets the position of the dot and badge. */
    void setDotBadgeOnLeft(boolean onLeft) {
    void setDotBadgeOnLeft(boolean onLeft) {
        mOnLeft = onLeft;
        mBadgeOnLeft = onLeft;
        mDotOnLeft = onLeft;
        invalidate();
        invalidate();
        showBadge();
        showBadge();
    }
    }
@@ -361,7 +363,7 @@ public class BadgedImageView extends ConstraintLayout {
        }
        }


        int translationX;
        int translationX;
        if (mOnLeft) {
        if (mBadgeOnLeft) {
            translationX = -(mBubble.getBubbleIcon().getWidth() - appBadgeBitmap.getWidth());
            translationX = -(mBubble.getBubbleIcon().getWidth() - appBadgeBitmap.getWidth());
        } else {
        } else {
            translationX = 0;
            translationX = 0;