With this small library you will be able to include the common used "new password" view in your app very easily. Use it directly on your layout or make it easier using it NewPasswordDialog!
There is also a sample showing how it works
- Passwords check: minimum length and match showing errors if proceed
- Password encryption
- English and spanish translation
- Soft keyboard IME options friendly
- Configurable: minimum lenght and "Check" button visibility
To use it, just include in your layout:
<com.triskelapps.newpasswordview.NewPasswordView
android:id="@+id/view_new_pass"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Take the reference, or create it directly in java:
viewNewPassword = (NewPasswordView) findViewById(R.id.view_new_pass);
or
NewPasswordView viewNewPassword = new NewPasswordView(context);
Then set the callback:
viewNewPassword.setOnPasswordCheckListener(new NewPasswordView.OnPasswordCheckListener() {
@Override
public void onPasswordCorrect(String password) {
}
@Override
public void onPasswordError(String reason) {
}
});
Optionally, some configurations:
viewNewPassword.digestPassword("SHA-1");
viewNewPassword.setMinimumLength(4);
Also you can handle Check action by yourself:
viewNewPassword.setButtonCheckVisible(false);
...
viewNewPassword.performButtonCheckClick();
To simplify even more this functionality, use a Dialog!:
NewPasswordDialog dialog = NewPasswordDialog.newInstance();
dialog.configure(getString(R.string.enter_new_password), new NewPasswordDialog.NewPasswordDialogListener() {
@Override
public void onAccept(String text) {
// User clicked dialog Ok and password is correct, so do what you want with it!
}
});
dialog.show(getSupportFragmentManager(), null);