Methods Summary |
---|
public void | afterTextChanged(android.text.Editable s)
|
public void | beforeTextChanged(java.lang.CharSequence s, int start, int count, int after)
if (mCallback != null) {
mCallback.userActivity();
}
|
protected java.lang.String | getPasswordText()
return mPasswordEntry.getText().toString();
|
protected int | getPasswordTextViewId()
return R.id.passwordEntry;
|
public int | getWrongPasswordStringId()
return R.string.kg_wrong_password;
|
private boolean | hasMultipleEnabledIMEsOrSubtypes(android.view.inputmethod.InputMethodManager imm, boolean shouldIncludeAuxiliarySubtypes)Method adapted from com.android.inputmethod.latin.Utils
final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList();
// Number of the filtered IMEs
int filteredImisCount = 0;
for (InputMethodInfo imi : enabledImis) {
// We can return true immediately after we find two or more filtered IMEs.
if (filteredImisCount > 1) return true;
final List<InputMethodSubtype> subtypes =
imm.getEnabledInputMethodSubtypeList(imi, true);
// IMEs that have no subtypes should be counted.
if (subtypes.isEmpty()) {
++filteredImisCount;
continue;
}
int auxCount = 0;
for (InputMethodSubtype subtype : subtypes) {
if (subtype.isAuxiliary()) {
++auxCount;
}
}
final int nonAuxCount = subtypes.size() - auxCount;
// IMEs that have one or more non-auxiliary subtypes should be counted.
// If shouldIncludeAuxiliarySubtypes is true, IMEs that have two or more auxiliary
// subtypes should be counted as well.
if (nonAuxCount > 0 || (shouldIncludeAuxiliarySubtypes && auxCount > 1)) {
++filteredImisCount;
continue;
}
}
return filteredImisCount > 1
// imm.getEnabledInputMethodSubtypeList(null, false) will return the current IME's enabled
// input method subtype (The current IME should be LatinIME.)
|| imm.getEnabledInputMethodSubtypeList(null, false).size() > 1;
|
public boolean | needsInput()
return true;
|
public boolean | onEditorAction(android.widget.TextView v, int actionId, android.view.KeyEvent event)
// Check if this was the result of hitting the enter key
final boolean isSoftImeEvent = event == null
&& (actionId == EditorInfo.IME_NULL
|| actionId == EditorInfo.IME_ACTION_DONE
|| actionId == EditorInfo.IME_ACTION_NEXT);
final boolean isKeyboardEnterKey = event != null
&& KeyEvent.isConfirmKey(event.getKeyCode())
&& event.getAction() == KeyEvent.ACTION_DOWN;
if (isSoftImeEvent || isKeyboardEnterKey) {
verifyPasswordAndUnlock();
return true;
}
return false;
|
protected void | onFinishInflate()
super.onFinishInflate();
boolean imeOrDeleteButtonVisible = false;
mImm = (InputMethodManager) getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
mPasswordEntry = (TextView) findViewById(getPasswordTextViewId());
mPasswordEntry.setKeyListener(TextKeyListener.getInstance());
mPasswordEntry.setInputType(InputType.TYPE_CLASS_TEXT
| InputType.TYPE_TEXT_VARIATION_PASSWORD);
mPasswordEntry.setOnEditorActionListener(this);
mPasswordEntry.addTextChangedListener(this);
// Poke the wakelock any time the text is selected or modified
mPasswordEntry.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mCallback.userActivity();
}
});
// Set selected property on so the view can send accessibility events.
mPasswordEntry.setSelected(true);
mPasswordEntry.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void afterTextChanged(Editable s) {
if (mCallback != null) {
mCallback.userActivity();
}
}
});
mPasswordEntry.requestFocus();
// If there's more than one IME, enable the IME switcher button
View switchImeButton = findViewById(R.id.switch_ime_button);
if (switchImeButton != null && hasMultipleEnabledIMEsOrSubtypes(mImm, false)) {
switchImeButton.setVisibility(View.VISIBLE);
imeOrDeleteButtonVisible = true;
switchImeButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mCallback.userActivity(); // Leave the screen on a bit longer
mImm.showInputMethodPicker();
}
});
}
// If no icon is visible, reset the start margin on the password field so the text is
// still centered.
if (!imeOrDeleteButtonVisible) {
android.view.ViewGroup.LayoutParams params = mPasswordEntry.getLayoutParams();
if (params instanceof MarginLayoutParams) {
final MarginLayoutParams mlp = (MarginLayoutParams) params;
mlp.setMarginStart(0);
mPasswordEntry.setLayoutParams(params);
}
}
|
public void | onPause()
super.onPause();
mImm.hideSoftInputFromWindow(getWindowToken(), 0);
|
protected boolean | onRequestFocusInDescendants(int direction, android.graphics.Rect previouslyFocusedRect)
// send focus to the password field
return mPasswordEntry.requestFocus(direction, previouslyFocusedRect);
|
public void | onResume(int reason)
super.onResume(reason);
// Wait a bit to focus the field so the focusable flag on the window is already set then.
post(new Runnable() {
@Override
public void run() {
if (isShown()) {
mPasswordEntry.requestFocus();
if (reason != KeyguardSecurityView.SCREEN_ON || mShowImeAtScreenOn) {
mImm.showSoftInput(mPasswordEntry, InputMethodManager.SHOW_IMPLICIT);
}
}
}
});
|
public void | onTextChanged(java.lang.CharSequence s, int start, int before, int count)
|
public void | reset()
super.reset();
mPasswordEntry.requestFocus();
|
protected void | resetPasswordText(boolean animate)
mPasswordEntry.setText("");
|
protected void | resetState()
mSecurityMessageDisplay.setMessage(R.string.kg_password_instructions, false);
mPasswordEntry.setEnabled(true);
|
protected void | setPasswordEntryEnabled(boolean enabled)
mPasswordEntry.setEnabled(enabled);
|
public void | showUsabilityHint()
|
public void | startAppearAnimation()
setAlpha(0f);
setTranslationY(0f);
animate()
.alpha(1)
.withLayer()
.setDuration(300)
.setInterpolator(mLinearOutSlowInInterpolator);
|
public boolean | startDisappearAnimation(java.lang.Runnable finishRunnable)
animate()
.alpha(0f)
.translationY(mDisappearYTranslation)
.setInterpolator(mFastOutLinearInInterpolator)
.setDuration(100)
.withEndAction(finishRunnable);
return true;
|