Merge "Fix PIN/password lock UI update when locked out."

This commit is contained in:
TreeHugger Robot
2017-07-14 18:25:03 +00:00
committed by Android (Google) Code Review

View File

@@ -108,7 +108,6 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
private boolean mUsingFingerprint = false; private boolean mUsingFingerprint = false;
private AppearAnimationUtils mAppearAnimationUtils; private AppearAnimationUtils mAppearAnimationUtils;
private DisappearAnimationUtils mDisappearAnimationUtils; private DisappearAnimationUtils mDisappearAnimationUtils;
private boolean mBlockImm;
// required constructor for fragments // required constructor for fragments
public ConfirmLockPasswordFragment() { public ConfirmLockPasswordFragment() {
@@ -240,8 +239,8 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
mDetailsTextView.setAlpha(0f); mDetailsTextView.setAlpha(0f);
mCancelButton.setAlpha(0f); mCancelButton.setAlpha(0f);
mPasswordEntry.setAlpha(0f); mPasswordEntry.setAlpha(0f);
mErrorTextView.setAlpha(0f);
mFingerprintIcon.setAlpha(0f); mFingerprintIcon.setAlpha(0f);
mBlockImm = true;
} }
private View[] getActiveViews() { private View[] getActiveViews() {
@@ -252,6 +251,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
result.add(mCancelButton); result.add(mCancelButton);
} }
result.add(mPasswordEntry); result.add(mPasswordEntry);
result.add(mErrorTextView);
if (mFingerprintIcon.getVisibility() == View.VISIBLE) { if (mFingerprintIcon.getVisibility() == View.VISIBLE) {
result.add(mFingerprintIcon); result.add(mFingerprintIcon);
} }
@@ -261,13 +261,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
@Override @Override
public void startEnterAnimation() { public void startEnterAnimation() {
super.startEnterAnimation(); super.startEnterAnimation();
mAppearAnimationUtils.startAnimation(getActiveViews(), new Runnable() { mAppearAnimationUtils.startAnimation(getActiveViews(), this::updatePasswordEntry);
@Override
public void run() {
mBlockImm = false;
resetState();
}
});
} }
@Override @Override
@@ -293,7 +287,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
mCredentialCheckResultTracker.clearResult(); mCredentialCheckResultTracker.clearResult();
handleAttemptLockout(deadline); handleAttemptLockout(deadline);
} else { } else {
resetState(); updatePasswordEntry();
mErrorTextView.setText(""); mErrorTextView.setText("");
updateErrorMessage( updateErrorMessage(
mLockPatternUtils.getCurrentFailedPasswordAttempts(mEffectiveUserId)); mLockPatternUtils.getCurrentFailedPasswordAttempts(mEffectiveUserId));
@@ -311,36 +305,24 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
mUsingFingerprint = visible; mUsingFingerprint = visible;
} }
private void resetState() { private void updatePasswordEntry() {
if (mBlockImm) return; final boolean isLockedOut =
mPasswordEntry.setEnabled(true); mLockPatternUtils.getLockoutAttemptDeadline(mEffectiveUserId) != 0;
mPasswordEntryInputDisabler.setInputEnabled(true); mPasswordEntry.setEnabled(!isLockedOut);
if (shouldAutoShowSoftKeyboard()) { mPasswordEntryInputDisabler.setInputEnabled(!isLockedOut);
if (isLockedOut || mUsingFingerprint) {
mImm.hideSoftInputFromWindow(mPasswordEntry.getWindowToken(), 0 /*flags*/);
} else {
mPasswordEntry.scheduleShowSoftInput(); mPasswordEntry.scheduleShowSoftInput();
} }
} }
private boolean shouldAutoShowSoftKeyboard() {
return mPasswordEntry.isEnabled() && !mUsingFingerprint;
}
public void onWindowFocusChanged(boolean hasFocus) { public void onWindowFocusChanged(boolean hasFocus) {
if (!hasFocus || mBlockImm) { if (!hasFocus) {
return; return;
} }
// Post to let window focus logic to finish to allow soft input show/hide properly. // Post to let window focus logic to finish to allow soft input show/hide properly.
mPasswordEntry.post(new Runnable() { mPasswordEntry.post(this::updatePasswordEntry);
@Override
public void run() {
if (shouldAutoShowSoftKeyboard()) {
resetState();
return;
}
mImm.hideSoftInputFromWindow(mPasswordEntry.getWindowToken(),
InputMethodManager.HIDE_IMPLICIT_ONLY);
}
});
} }
private void handleNext() { private void handleNext() {
@@ -395,7 +377,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
} }
} }
mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs, mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
localUserId); localEffectiveUserId);
} }
}; };
mPendingLockCheck = (localEffectiveUserId == localUserId) mPendingLockCheck = (localEffectiveUserId == localUserId)
@@ -490,10 +472,8 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
} }
private void handleAttemptLockout(long elapsedRealtimeDeadline) { private void handleAttemptLockout(long elapsedRealtimeDeadline) {
long elapsedRealtime = SystemClock.elapsedRealtime();
mPasswordEntry.setEnabled(false);
mCountdownTimer = new CountDownTimer( mCountdownTimer = new CountDownTimer(
elapsedRealtimeDeadline - elapsedRealtime, elapsedRealtimeDeadline - SystemClock.elapsedRealtime(),
LockPatternUtils.FAILED_ATTEMPT_COUNTDOWN_INTERVAL_MS) { LockPatternUtils.FAILED_ATTEMPT_COUNTDOWN_INTERVAL_MS) {
@Override @Override
@@ -506,12 +486,13 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
@Override @Override
public void onFinish() { public void onFinish() {
resetState(); updatePasswordEntry();
mErrorTextView.setText(""); mErrorTextView.setText("");
updateErrorMessage( updateErrorMessage(
mLockPatternUtils.getCurrentFailedPasswordAttempts(mEffectiveUserId)); mLockPatternUtils.getCurrentFailedPasswordAttempts(mEffectiveUserId));
} }
}.start(); }.start();
updatePasswordEntry();
} }
public void onClick(View v) { public void onClick(View v) {