Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit 5096df9

Browse files
Version 1.2.0 (#47)
* Improve Goldfinger API, rewrite tests, bump deps * Update README.md * Remove CircleCI and migrate to Bitrise * Bump version * Improve example activity * Improve javadoc * Bump bintray gradle plugin * Update README to mention androidx support * Check hardware and enrolled fingerprint preconditions
1 parent f7db550 commit 5096df9

39 files changed

+841
-661
lines changed

.circleci/config.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

README.md

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
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
3034
goldfinger.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
107114
Goldfinger.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
123130
new 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
148154
new 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

build.gradle

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
11
buildscript {
22

33
ext.sdk = [
4-
min : 16,
5-
target: 27,
4+
min : 14,
5+
target: 28,
66
]
77

88
ext.versions = [
9-
goldfinger: '1.1.2',
10-
google : '27.1.1',
9+
appcompat: '1.0.2',
10+
goldfinger: '1.2.0',
1111
junit : '4.12',
1212
mockito : '2.10.0',
1313
rxjava : '2.1.13'
1414
]
1515

16-
ext.deps = [
17-
appcompat: "com.android.support:appcompat-v7:${versions.google}",
18-
junit : "junit:junit:${versions.junit}",
19-
mockito : "org.mockito:mockito-core:${versions.mockito}",
20-
rxjava : "io.reactivex.rxjava2:rxjava:${versions.rxjava}"
21-
]
22-
2316
repositories {
2417
google()
2518
jcenter()
2619
}
2720

2821
dependencies {
29-
classpath 'com.android.tools.build:gradle:3.1.2'
30-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
22+
classpath 'com.android.tools.build:gradle:3.4.1'
23+
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
3124
}
3225
}
3326

core/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ android {
1515
}
1616

1717
dependencies {
18-
implementation deps.appcompat
19-
testImplementation deps.junit
20-
testImplementation deps.mockito
18+
implementation "androidx.appcompat:appcompat:${versions.appcompat}"
19+
testImplementation "junit:junit:${versions.junit}"
20+
testImplementation "org.mockito:mockito-core:${versions.mockito}"
2121
}
2222

2323
apply from: '../tasks.gradle'

core/src/main/java/co/infinum/goldfinger/AsyncCryptoFactory.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
package co.infinum.goldfinger;
22

3-
import android.support.annotation.Nullable;
4-
import android.support.v4.hardware.fingerprint.FingerprintManagerCompat;
5-
63
import java.util.concurrent.ExecutorService;
74
import java.util.concurrent.Executors;
85
import java.util.concurrent.Future;
96

7+
import androidx.annotation.NonNull;
8+
import androidx.annotation.Nullable;
9+
import androidx.core.hardware.fingerprint.FingerprintManagerCompat;
10+
1011
class AsyncCryptoFactory {
1112

1213
private final CryptoFactory cryptoFactory;
1314
private final ExecutorService executor;
1415
private Future task;
1516

16-
AsyncCryptoFactory(CryptoFactory cryptoFactory) {
17+
AsyncCryptoFactory(@NonNull CryptoFactory cryptoFactory) {
1718
this.cryptoFactory = cryptoFactory;
1819
this.executor = Executors.newSingleThreadExecutor();
1920
}
2021

21-
void createCryptoObject(String keyName, Mode mode, AsyncCryptoFactory.Callback callback) {
22+
void createCryptoObject(@NonNull String keyName, @NonNull Mode mode, @NonNull AsyncCryptoFactory.Callback callback) {
2223
if (task != null && !task.isDone()) {
2324
task.cancel(true);
2425
}

0 commit comments

Comments
 (0)