-
Notifications
You must be signed in to change notification settings - Fork 28
/
SecureDialog.java
78 lines (66 loc) · 2.32 KB
/
SecureDialog.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package me.aflak.fingerprintdialoglibrary;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import me.aflak.libraries.callback.FingerprintDialogSecureCallback;
import me.aflak.libraries.dialog.FingerprintDialog;
import me.aflak.libraries.utils.FingerprintToken;
import me.aflak.libraries.callback.PasswordCallback;
import me.aflak.libraries.dialog.PasswordDialog;
public class SecureDialog extends AppCompatActivity implements View.OnClickListener, FingerprintDialogSecureCallback, PasswordCallback {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialog);
findViewById(R.id.button).setOnClickListener(this);
}
@Override
public void onClick(View view) {
if(FingerprintDialog.isAvailable(this)) {
FingerprintDialog.initialize(this)
.title(R.string.fingerprint_title)
.message(R.string.fingerprint_message)
.callback(this, "KeyName1")
.show();
}
}
@Override
public void onAuthenticationSucceeded() {
// Logic when fingerprint is recognized
}
@Override
public void onAuthenticationCancel() {
// Logic when user canceled operation
}
@Override
public void onNewFingerprintEnrolled(FingerprintToken token) {
// /!\ A new fingerprint was added /!\
//
// Prompt a password to verify identity, then :
// if (password.correct()) {
// token.continueAuthentication();
// }
//
// OR
//
// Use PasswordDialog to simplify the process
PasswordDialog.initialize(this, token)
.title(R.string.password_title)
.message(R.string.password_message)
.callback(this)
.passwordType(PasswordDialog.PASSWORD_TYPE_TEXT)
.show();
}
@Override
public boolean onPasswordCheck(String password) {
return password.equals("password");
}
@Override
public void onPasswordCancel() {
// Logic when user canceled operation
}
@Override
public void onPasswordSucceeded() {
// Logic when password is correct (new keys have been generated)
}
}