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

Commit 0b9bc54c authored by Aaron Liu's avatar Aaron Liu
Browse files

[Bouncer] Remove flicker of message area.

When locked out for 30s, we add a timer that changes the message every
second. The animation is a bit jarring, so I added a way to disable the
animation in cases like this.

Fixes: 257407393
Test: Add unique incorrect pins until I get the dialog that I have been
locked out. Observe the changes. Also observe that the bouner title
still animates in other cases.
Test: Added unit tests.

Change-Id: I5e09686174ac17cae139f5f9535e946e39d6d009
parent 2a4339d0
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -69,10 +69,16 @@ open class BouncerKeyguardMessageArea(context: Context?, attrs: AttributeSet?) :
        super.reloadColor()
        super.reloadColor()
    }
    }


    override fun setMessage(msg: CharSequence?) {
    override fun setMessage(msg: CharSequence?, animate: Boolean) {
        if ((msg == textAboutToShow && msg != null) || msg == text) {
        if ((msg == textAboutToShow && msg != null) || msg == text) {
            return
            return
        }
        }

        if (!animate) {
            super.setMessage(msg, animate)
            return
        }

        textAboutToShow = msg
        textAboutToShow = msg


        if (animatorSet.isRunning) {
        if (animatorSet.isRunning) {
@@ -89,7 +95,7 @@ open class BouncerKeyguardMessageArea(context: Context?, attrs: AttributeSet?) :
        hideAnimator.addListener(
        hideAnimator.addListener(
            object : AnimatorListenerAdapter() {
            object : AnimatorListenerAdapter() {
                override fun onAnimationEnd(animation: Animator?) {
                override fun onAnimationEnd(animation: Animator?) {
                    super@BouncerKeyguardMessageArea.setMessage(msg)
                    super@BouncerKeyguardMessageArea.setMessage(msg, animate)
                }
                }
            }
            }
        )
        )
+6 −4
Original line number Original line Diff line number Diff line
@@ -159,10 +159,12 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
                int secondsRemaining = (int) Math.round(millisUntilFinished / 1000.0);
                int secondsRemaining = (int) Math.round(millisUntilFinished / 1000.0);
                Map<String, Object> arguments = new HashMap<>();
                Map<String, Object> arguments = new HashMap<>();
                arguments.put("count", secondsRemaining);
                arguments.put("count", secondsRemaining);
                mMessageAreaController.setMessage(PluralsMessageFormatter.format(
                mMessageAreaController.setMessage(
                        PluralsMessageFormatter.format(
                            mView.getResources(),
                            mView.getResources(),
                            arguments,
                            arguments,
                        R.string.kg_too_many_failed_attempts_countdown));
                            R.string.kg_too_many_failed_attempts_countdown),
                        /* animate= */ false);
            }
            }


            @Override
            @Override
+3 −11
Original line number Original line Diff line number Diff line
@@ -59,6 +59,7 @@ public abstract class KeyguardMessageArea extends TextView implements SecurityMe
    @Nullable
    @Nullable
    private ViewGroup mContainer;
    private ViewGroup mContainer;
    private int mTopMargin;
    private int mTopMargin;
    protected boolean mAnimate;


    public KeyguardMessageArea(Context context, AttributeSet attrs) {
    public KeyguardMessageArea(Context context, AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);
@@ -106,7 +107,7 @@ public abstract class KeyguardMessageArea extends TextView implements SecurityMe
    }
    }


    @Override
    @Override
    public void setMessage(CharSequence msg) {
    public void setMessage(CharSequence msg, boolean animate) {
        if (!TextUtils.isEmpty(msg)) {
        if (!TextUtils.isEmpty(msg)) {
            securityMessageChanged(msg);
            securityMessageChanged(msg);
        } else {
        } else {
@@ -114,22 +115,13 @@ public abstract class KeyguardMessageArea extends TextView implements SecurityMe
        }
        }
    }
    }


    @Override
    public void setMessage(int resId) {
        CharSequence message = null;
        if (resId != 0) {
            message = getContext().getResources().getText(resId);
        }
        setMessage(message);
    }

    @Override
    @Override
    public void formatMessage(int resId, Object... formatArgs) {
    public void formatMessage(int resId, Object... formatArgs) {
        CharSequence message = null;
        CharSequence message = null;
        if (resId != 0) {
        if (resId != 0) {
            message = getContext().getString(resId, formatArgs);
            message = getContext().getString(resId, formatArgs);
        }
        }
        setMessage(message);
        setMessage(message, true);
    }
    }


    private void securityMessageChanged(CharSequence message) {
    private void securityMessageChanged(CharSequence message) {
+10 −2
Original line number Original line Diff line number Diff line
@@ -92,11 +92,19 @@ public class KeyguardMessageAreaController<T extends KeyguardMessageArea>
    }
    }


    public void setMessage(CharSequence s) {
    public void setMessage(CharSequence s) {
        mView.setMessage(s);
        setMessage(s, true);
    }

    /**
     * Sets a message to the underlying text view.
     */
    public void setMessage(CharSequence s, boolean animate) {
        mView.setMessage(s, animate);
    }
    }


    public void setMessage(int resId) {
    public void setMessage(int resId) {
        mView.setMessage(resId);
        String message = resId != 0 ? mView.getResources().getString(resId) : null;
        setMessage(message);
    }
    }


    public void setNextMessageColor(ColorStateList colorState) {
    public void setNextMessageColor(ColorStateList colorState) {
+7 −4
Original line number Original line Diff line number Diff line
@@ -372,10 +372,13 @@ public class KeyguardPatternViewController
                Map<String, Object> arguments = new HashMap<>();
                Map<String, Object> arguments = new HashMap<>();
                arguments.put("count", secondsRemaining);
                arguments.put("count", secondsRemaining);


                mMessageAreaController.setMessage(PluralsMessageFormatter.format(
                mMessageAreaController.setMessage(
                        PluralsMessageFormatter.format(
                            mView.getResources(),
                            mView.getResources(),
                            arguments,
                            arguments,
                        R.string.kg_too_many_failed_attempts_countdown));
                            R.string.kg_too_many_failed_attempts_countdown),
                        /* animate= */ false
                );
            }
            }


            @Override
            @Override
Loading