• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

FingerprintDialog from Android 28 (P) back ported to Android 23 (M).

FingerprintDialogCompat

Build Status API Javadoc

FingerprintDialog from Android 28 (P) back ported to Android 23 (M).

Why do we need this library⁉️

  • Fingerprint is currently the most secure and most user friendly way of authenticating the user in Android.
  • Android provides different APIs to deal with the fingerprint authentication. These APIs changed overtime.
    • Android versions below API 23 did not support fingerprint hardware at all.
    • Android versions between API 23 and API 27, uses FingerprintManager for fingerprint authentication. Developer has to manually authenticate by implementing bunch of APIs.
    • Android version above API 28, uses FingerprintDialog for fingerprint authentication.
  • Due to the Android fragmentation developer has to implement all those APIs based on the android version.πŸ˜” It makes managing fingerprint authentication very hard.
  • This library aims to simplify fingerprint authentication by providing backport of the FingerprintDialog from Android P and provides single public APIs for the authentication all the way to API 14. So as a developer you don't have to deal with the complexity of dealing with different APIs.✌️

Features:

  • Extremely lightweight πŸ‹.
  • Backport of FingerprintDialog from Android P, provides same fingerprint authentication on all Android versions.
  • Easy to integrate. All you have to do is implement the builder and you are done. The library will take care of authentication based on the device's android version.
  • Classifies different error codes provided by the Android framework and wraps them into different error callbacks for easy error handling.

How to use this library?

  • Gradle dependency:

    • Add below dependency into your build.gradle file.
      implementation 'com.kevalpatel2106:fingerprint-dialog-compat:1.0'
    • For other build systems see Import.md.
  • Prepare the builder.

    • Create the FingerprintDialogBuilder and provide the title, subtitle and the description. Application should explain why they need to access user's fingerprint.
    • Dialog

    Java:

    final FingerprintDialogBuilder dialogBuilder = new FingerprintDialogBuilder(Activity.this)
        .setTitle(/* Title of the fingerprint dialog */)
        .setSubtitle(/* Subtitle of the fingerprint dialog */)
        .setDescription(/* Description of the fingerprint dialog */)
        .setNegativeButton(/* Negative button of the fingerprint dialog */);

    Kotlin:

    val dialogBuilder = FingerprintDialogBuilder(this)
        .set  Title(/* Title of the fingerprint dialog */)
        .setSubtitle(/* Subtitle of the fingerprint dialog */)
        .setDescription(/* Description of the fingerprint dialog */)
        .setNegativeButton(/* Negative button of the fingerprint dialog */)
  • Implement callbacks and show the dialog.

    • Implement the AuthenticationCallback to get callbacks for error or success from the fingerprint authentication dialog.

    Java:

    final AuthenticationCallback callback = new AuthenticationCallback() {
            @Override
            public void fingerprintAuthenticationNotSupported() {
                // Device doesn't support fingerprint authentication. May be device doesn't have fingerprint hardware or device is running on Android below Marshmallow.
                // Switch to alternate authentication method.
            }
    
            @Override
            public void hasNoFingerprintEnrolled() {
                // User has no fingerprint enrolled.
                // Application should redirect the user to the lock screen settings.
                // FingerprintUtils.openSecuritySettings(this)
            }
    
            @Override
            public void onAuthenticationError(final int errorCode, @Nullable final CharSequence errString) {
                // Unrecoverable error. Cannot use fingerprint scanner. Library will stop scanning for the fingerprint after this callback.
                // Switch to alternate authentication method.
            }
    
            @Override
            public void onAuthenticationHelp(final int helpCode, @Nullable final CharSequence helpString) {
                // Authentication process has some warning. such as "Sensor dirty, please clean it."
                // Handle it if you want. Library will continue scanning for the fingerprint after this callback.
            }
    
            @Override
            public void authenticationCanceledByUser() {
                // User canceled the authentication by tapping on the cancel button (which is at the bottom of the dialog).
            }
    
            @Override
            public void onAuthenticationSucceeded() {
                // Authentication success
                // Your user is now authenticated.
            }
    
            @Override
            public void onAuthenticationFailed() {
                // Authentication failed.
                // Library will continue scanning the fingerprint after this callback.
            }
        };

    Kotlin:

    val callback = object : AuthenticationCallback {
    
        override fun fingerprintAuthenticationNotSupported() {
            // Device doesn't support fingerprint authentication. May be device doesn't have fingerprint hardware or device is running on Android below Marshmallow.
            // Switch to alternate authentication method.
        }
    
        override fun hasNoFingerprintEnrolled() {
            // User has no fingerprint enrolled.
            // Application should redirect the user to the lock screen settings.
            // FingerprintUtils.openSecuritySettings(this@SecureActivity)
        }
    
        override fun onAuthenticationError(errorCode: Int, errString: CharSequence?) {    
            // Unrecoverable error. Cannot use fingerprint scanner. Library will stop scanning for the fingerprint after this callback.
            // Switch to alternate authentication method.
        }
    
        override fun onAuthenticationHelp(helpCode: Int, helpString: CharSequence?) {
            // Authentication process has some warning. such as "Sensor dirty, please clean it."
            // Handle it if you want. Library will continue scanning for the fingerprint after this callback.
        }
    
        override fun authenticationCanceledByUser() {
            // User canceled the authentication by tapping on the cancel button (which is at the bottom of the dialog).
        }
    
        override fun onAuthenticationSucceeded() {
            // Authentication success
            // Your user is now authenticated.
        }
    
        override fun onAuthenticationFailed() {
            // Authentication failed.
            // Library will continue scanning the fingerprint after this callback.
        }
    }
    • Show the dialog and start fingerprint authentication.

    Java:

    dialogBuilder.show(getSupportFragmentanager(), callback);

    Kotlin:

    dialogBuilder.show(supportFragmentManager, callback)

