Merge "Do not show soft keyboard when locked out" into mnc-dev

This commit is contained in:
Xiyuan Xia
2015-05-21 16:16:06 +00:00
committed by Android (Google) Code Review
2 changed files with 46 additions and 7 deletions

View File

@@ -1407,7 +1407,7 @@
android:theme="@style/Theme.ConfirmDeviceCredentials"/> android:theme="@style/Theme.ConfirmDeviceCredentials"/>
<activity android:name="ConfirmLockPassword" <activity android:name="ConfirmLockPassword"
android:windowSoftInputMode="stateVisible|adjustResize" android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.ConfirmDeviceCredentials"/> android:theme="@style/Theme.ConfirmDeviceCredentials"/>
<activity android:name=".fingerprint.FingerprintSettings" android:exported="false"/> <activity android:name=".fingerprint.FingerprintSettings" android:exported="false"/>
@@ -1424,7 +1424,7 @@
<!-- Note this must not be exported since it returns the password in the intent --> <!-- Note this must not be exported since it returns the password in the intent -->
<activity android:name="ConfirmLockPassword$InternalActivity" <activity android:name="ConfirmLockPassword$InternalActivity"
android:exported="false" android:exported="false"
android:windowSoftInputMode="stateVisible|adjustResize" android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.ConfirmDeviceCredentials"/> android:theme="@style/Theme.ConfirmDeviceCredentials"/>
<activity android:name="SetupChooseLockGeneric" <activity android:name="SetupChooseLockGeneric"

View File

@@ -16,7 +16,6 @@
package com.android.settings; package com.android.settings;
import android.annotation.Nullable;
import android.os.UserHandle; import android.os.UserHandle;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsLogger;
@@ -24,7 +23,9 @@ import com.android.internal.widget.LockPatternChecker;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.TextViewInputDisabler; import com.android.internal.widget.TextViewInputDisabler;
import android.app.Fragment;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
@@ -35,11 +36,11 @@ import android.os.storage.StorageManager;
import android.text.InputType; import android.text.InputType;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener; import android.widget.TextView.OnEditorActionListener;
@@ -61,6 +62,15 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
return false; return false;
} }
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
Fragment fragment = getFragmentManager().findFragmentById(R.id.main_content);
if (fragment != null && fragment instanceof ConfirmLockPasswordFragment) {
((ConfirmLockPasswordFragment)fragment).onWindowFocusChanged(hasFocus);
}
}
public static class ConfirmLockPasswordFragment extends ConfirmDeviceCredentialBaseFragment public static class ConfirmLockPasswordFragment extends ConfirmDeviceCredentialBaseFragment
implements OnClickListener, OnEditorActionListener { implements OnClickListener, OnEditorActionListener {
private static final String KEY_NUM_WRONG_CONFIRM_ATTEMPTS private static final String KEY_NUM_WRONG_CONFIRM_ATTEMPTS
@@ -77,6 +87,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
private int mNumWrongConfirmAttempts; private int mNumWrongConfirmAttempts;
private CountDownTimer mCountdownTimer; private CountDownTimer mCountdownTimer;
private boolean mIsAlpha; private boolean mIsAlpha;
private InputMethodManager mImm;
// required constructor for fragments // required constructor for fragments
public ConfirmLockPasswordFragment() { public ConfirmLockPasswordFragment() {
@@ -111,6 +122,9 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|| DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC == storedQuality || DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC == storedQuality
|| DevicePolicyManager.PASSWORD_QUALITY_COMPLEX == storedQuality; || DevicePolicyManager.PASSWORD_QUALITY_COMPLEX == storedQuality;
mImm = (InputMethodManager) getActivity().getSystemService(
Context.INPUT_METHOD_SERVICE);
Intent intent = getActivity().getIntent(); Intent intent = getActivity().getIntent();
if (intent != null) { if (intent != null) {
CharSequence headerMessage = intent.getCharSequenceExtra( CharSequence headerMessage = intent.getCharSequenceExtra(
@@ -172,7 +186,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
if (deadline != 0) { if (deadline != 0) {
handleAttemptLockout(deadline); handleAttemptLockout(deadline);
} else { } else {
mPasswordEntryInputDisabler.setInputEnabled(true); resetState();
} }
} }
@@ -189,6 +203,31 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
getActivity().finish(); getActivity().finish();
} }
private void resetState() {
mPasswordEntry.setEnabled(true);
mPasswordEntryInputDisabler.setInputEnabled(true);
mImm.showSoftInput(mPasswordEntry, InputMethodManager.SHOW_IMPLICIT);
}
public void onWindowFocusChanged(boolean hasFocus) {
if (!hasFocus) {
return;
}
// Post to let window focus logic to finish to allow soft input show/hide properly.
mPasswordEntry.post(new Runnable() {
@Override
public void run() {
if (mPasswordEntry.isEnabled()) {
resetState();
return;
}
mImm.hideSoftInputFromWindow(mPasswordEntry.getWindowToken(),
InputMethodManager.HIDE_IMPLICIT_ONLY);
}
});
}
private void handleNext() { private void handleNext() {
mPasswordEntryInputDisabler.setInputEnabled(false); mPasswordEntryInputDisabler.setInputEnabled(false);
if (mPendingLockCheck != null) { if (mPendingLockCheck != null) {
@@ -279,7 +318,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
private void handleAttemptLockout(long elapsedRealtimeDeadline) { private void handleAttemptLockout(long elapsedRealtimeDeadline) {
long elapsedRealtime = SystemClock.elapsedRealtime(); long elapsedRealtime = SystemClock.elapsedRealtime();
mPasswordEntryInputDisabler.setInputEnabled(false); mPasswordEntry.setEnabled(false);
mCountdownTimer = new CountDownTimer( mCountdownTimer = new CountDownTimer(
elapsedRealtimeDeadline - elapsedRealtime, elapsedRealtimeDeadline - elapsedRealtime,
LockPatternUtils.FAILED_ATTEMPT_COUNTDOWN_INTERVAL_MS) { LockPatternUtils.FAILED_ATTEMPT_COUNTDOWN_INTERVAL_MS) {
@@ -294,7 +333,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
@Override @Override
public void onFinish() { public void onFinish() {
mPasswordEntryInputDisabler.setInputEnabled(true); resetState();
mErrorTextView.setText(""); mErrorTextView.setText("");
mNumWrongConfirmAttempts = 0; mNumWrongConfirmAttempts = 0;
} }