├── .editorconfig ├── .github └── FUNDING.yml ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── RELEASING.md ├── app-kotlin ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── kotlin │ └── pwittchen │ │ └── github │ │ └── com │ │ └── rxbiometric │ │ └── MainActivity.kt │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ └── ic_launcher_background.xml │ ├── layout │ ├── activity_main.xml │ └── content_main.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── config ├── quality.gradle └── quality │ ├── checkstyle │ ├── checkstyle.xml │ └── suppressions.xml │ ├── findbugs │ └── findbugs-filter.xml │ ├── lint │ └── lint.xml │ └── pmd │ └── pmd-ruleset.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── detekt.yml ├── gradle.properties ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── kotlin │ │ └── com │ │ │ └── github │ │ │ └── pwittchen │ │ │ └── rxbiometric │ │ │ └── library │ │ │ ├── Authentication.kt │ │ │ ├── RxBiometric.kt │ │ │ ├── RxBiometricBuilder.kt │ │ │ ├── throwable │ │ │ ├── AuthenticationError.kt │ │ │ ├── AuthenticationFail.kt │ │ │ ├── AuthenticationHelp.kt │ │ │ └── BiometricNotSupported.kt │ │ │ └── validation │ │ │ ├── Preconditions.kt │ │ │ └── RxPreconditions.kt │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── kotlin │ └── com │ └── github │ └── pwittchen │ └── rxbiometric │ └── library │ └── AuthenticationTest.kt ├── logo.png ├── maven_push.gradle ├── oxylabs_logo.png ├── settings.gradle └── update_javadocs.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{kt,kts}] 2 | # possible values: number (e.g. 2), "unset" (makes ktlint ignore indentation completely) 3 | indent_size=2 4 | # possible values: number (e.g. 2), "unset" 5 | continuation_indent_size=2 6 | # true (recommended) / false 7 | insert_final_newline=unset 8 | # possible values: number (e.g. 120) (package name, imports & comments are ignored), "off" 9 | # it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide) 10 | max_line_length=off -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [pwittchen] 2 | custom: ['https://paypal.me/pwittchen'] 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | .gradletasknamecache 19 | build/ 20 | 21 | # Local configuration file (sdk path, etc) 22 | local.properties 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | 27 | # Log Files 28 | *.log 29 | 30 | # Android Studio Navigation editor temp files 31 | .navigation/ 32 | 33 | # Android Studio captures folder 34 | captures/ 35 | 36 | # IntelliJ 37 | *.iml 38 | .idea/workspace.xml 39 | .idea/tasks.xml 40 | .idea/gradle.xml 41 | .idea/assetWizardSettings.xml 42 | .idea/dictionaries 43 | .idea/libraries 44 | .idea/caches 45 | .idea/codeStyles/Project.xml 46 | .idea/ 47 | 48 | # Keystore files 49 | # Uncomment the following line if you do not want to check your keystore files in. 50 | #*.jks 51 | 52 | # External native build folder generated in Android Studio 2.2 and later 53 | .externalNativeBuild 54 | 55 | # Google Services (e.g. APIs or Firebase) 56 | google-services.json 57 | 58 | # Freeline 59 | freeline.py 60 | freeline/ 61 | freeline_project_description.json 62 | 63 | # fastlane 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | fastlane/readme.md 69 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | 3 | android: 4 | components: 5 | - tools 6 | - tools 7 | - platform-tools 8 | - build-tools-28 9 | - android-28 10 | - extra-android-support 11 | - extra-android-m2repository 12 | licenses: 13 | - android-sdk-license-5be876d5 14 | - android-sdk-license-c81a61d9 15 | - 'android-sdk-preview-license-.+' 16 | - 'android-sdk-license-.+' 17 | - 'google-gdk-license-.+' 18 | 19 | install: 20 | - true 21 | 22 | before_install: 23 | - yes | sdkmanager "platforms;android-27" 24 | 25 | jdk: oraclejdk8 26 | 27 | script: 28 | - ./gradlew clean build test check 29 | 30 | cache: 31 | directories: 32 | - $HOME/.m2 33 | 34 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | ========= 3 | 4 | v. 0.1.0 5 | -------- 6 | *28 Jan 2019* 7 | 8 | - used `androidx.biometrics` to support devices since Android 6 (Marshmallow) - issue #1, PR #9 9 | - removed `Preconditions#isAtLeastAndroidPie()` method 10 | - removed `Preconditions#canHandleBiometric(context)` method 11 | - removed `RxPreconditions#isAtLeastAndroidPie()` method 12 | - removed `RxPreconditions#canHandleBiometric(context)` method 13 | 14 | v. 0.0.1 15 | -------- 16 | *23rd Aug 2018* 17 | 18 | The first release of the library. 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

