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

Commit 2437ceed authored by Aaron Liu's avatar Aaron Liu
Browse files

Remove char state cache.

Removes charpool which caches char state objects to be reused. This
charpool was causing char state objects to duplicate.

Fixes: 265978605
Test: open pin and spam enter to reset pin and spam pin numbers. I
eventually get a duplicate. I also logged the char state array to
confirm that the same char state object is being added in append.

Change-Id: I9724fcf8d29d43069e298bb0407cea90405741b7
parent f71427b2
Loading
Loading
Loading
Loading
+1 −28
Original line number Original line Diff line number Diff line
@@ -47,7 +47,6 @@ import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.R;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Stack;


/**
/**
 * A View similar to a textView which contains password text and can animate when the text is
 * A View similar to a textView which contains password text and can animate when the text is
@@ -92,7 +91,6 @@ public class PasswordTextView extends View {
    private final int mGravity;
    private final int mGravity;
    private ArrayList<CharState> mTextChars = new ArrayList<>();
    private ArrayList<CharState> mTextChars = new ArrayList<>();
    private String mText = "";
    private String mText = "";
    private Stack<CharState> mCharPool = new Stack<>();
    private int mDotSize;
    private int mDotSize;
    private PowerManager mPM;
    private PowerManager mPM;
    private int mCharPadding;
    private int mCharPadding;
@@ -310,13 +308,7 @@ public class PasswordTextView extends View {
    }
    }


    private CharState obtainCharState(char c) {
    private CharState obtainCharState(char c) {
        CharState charState;
        CharState charState = new CharState();
        if(mCharPool.isEmpty()) {
            charState = new CharState();
        } else {
            charState = mCharPool.pop();
            charState.reset();
        }
        charState.whichChar = c;
        charState.whichChar = c;
        return charState;
        return charState;
    }
    }
@@ -343,8 +335,6 @@ public class PasswordTextView extends View {
                maxDelay = Math.min(maxDelay, RESET_MAX_DELAY) + DISAPPEAR_DURATION;
                maxDelay = Math.min(maxDelay, RESET_MAX_DELAY) + DISAPPEAR_DURATION;
                charState.startRemoveAnimation(startDelay, maxDelay);
                charState.startRemoveAnimation(startDelay, maxDelay);
                charState.removeDotSwapCallbacks();
                charState.removeDotSwapCallbacks();
            } else {
                mCharPool.push(charState);
            }
            }
        }
        }
        if (!animated) {
        if (!animated) {
@@ -421,8 +411,6 @@ public class PasswordTextView extends View {
            public void onAnimationEnd(Animator animation) {
            public void onAnimationEnd(Animator animation) {
                if (!mCancelled) {
                if (!mCancelled) {
                    mTextChars.remove(CharState.this);
                    mTextChars.remove(CharState.this);
                    mCharPool.push(CharState.this);
                    reset();
                    cancelAnimator(textTranslateAnimator);
                    cancelAnimator(textTranslateAnimator);
                    textTranslateAnimator = null;
                    textTranslateAnimator = null;
                }
                }
@@ -518,21 +506,6 @@ public class PasswordTextView extends View {
            }
            }
        };
        };


        void reset() {
            whichChar = 0;
            currentTextSizeFactor = 0.0f;
            currentDotSizeFactor = 0.0f;
            currentWidthFactor = 0.0f;
            cancelAnimator(textAnimator);
            textAnimator = null;
            cancelAnimator(dotAnimator);
            dotAnimator = null;
            cancelAnimator(widthAnimator);
            widthAnimator = null;
            currentTextTranslationY = 1.0f;
            removeDotSwapCallbacks();
        }

        void startRemoveAnimation(long startDelay, long widthDelay) {
        void startRemoveAnimation(long startDelay, long widthDelay) {
            boolean dotNeedsAnimation = (currentDotSizeFactor > 0.0f && dotAnimator == null)
            boolean dotNeedsAnimation = (currentDotSizeFactor > 0.0f && dotAnimator == null)
                    || (dotAnimator != null && dotAnimationIsGrowing);
                    || (dotAnimator != null && dotAnimationIsGrowing);