Fields Summary |
---|
protected PasswordTextView | mPasswordEntry |
private android.view.View | mOkButton |
private android.view.View | mDeleteButton |
private android.view.View | mButton0 |
private android.view.View | mButton1 |
private android.view.View | mButton2 |
private android.view.View | mButton3 |
private android.view.View | mButton4 |
private android.view.View | mButton5 |
private android.view.View | mButton6 |
private android.view.View | mButton7 |
private android.view.View | mButton8 |
private android.view.View | mButton9 |
Methods Summary |
---|
protected java.lang.String | getPasswordText()
return mPasswordEntry.getText();
|
protected void | onFinishInflate()
mPasswordEntry = (PasswordTextView) findViewById(getPasswordTextViewId());
mPasswordEntry.setOnKeyListener(this);
// Set selected property on so the view can send accessibility events.
mPasswordEntry.setSelected(true);
// Poke the wakelock any time the text is selected or modified
mPasswordEntry.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mCallback.userActivity();
}
});
mOkButton = findViewById(R.id.key_enter);
if (mOkButton != null) {
mOkButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doHapticKeyClick();
if (mPasswordEntry.isEnabled()) {
verifyPasswordAndUnlock();
}
}
});
mOkButton.setOnHoverListener(new LiftToActivateListener(getContext()));
}
mDeleteButton = findViewById(R.id.delete_button);
mDeleteButton.setVisibility(View.VISIBLE);
mDeleteButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// check for time-based lockouts
if (mPasswordEntry.isEnabled()) {
mPasswordEntry.deleteLastChar();
}
doHapticKeyClick();
}
});
mDeleteButton.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View v) {
// check for time-based lockouts
if (mPasswordEntry.isEnabled()) {
resetPasswordText(true /* animate */);
}
doHapticKeyClick();
return true;
}
});
mButton0 = findViewById(R.id.key0);
mButton1 = findViewById(R.id.key1);
mButton2 = findViewById(R.id.key2);
mButton3 = findViewById(R.id.key3);
mButton4 = findViewById(R.id.key4);
mButton5 = findViewById(R.id.key5);
mButton6 = findViewById(R.id.key6);
mButton7 = findViewById(R.id.key7);
mButton8 = findViewById(R.id.key8);
mButton9 = findViewById(R.id.key9);
mPasswordEntry.requestFocus();
super.onFinishInflate();
|
public boolean | onKey(android.view.View v, int keyCode, android.view.KeyEvent event)
if (event.getAction() == KeyEvent.ACTION_DOWN) {
onKeyDown(keyCode, event);
return true;
}
return false;
|
public boolean | onKeyDown(int keyCode, android.view.KeyEvent event)
if (KeyEvent.isConfirmKey(keyCode)) {
performClick(mOkButton);
return true;
} else if (keyCode == KeyEvent.KEYCODE_DEL) {
performClick(mDeleteButton);
return true;
}
if (keyCode >= KeyEvent.KEYCODE_0 && keyCode <= KeyEvent.KEYCODE_9) {
int number = keyCode - KeyEvent.KEYCODE_0 ;
performNumberClick(number);
return true;
}
return super.onKeyDown(keyCode, event);
|
protected boolean | onRequestFocusInDescendants(int direction, android.graphics.Rect previouslyFocusedRect)
// send focus to the password field
return mPasswordEntry.requestFocus(direction, previouslyFocusedRect);
|
private void | performClick(android.view.View view)
view.performClick();
|
private void | performNumberClick(int number)
switch (number) {
case 0:
performClick(mButton0);
break;
case 1:
performClick(mButton1);
break;
case 2:
performClick(mButton2);
break;
case 3:
performClick(mButton3);
break;
case 4:
performClick(mButton4);
break;
case 5:
performClick(mButton5);
break;
case 6:
performClick(mButton6);
break;
case 7:
performClick(mButton7);
break;
case 8:
performClick(mButton8);
break;
case 9:
performClick(mButton9);
break;
}
|
public void | reset()
mPasswordEntry.requestFocus();
super.reset();
|
protected void | resetPasswordText(boolean animate)
mPasswordEntry.reset(animate);
|
protected void | resetState()
mPasswordEntry.setEnabled(true);
|
protected void | setPasswordEntryEnabled(boolean enabled)
mPasswordEntry.setEnabled(enabled);
|