public void onCreate(Activity activity, final Receiver receiver, Bundle savedInstanceState) { super.onCreate(activity); this.activity = activity; this.receiver = receiver; messageText.setText(R.string.pl_draw_pattern_to_unlock); patternView.setInStealthMode(isStealthModeEnabled()); patternView.setOnPatternListener(this); leftButton.setText(R.string.pl_cancel); leftButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { receiver.onCancel(); } }); rightButton.setText(R.string.pl_forgot_pattern); rightButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { receiver.onForgotPassword(); } }); ViewAccessibilityCompat.announceForAccessibility(messageText, messageText.getText()); if (savedInstanceState == null) { numFailedAttempts = 0; } else { numFailedAttempts = savedInstanceState.getInt(KEY_NUM_FAILED_ATTEMPTS); } }
@Override public void onPatternDetected(List<PatternView.Cell> pattern) { if (isPatternCorrect(pattern)) { receiver.onConfirmed(); } else { messageText.setText(R.string.pl_wrong_pattern); patternView.setDisplayMode(PatternView.DisplayMode.Wrong); postClearPatternRunnable(); ViewAccessibilityCompat.announceForAccessibility(messageText, messageText.getText()); onWrongPattern(); } }