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
This commit is contained in:
Aaron Liu
2023-08-04 11:22:33 -07:00
parent 0f0a5bd651
commit c3564ab30b

View File

@@ -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