logo

2 | 3 | RxBiometric [![Build Status](https://img.shields.io/travis/pwittchen/RxBiometric.svg?branch=master&style=flat-square)](https://travis-ci.org/pwittchen/RxBiometric) ![Maven Central](https://img.shields.io/maven-central/v/com.github.pwittchen/rxbiometric.svg?style=flat-square) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-RxBiometric-brightgreen.svg?style=flat-square)](https://android-arsenal.com/details/1/7245) 4 | =========== 5 | RxJava and RxKotlin bindings for Biometric Prompt (Fingerprint Scanner) on Android (added in Android 9 Pie, API Level 28+) 6 | 7 | *If your app is drawing its own fingerprint auth dialogs, you should switch to using the BiometricPrompt API as soon as possible.* 8 | 9 | It's an official statement from [Google Android Developers Blog](https://android-developers.googleblog.com/2018/08/introducing-android-9-pie.html). RxBiometric helps you to do that via RxJava stream! 10 | 11 | Contents 12 | -------- 13 | 14 | - [Usage](#usage) 15 | - [Examples](#examples) 16 | - [Download](#download) 17 | - [Tests](#tests) 18 | - [Code style](#code-style) 19 | - [Static code analysis](#static-code-analysis) 20 | - [JavaDoc](#javadoc) 21 | - [Changelog](#changelog) 22 | - [Releasing](#releasing) 23 | - [Mentions](#mentions) 24 | - [References](#references) 25 | - [License](#license) 26 | 27 | Usage 28 | ----- 29 | 30 | Simple library usage in **Kotlin** looks as follows: 31 | 32 | ```kotlin 33 | RxBiometric 34 | .title("title") 35 | .description("description") 36 | .negativeButtonText("cancel") 37 | .negativeButtonListener(DialogInterface.OnClickListener { _, _ -> 38 | showMessage("cancel") 39 | }) 40 | .executor(mainExecutor) 41 | .build() 42 | .authenticate(context) 43 | .subscribeOn(Schedulers.io()) 44 | .observeOn(AndroidSchedulers.mainThread()) 45 | .subscribeBy( 46 | onComplete = { showMessage("authenticated!") }, 47 | onError = { showMessage("error") } 48 | ) 49 | ``` 50 | 51 | Library also have validation method in the `Preconditions` class, which you can use to verify if you're able to use Biometric. 52 | 53 | ```kotlin 54 | Preconditions.hasBiometricSupport(context) 55 | ``` 56 | 57 | There's also `RxPreconditions` class, which has the same method wrapped in RxJava `Single` type, 58 | which you can use to create fluent data flow like in the example below 59 | 60 | ```kotlin 61 | RxPreconditions 62 | .hasBiometricSupport(context) 63 | .flatMapCompletable { 64 | if (!it) Completable.error(BiometricNotSupported()) 65 | else 66 | RxBiometric 67 | .title("title") 68 | .description("description") 69 | .negativeButtonText("cancel") 70 | .negativeButtonListener(DialogInterface.OnClickListener { _, _ -> 71 | showMessage("cancel") 72 | }) 73 | .executor(mainExecutor) 74 | .build() 75 | .authenticate(context) 76 | } 77 | .subscribeOn(Schedulers.io()) 78 | .observeOn(AndroidSchedulers.mainThread()) 79 | .subscribeBy( 80 | onComplete = { showMessage("authenticated!") }, 81 | onError = { 82 | when (it) { 83 | is AuthenticationError -> showMessage("error") 84 | is AuthenticationFail -> showMessage("fail") 85 | is AuthenticationHelp -> showMessage("help") 86 | is BiometricNotSupported -> showMessage("biometric not supported") 87 | else -> showMessage("other error") 88 | } 89 | } 90 | ) 91 | ``` 92 | 93 | If you want to create your own CryptoObject and use it during authentication, then you can call `authenticate(context, cryptoObject)` method instead of `authenticate(context)`. 94 | 95 | Of course, **don't forget to dispose** `Disposable` appropriately in the Activity Lifecycle. 96 | 97 | Library can be used in the **Java** projects as well. Idea is the same, just syntax will be a bit different. 98 | 99 | Examples 100 | -------- 101 | 102 | Complete example of the working application can be found in the `kotlin-app` directory. 103 | 104 | Download 105 | -------- 106 | 107 | You can depend on the library through Gradle: 108 | 109 | ```groovy 110 | dependencies { 111 | implementation 'com.github.pwittchen:rxbiometric:0.1.0' 112 | } 113 | ``` 114 | 115 | Tests 116 | ----- 117 | 118 | Tests are available in `library/src/test/kotlin/` directory and can be executed on JVM without any emulator or Android device from Android Studio or CLI with the following command: 119 | 120 | ``` 121 | ./gradlew test 122 | ``` 123 | 124 | Code style 125 | ---------- 126 | 127 | Code style used in the project is called `SquareAndroid` from Java Code Styles repository by Square available at: https://github.com/square/java-code-styles. 128 | 129 | Static code analysis 130 | -------------------- 131 | 132 | Static code analysis runs Checkstyle, PMD, Lint and Detekt. It can be executed with command: 133 | 134 | ``` 135 | ./gradlew check 136 | ``` 137 | 138 | Reports from analysis are generated in `library/build/reports/` directory. 139 | 140 | JavaDoc 141 | ------- 142 | 143 | Documentation can be generated as follows: 144 | 145 | ``` 146 | ./gradlew dokka 147 | ``` 148 | 149 | Output will be generated in `library/build/javadoc` 150 | 151 | JavaDoc can be viewed on-line at https://pwittchen.github.io/RxBiometric/library/ 152 | 153 | Changelog 154 | --------- 155 | 156 | See [CHANGELOG.md](https://github.com/pwittchen/RxBiometric/blob/master/CHANGELOG.md) file. 157 | 158 | Releasing 159 | --------- 160 | 161 | See [RELEASING.md](https://github.com/pwittchen/RxBiometric/blob/master/RELEASING.md) file. 162 | 163 | Mentions 164 | -------- 165 | - [Android Weekly - issue #324](https://androidweekly.net/issues/issue-324) 166 | - [Android Weekly China - issue #194](https://androidweekly.cn/android-dev-weekly-issue-194/) 167 | - [30 summertime libraries which you don't want to miss in 2018](https://medium.com/@mmbialas/30-summertime-android-libraries-and-tools-which-you-dont-want-to-miss-in-2018-fab053d69503) 168 | 169 | References 170 | ---------- 171 | - https://android-developers.googleblog.com/2018/08/introducing-android-9-pie.html 172 | - https://android-developers.googleblog.com/2018/06/better-biometrics-in-android-p.html 173 | - https://developer.android.com/reference/android/hardware/biometrics/BiometricPrompt 174 | - https://github.com/Kieun/android-biometricprompt 175 | - https://android-developers.googleblog.com/2019/10/one-biometric-api-over-all-android.html 176 | 177 | License 178 | ------- 179 | 180 | Copyright 2018 Piotr Wittchen 181 | 182 | Licensed under the Apache License, Version 2.0 (the "License"); 183 | you may not use this file except in compliance with the License. 184 | You may obtain a copy of the License at 185 | 186 | http://www.apache.org/licenses/LICENSE-2.0 187 | 188 | Unless required by applicable law or agreed to in writing, software 189 | distributed under the License is distributed on an "AS IS" BASIS, 190 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 191 | See the License for the specific language governing permissions and 192 | limitations under the License. 193 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | Releasing Guidelines 2 | ==================== 3 | 4 | In order to release new version of the library, we need to perform the following operations: 5 | - create new release issue on GitHub 6 | - prepare release notes and put them to the issue 7 | - checkout to the `master` branch 8 | - bump library version (`VERSION_NAME` and `VERSION_CODE`) in `gradle.properties` file 9 | - commit and push the changes 10 | - run command: `./gradlew uploadArchives` 11 | - go to the https://oss.sonatype.org website 12 | - log in to Sonatype 13 | - go to "Staging Repositories" and sort by last "Updated" date and time 14 | - close and release artifact 15 | - copy `library/build/docs/javadoc` directory 16 | - checkout to `gh-pages` branch 17 | - remove old JavaDoc and paste new, generated JavaDoc there 18 | - commit and push changes 19 | - wait for the Maven Sync (up to 48 hours) 20 | - when sync is done, checkout to the `master` branch 21 | - update `CHANGELOG.md` file with new release version, current date and release notes 22 | - bump library version in "Download" section in `README.md` file 23 | - create new tagged GitHub release with name the same as `VERSION_NAME` from `gradle.properties` and release notes -------------------------------------------------------------------------------- /app-kotlin/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app-kotlin/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion rootProject.ext.compileSdkVersion 7 | 8 | defaultConfig { 9 | applicationId "pwittchen.github.com.rxbiometric" 10 | minSdkVersion rootProject.ext.minSdkVersion 11 | compileSdkVersion rootProject.ext.compileSdkVersion 12 | targetSdkVersion rootProject.ext.targetSdkVersion 13 | versionCode 1 14 | versionName "1.0" 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | 24 | sourceSets { 25 | androidTest.java.srcDirs += "src/androidTest/kotlin" 26 | main.java.srcDirs += "src/main/kotlin" 27 | test.java.srcDirs += "src/test/kotlin" 28 | } 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_8 32 | targetCompatibility JavaVersion.VERSION_1_8 33 | } 34 | } 35 | 36 | dependencies { 37 | implementation project(':library') 38 | implementation deps.kotlinstdlib 39 | implementation deps.appcompat 40 | implementation deps.constraintlayout 41 | implementation deps.material 42 | } 43 | 44 | buildscript { 45 | repositories { 46 | mavenCentral() 47 | jcenter() 48 | google() 49 | maven { 50 | url 'https://plugins.gradle.org/m2/' 51 | } 52 | } 53 | 54 | dependencies { 55 | classpath deps.kotlingradleplugin 56 | classpath deps.kotlinx 57 | } 58 | } -------------------------------------------------------------------------------- /app-kotlin/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app-kotlin/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app-kotlin/src/main/kotlin/pwittchen/github/com/rxbiometric/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Piotr Wittchen 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package pwittchen.github.com.rxbiometric 17 | 18 | import android.content.DialogInterface 19 | import android.os.Build 20 | import android.os.Bundle 21 | import android.widget.Toast 22 | import androidx.annotation.RequiresApi 23 | import androidx.appcompat.app.AppCompatActivity 24 | import androidx.core.app.ActivityCompat 25 | import com.github.pwittchen.rxbiometric.library.RxBiometric 26 | import com.github.pwittchen.rxbiometric.library.throwable.AuthenticationError 27 | import com.github.pwittchen.rxbiometric.library.throwable.AuthenticationFail 28 | import com.github.pwittchen.rxbiometric.library.throwable.BiometricNotSupported 29 | import com.github.pwittchen.rxbiometric.library.validation.RxPreconditions 30 | import io.reactivex.Completable 31 | import io.reactivex.android.schedulers.AndroidSchedulers 32 | import io.reactivex.disposables.Disposable 33 | import io.reactivex.rxkotlin.subscribeBy 34 | import kotlinx.android.synthetic.main.activity_main.toolbar 35 | import kotlinx.android.synthetic.main.content_main.button 36 | 37 | class MainActivity : AppCompatActivity() { 38 | 39 | private var disposable: Disposable? = null 40 | 41 | @RequiresApi(Build.VERSION_CODES.P) 42 | override fun onCreate(savedInstanceState: Bundle?) { 43 | super.onCreate(savedInstanceState) 44 | setContentView(R.layout.activity_main) 45 | setSupportActionBar(toolbar) 46 | 47 | 48 | button.setOnClickListener { 49 | disposable = 50 | RxPreconditions 51 | .hasBiometricSupport(this) 52 | .flatMapCompletable { 53 | if (!it) Completable.error(BiometricNotSupported()) 54 | else 55 | RxBiometric 56 | .title("title") 57 | .description("description") 58 | .negativeButtonText("cancel") 59 | .negativeButtonListener(DialogInterface.OnClickListener { _, _ -> 60 | showMessage("cancel") 61 | }) 62 | .executor(ActivityCompat.getMainExecutor(this@MainActivity)) 63 | .build() 64 | .authenticate(this) 65 | } 66 | .observeOn(AndroidSchedulers.mainThread()) 67 | .subscribeBy( 68 | onComplete = { showMessage("authenticated!") }, 69 | onError = { 70 | when (it) { 71 | is AuthenticationError -> showMessage("error: ${it.errorCode} ${it.errorMessage}") 72 | is AuthenticationFail -> showMessage("fail") 73 | else -> { 74 | showMessage("other error") 75 | } 76 | } 77 | } 78 | ) 79 | } 80 | } 81 | 82 | override fun onPause() { 83 | super.onPause() 84 | disposable?.let { 85 | if (!it.isDisposed) { 86 | it.dispose() 87 | } 88 | } 89 | } 90 | 91 | private fun showMessage(message: String) { 92 | Toast 93 | .makeText( 94 | this@MainActivity, 95 | message, 96 | Toast.LENGTH_SHORT 97 | ) 98 | .show() 99 | } 100 | } -------------------------------------------------------------------------------- /app-kotlin/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app-kotlin/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | 16 | 21 | 26 | 31 | 36 | 41 | 46 | 51 | 56 | 61 | 66 | 71 | 76 | 81 | 86 | 91 | 96 | 101 | 106 | 111 | 116 | 121 | 126 | 131 | 136 | 141 | 146 | 151 | 156 | 161 | 166 | 171 | 172 | -------------------------------------------------------------------------------- /app-kotlin/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app-kotlin/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 |