From c3564ab30b001280c669b0b7f4e09011c1179ea8 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Fri, 4 Aug 2023 11:22:33 -0700 Subject: [PATCH] Do not setenabled to false for edittext. calling #setEnabled(false) and #setEnabled(true) for some reason prevents the edit text from registering the backspace key. Also #setFocusable(boolean) also has the same behavior. By setting the cursor visibility, with the text input filter, we see the edit text but cannot add any characters into it and there is no cursor. There is a visual difference here as the old behavior would grey out the textview. Fixes: 288469866 Test: lockout with password security method. Type some stuff, exit bouncer and re-enter and type some stuff. Wait for lockout to finish and type stuff and then try to hit the backspace key. Change-Id: I5fa8e022a765c95e65c0342e68136e648d0e4ac0 --- .../src/com/android/keyguard/KeyguardPasswordView.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java index a9910a128e13d..59ee0d817ef3d 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java @@ -32,6 +32,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.content.Context; +import android.content.res.ColorStateList; import android.graphics.Insets; import android.graphics.Rect; import android.os.Trace; @@ -71,6 +72,8 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView { private Interpolator mLinearOutSlowInInterpolator; private Interpolator mFastOutLinearInInterpolator; private DisappearAnimationListener mDisappearAnimationListener; + private static final int[] DISABLE_STATE_SET = {-android.R.attr.state_enabled}; + private static final int[] ENABLE_STATE_SET = {android.R.attr.state_enabled}; public KeyguardPasswordView(Context context) { this(context, null); @@ -148,7 +151,10 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView { @Override protected void setPasswordEntryEnabled(boolean enabled) { - mPasswordEntry.setEnabled(enabled); + int color = mPasswordEntry.getTextColors().getColorForState( + enabled ? ENABLE_STATE_SET : DISABLE_STATE_SET, 0); + mPasswordEntry.setBackgroundTintList(ColorStateList.valueOf(color)); + mPasswordEntry.setCursorVisible(enabled); } @Override