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

Unverified Commit 741dcffe authored by Tommy Webb's avatar Tommy Webb Committed by Michael Bestas
Browse files

fixup! Keyguard: Add option to scramble pin layout when unlocking (2/2).

Fix issue introduced with 13 QPR2 in which the PIN layout is not
randomized every time the PIN entry view appears.

Issue: calyxos#1557
Change-Id: I44247941a02c95cc2ec53fc42ddb1337b61f692e
parent 698c6130
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
    private boolean mScramblePin;

    private List<Integer> mNumbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
    private final List<Integer> mDefaultNumbers = List.of(mNumbers.toArray(new Integer[0]));

    public KeyguardPINView(Context context) {
        this(context, null);
@@ -178,11 +179,19 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
                new View[]{
                        null, mEcaView, null
                }};
        updatePinScrambling();
    }

        mScramblePin = LineageSettings.System.getInt(getContext().getContentResolver(),
    private void updatePinScrambling() {
        final boolean scramblePin = LineageSettings.System.getInt(getContext().getContentResolver(),
                LineageSettings.System.LOCKSCREEN_PIN_SCRAMBLE_LAYOUT, 0) == 1;
        if (mScramblePin) {
        if (scramblePin || scramblePin != mScramblePin) {
            mScramblePin = scramblePin;
            if (scramblePin) {
                Collections.shuffle(mNumbers);
            } else {
                mNumbers = new ArrayList<>(mDefaultNumbers);
            }
            // get all children who are NumPadKeys
            List<NumPadKey> views = new ArrayList<>();

@@ -212,6 +221,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {

    @Override
    public void startAppearAnimation() {
        updatePinScrambling();
        setAlpha(1f);
        setTranslationY(0);
        if (mAppearAnimator.isRunning()) {