Screenshots:

Authentication success Authentication fail
success-demo.gif ruler-view-demo.gif

What to try this out?

  • You can download the sample apk from here and play with it.

Want to contribute?

Every small or large contribution to this project is appreciated. Make sure you read the contribution guide before generating the pull request.

Questions?πŸ€”

Hit me on twitter Twitter

License

Copyright 2018 Keval Patel

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

android-hidden-camera

This library is to take picture using camera without camera preview.
Java
396
star
2

android-ruler-picker

Android custom view that uses ruler for picking the number from given range.
Java
381
star
3

EmoticonGIFKeyboard

An advance Emoticons & GIF keyboard.
Java
273
star
4

PasscodeView

PasscodeView is an Android Library to easily and securely authenticate user with PIN code or using the fingerprint scanner.
Java
272
star
5

android-samples

Repository that contains android tutorial projects and sample applications
Java
229
star
6

Prevent-Screen-Off

This is the library that keeps the screen on until user is looking at the screen.
Java
176
star
7

android-ringtone-picker

Simple Ringtone Picker dialog which allows you to pick different sounds from ringtone, alarm tone, notification tone and music from external storage.
Java
74
star
8

green-build

An android app for managing your CI builds.
Kotlin
73
star
9

UserAwareVideoView

A customized video view that will automatically pause video is user is not looking at device screen!!!!!
Java
51
star
10

Open-Weather-API-Wrapper

An Android wrapper for the APIs of https://openweathermap.org
Java
22
star
11

remote-storage-android-things

Create an FTP server using on raspberry pi and build your own wireless storage & backup solution for home.
Java
20
star
12

year-in-progress

Deadline tracker
Kotlin
17
star
13

PastryShop

Take home task for the cookpad interview (Sr. Android Engineer) 2018
Kotlin
15
star
14

smart-lens

Get the information of object based on image recognition using TensorFlow.
Java
12
star
15

unity-lamborghini-car

See Lamborghini in the real world.
C#
12
star
16

unity-snake-game

This is smaple 2D unity snake game.
C#
12
star
17

collision-detector-android-things

Get the distance of the object using Android Things & ultrasonic ranging sensor HC-SR04.
Java
10
star
18

pocket-ci

Check your builds from your pocket
Kotlin
9
star
19

smartswitch

Control your home switches remotely from phone using Android Things.
Java
9
star
20

torrent-downloader-android-things

Java
7
star
21

github-issue-cloud-function

πŸ”₯ Firebase cloud function to post a GitHub issue whenever new crash🐞 reported in firebase crashalytics.
JavaScript
7
star
22

rxbus

Implementation of event bus using Rx for Android.
Java
5
star
23

remote-bluetooth-speaker-android-things

Java
5
star
24

Currency-Converter-App

Currency converter android app
Kotlin
4
star
25

robo-car

Java
4
star
26

crypto-wallet

Demo application for displaying the Bitcoin transaction in Crypto Wallet.
Kotlin
3
star
27

gitlab-ci-android

GitLab CI Docker image to create android builds.
Shell
3
star
28

basic-android

A ready to start from scratch setup for android application project
Java
3
star
29

Github-User-Search

Java
3
star
30

vuforia-barcode-scanner

A barcode scanner for Vuforia based AR applications.
C#
2
star
31

google-home-andorid-things

Protocol Buffer
2
star
32

Stand-Up

Sitting is next cancer.
Kotlin
2
star
33

brew

Kotlin
2
star
34

kevalpatel2106.github.io

Source code for my personal website.
SCSS
2
star
35

rpi-setup

This script will set up your raspberry pi after first boot.
Shell
1
star
36

kevalpatel2106

1
star
37

ar-solar-system

Augmented reality specific model of the solar system using unity in ARCore.
C#
1
star
38

SpinWheelView

Java
1
star
39

home

Java
1
star