FileDocCategorySizeDatePackage
KeyguardPinBasedInputView.javaAPI DocAndroid 5.1 API6582Thu Mar 12 22:22:42 GMT 2015com.android.keyguard

KeyguardPinBasedInputView

public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView implements View.OnKeyListener
A Pin based Keyguard input view

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
Constructors Summary
public KeyguardPinBasedInputView(android.content.Context context)

        this(context, null);
    
public KeyguardPinBasedInputView(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);
    
Methods Summary
protected java.lang.StringgetPasswordText()

        return mPasswordEntry.getText();
    
protected voidonFinishInflate()

        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 booleanonKey(android.view.View v, int keyCode, android.view.KeyEvent event)

        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            onKeyDown(keyCode, event);
            return true;
        }
        return false;
    
public booleanonKeyDown(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 booleanonRequestFocusInDescendants(int direction, android.graphics.Rect previouslyFocusedRect)

        // send focus to the password field
        return mPasswordEntry.requestFocus(direction, previouslyFocusedRect);
    
private voidperformClick(android.view.View view)

        view.performClick();
    
private voidperformNumberClick(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 voidreset()

        mPasswordEntry.requestFocus();
        super.reset();
    
protected voidresetPasswordText(boolean animate)

        mPasswordEntry.reset(animate);
    
protected voidresetState()

        mPasswordEntry.setEnabled(true);
    
protected voidsetPasswordEntryEnabled(boolean enabled)

        mPasswordEntry.setEnabled(enabled);