1- # Goldfinger [ ![ JCenter] ( https://api.bintray.com/packages/infinum/android/goldfinger/images/download.svg )] ( https://bintray.com/infinum/android/goldfinger/_latestVersion ) [ ![ CircleCI Status] ( https://circleci.com/gh/infinum/Android-Goldfinger/tree/master .svg?style=shield&circle-token=141a7164e06f4e97602260e076110778f16a8d02 )] ( https://bintray.com/infinum/android/goldfinger/_latestVersion )
1+ # Goldfinger [ ![ JCenter] ( https://api.bintray.com/packages/infinum/android/goldfinger/images/download.svg )] ( https://bintray.com/infinum/android/goldfinger/_latestVersion ) [ ![ Build Status] ( https://app.bitrise.io/app/bc0cdf2da387a5c3/status .svg?token=eHOSr1ZB1HzNnKZfxYjxbA&branch=master )] ( https://bintray.com/infinum/android/goldfinger/_latestVersion )
22
33<img src =' ./logo.svg ' width =' 264 ' />
44
5+ ## Important
6+
7+ This version is compatible with ` androidx ` . If you are not using ` androidx ` , you can use [ older version of Goldfinger] ( https://github.com/infinum/Android-Goldfinger/tree/v1.1.2 ) .
8+
59## Quick guide
610
711#### Add dependency
812
913``` gradle
10- implementation 'co.infinum:goldfinger:1.1.2 '
14+ implementation 'co.infinum:goldfinger:1.2.0 '
1115```
1216
1317#### Initialize
@@ -28,15 +32,14 @@ if (goldfinger.hasEnrolledFingerprint()) {
2832
2933``` java
3034goldfinger. authenticate(new Goldfinger .Callback () {
31-
3235 @Override
33- public void onSuccess ( String value ) {
34- /* Authenticated */
36+ public void onError ( @NonNull Exception e ) {
37+ /* Critical error happened */
3538 }
3639
3740 @Override
38- public void onError ( Error error ) {
39- /* Error, can be either critical or non-critical */
41+ public void onResult ( @NonNull Goldfinger . Result result ) {
42+ /* Result received */
4043 }
4144});
4245```
@@ -50,8 +53,8 @@ Goldfinger has separate Rx module in case you want to use reactive approach.
5053#### Add dependencies
5154
5255``` gradle
53- implementation 'co.infinum:goldfinger:1.1.2 '
54- implementation 'co.infinum:goldfinger-rx:1.1.2 '
56+ implementation 'co.infinum:goldfinger:1.2.0 '
57+ implementation 'co.infinum:goldfinger-rx:1.2.0 '
5558```
5659
5760#### Initialize
@@ -63,17 +66,21 @@ RxGoldfinger.Builder(context).build()
6366#### Authenticate
6467
6568``` java
66- goldfinger. authenticate(). subscribe(new Observer<GoldfingerEvent > () {
69+ goldfinger. authenticate(). subscribe(new DisposableObserver<Goldfinger . Result >() {
70+
71+ @Override
72+ public void onComplete () {
73+ /* Fingerprint authentication is finished */
74+ }
6775
68- ...
76+ @Override
77+ public void onError (Throwable e ) {
78+ /* Critical error happened */
79+ }
6980
7081 @Override
71- public void onNext (GoldfingerEvent event ) {
72- if (event instanceof GoldfingerEvent . OnSuccess ) {
73- /* Authenticated */
74- } else if (event instanceof GoldfingerEvent . OnError ) {
75- /* Error, can be either critical or non-critical */
76- }
82+ public void onNext (Goldfinger .Result result ) {
83+ /* Result received */
7784 }
7885});
7986```
@@ -106,7 +113,7 @@ If you don’t like Default implementations, you can easily modify them using `G
106113``` java
107114Goldfinger . Builder(context)
108115 .setLogEnabled(true )
109- .setCryptoCreator(cryptoCreator )
116+ .setCryptoFactory(cryptoFactory )
110117 .setCrypto(crypto)
111118 .build()
112119```
@@ -121,18 +128,17 @@ Creating a `CryptoObject` is a complicated process that has multiple steps. `Cry
121128
122129``` java
123130new CryptoFactory () {
131+ @Nullable
132+ @Override
133+ public FingerprintManagerCompat .CryptoObject createAuthenticationCryptoObject (@NonNull String keyName ) {}
124134
125- @Nullable
126- @Override
127- public FingerprintManagerCompat .CryptoObject createAuthenticationCryptoObject (String keyName ) {}
128-
129- @Nullable
130- @Override
131- public FingerprintManagerCompat .CryptoObject createEncryptionCryptoObject (String keyName ) {}
135+ @Nullable
136+ @Override
137+ public FingerprintManagerCompat .CryptoObject createEncryptionCryptoObject (@NonNull String keyName ) {}
132138
133- @Nullable
134- @Override
135- public FingerprintManagerCompat .CryptoObject createDecryptionCryptoObject (String keyName ) {}
139+ @Nullable
140+ @Override
141+ public FingerprintManagerCompat .CryptoObject createDecryptionCryptoObject (@NonNull String keyName ) {}
136142};
137143```
138144
@@ -146,14 +152,13 @@ Goldfinger automatically handles encryption and decryption operations via a `Cry
146152
147153``` java
148154new Crypto () {
155+ @Nullable
156+ @Override
157+ public String encrypt (@NonNull FingerprintManagerCompat .CryptoObject cryptoObject , @NonNull String value ) {}
149158
150- @Nullable
151- @Override
152- public String encrypt (FingerprintManagerCompat .CryptoObject cryptoObject , String value ) {}
153-
154- @Nullable
155- @Override
156- public String decrypt (FingerprintManagerCompat .CryptoObject cryptoObject , String value ) {}
159+ @Nullable
160+ @Override
161+ public String decrypt (@NonNull FingerprintManagerCompat .CryptoObject cryptoObject , @NonNull String value ) {}
157162}
158163```
159164
0 commit comments