From 49571c9eef1aa4f0c855d9bc525236a5ccd82439 Mon Sep 17 00:00:00 2001 From: Fung Gwo Date: Thu, 11 Oct 2018 14:29:26 +0800 Subject: [PATCH] Update README --- .gitignore | 3 ++ INTRODUCTION.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 74 +++----------------------------------------- 3 files changed, 89 insertions(+), 70 deletions(-) create mode 100644 INTRODUCTION.md diff --git a/.gitignore b/.gitignore index 09b993d..02d277b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ /build /captures .externalNativeBuild +.settings +.project +.classpath \ No newline at end of file diff --git a/INTRODUCTION.md b/INTRODUCTION.md new file mode 100644 index 0000000..c41caa0 --- /dev/null +++ b/INTRODUCTION.md @@ -0,0 +1,82 @@ +BiometricPromptCompat +==== + +> In Android P, Google provides a easier way for developers to use biometric sensors to authenticate user identity: **BiometricPrompt**. However, it is only supported in latest Android. We create a compat library to take it to All Android 6.0+ devices. + +[My introduction in Chinese (中文介绍)](https://feng.moe/archives/33/) + +## Introduction + +#### What is `BiometricPrompt`? + +It looks like mostly a new `FingerprintManager` which is added in Android 6.0 (M). Its literal meaning may be: not only *fingerprints* will be supported, but also other biometric sensors. + +So if we use this API, it's easy to support other biometric sensors for authenticating, such as face identity. + +To learn more, read [BiometricPrompt Reference](https://developer.android.com/reference/android/hardware/biometrics/BiometricPrompt) in Android Developers site. + +#### How to use it in old devices? + +BiometricPromptCompat is designed to make it compatible in old Android. Its interface is very close to the original `BiometricPrompt` in order that we can keep a consistent UI in different Android. + +Of course, in Android P or newer version, we will use original `BiometricPrompt` API. Then we cannot guarantee the UI is completely consistent in different devices. Because ROM manufacturers will redesign in their own styles. + +And we should realize that **in Android M there is only fingerprint sensor to be supported.** I am sorry that I have no plan to adapt thousands of ROMs' incompatible APIs. + +## Requirements + +- Platform SDK for Android P Preview (`android-p`) +- Android Studio 3.1+ + +## Samples + +[![Download](https://api.bintray.com/packages/fython/BiometricPromptCompat/library/images/download.svg)](https://bintray.com/fython/BiometricPromptCompat/library/_latestVersion) + +Include library in your app module: + +```groovy +dependencies { + implementation 'moe.feng.support.biometricprompt:library:1.0.2' +} +``` + +We recommend to learn `FingerprintManager` or `BiometricPrompt` before using this library. All you need to know will be found. + +```java +final BiometricPromptCompat biometricPrompt = new BiometricPromptCompat.Builder(context) + .setTitle("Title") + .setSubtitle("Subtitle") + .setDescription("Description: blablablablablablablablablablabla...") + .setNegativeButton("Use password", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Toast.makeText( + context, + "You requested password.", + Toast.LENGTH_LONG).show(); + } + }) + .build(); + +biometricPrompt.authenticate(cancellationSignal, myCallback); +``` + +## Test & Screenshots + +Tested successfully in Android 8.1 & P Preview. + +### Android 8.1 + +![](./screenshots/Android-O.png) + +### Android P Preview + +![](./screenshots/Android-P.png) + +## Contact author + +Telegram: [@fython](https://t.me/fython) + +## License + +Apache License 2.0 \ No newline at end of file diff --git a/README.md b/README.md index f0972aa..1a15258 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,11 @@ -BiometricPromptCompat +BiometricPromptCompat (Deprecated) ==== -> In Android P, Google provides a easier way for developers to use biometric sensors to authenticate user identity: **BiometricPrompt**. However, it is only supported in latest Android. We create a compat library to take it to All Android 6.0+ devices. +Since Google's compat library for `BiometricPrompt` was released, I marked this project as deprecated. -[My introduction in Chinese (中文介绍)](https://feng.moe/archives/33/) +You can get `androidx.biometric:biometric` dependency information here: [https://mvnrepository.com/artifact/androidx.biometric/biometric](https://mvnrepository.com/artifact/androidx.biometric/biometric) -## Introduction - -#### What is `BiometricPrompt`? - -It looks like mostly a new `FingerprintManager` which is added in Android 6.0 (M). Its literal meaning may be: not only *fingerprints* will be supported, but also other biometric sensors. - -So if we use this API, it's easy to support other biometric sensors for authenticating, such as face identity. - -To learn more, read [BiometricPrompt Reference](https://developer.android.com/reference/android/hardware/biometrics/BiometricPrompt) in Android Developers site. - -#### How to use it in old devices? - -BiometricPromptCompat is designed to make it compatible in old Android. Its interface is very close to the original `BiometricPrompt` in order that we can keep a consistent UI in different Android. - -Of course, in Android P or newer version, we will use original `BiometricPrompt` API. Then we cannot guarantee the UI is completely consistent in different devices. Because ROM manufacturers will redesign in their own styles. - -And we should realize that **in Android M there is only fingerprint sensor to be supported.** I am sorry that I have no plan to adapt thousands of ROMs' incompatible APIs. - -## Requirements - -- Platform SDK for Android P Preview (`android-p`) -- Android Studio 3.1+ - -## Samples - -[![Download](https://api.bintray.com/packages/fython/BiometricPromptCompat/library/images/download.svg)](https://bintray.com/fython/BiometricPromptCompat/library/_latestVersion) - -Include library in your app module: - -```groovy -dependencies { - implementation 'moe.feng.support.biometricprompt:library:1.0.1' -} -``` - -We recommend to learn `FingerprintManager` or `BiometricPrompt` before using this library. All you need to know will be found. - -```java -final BiometricPromptCompat biometricPrompt = new BiometricPromptCompat.Builder(context) - .setTitle("Title") - .setSubtitle("Subtitle") - .setDescription("Description: blablablablablablablablablablabla...") - .setNegativeButton("Use password", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Toast.makeText( - context, - "You requested password.", - Toast.LENGTH_LONG).show(); - } - }) - .build(); - -biometricPrompt.authenticate(cancellationSignal, myCallback); -``` - -## Test & Screenshots - -Tested successfully in Android 8.1 & P Preview. - -### Android 8.1 - -![](./screenshots/Android-O.png) - -### Android P Preview - -![](./screenshots/Android-P.png) +If you want to continue on this library, you can start from here: [Introduction](./INTRODUCTION.md) ## Contact author