Giter VIP home page Giter VIP logo

fingerprint-android's Introduction

finger

Build Status License

This fingerprint library aims to make the use of fingerprint authentication in your application as simple as possible and is best suited for developers who just want to have to deal with 3 things:

  • was the fingerprint successfully accepted
  • was there an error while validating the fingerprint (and which) and provide custom error messages
  • show a system fingerprint dialog / biometric dialog without having to consider the API level or write boilerplate code

First, include finger in your project by adding

// add the finger and also the biometric dependency  
implementation "de.adorsys.android:finger:${latestFingerVersion}"
implementation "androidx.biometric:biometric:1.0.0"

usage

You can use finger as follows:

val finger = Finger(context) // will internally always use application context
finger.subscribe(object : FingerListener {
	override fun onFingerprintAuthenticationSuccess() {
    		// The user authenticated successfully -> go on with your logic
    	}
                  
	override fun onFingerprintAuthenticationFailure(errorMessage: String, errorCode: Int) {
    		// Show the user the human readable error message and use the error code if necessary 
        	// and subscribe again
	}
})
              
finger.showDialog(
            activity = this,
            strings = Finger.DialogStrings(
                title = getString(R.string.text_fingerprint),
                subTitle = "", // defaults to null if nothing is assigned    
                description = "", // defaults to null if nothing is assigned
                cancelButtonText = "login with password" // default parameter is android.R.cancel 
            )
        )

You should subscribe in onResume and unsubscribe in onPause:

override fun onResume() {
	super.onResume()
	finger.subscribe(this)
}

override fun onPause() {
    super.onPause()
    finger.unSubscribe()
}

error handling

finger usually emits the standard system error messages. But you can also assign finger a map of errors for each error type:

val errors = mapOf(
	Pair(BiometricPrompt.ERROR_HW_UNAVAILABLE, getString(R.string.error_override_hw_unavailable)),
	Pair(BiometricPrompt.ERROR_UNABLE_TO_PROCESS, getString(R.string.error_override_unable_to_process)),
	Pair(BiometricPrompt.ERROR_TIMEOUT, getString(R.string.error_override_error_timeout)),
	Pair(BiometricPrompt.ERROR_NO_SPACE, getString(R.string.error_override_no_space)),
	Pair(BiometricPrompt.ERROR_CANCELED, getString(R.string.error_override_canceled)),
	Pair(BiometricPrompt.ERROR_LOCKOUT, getString(R.string.error_override_lockout)),
	Pair(BiometricPrompt.ERROR_VENDOR, getString(R.string.error_override_vendor)),
	Pair(BiometricPrompt.ERROR_LOCKOUT_PERMANENT, getString(R.string.error_override_lockout_permanent)),
	Pair(BiometricPrompt.ERROR_USER_CANCELED, getString(R.string.error_override_user_cancel)),
	Pair(Finger.ERROR_NOT_RECOGNIZED, getString(R.string.error_override_not_recognized)))
val finger = Finger(applicationContext, errors)

Usually, errors is defined as an emptyMap() as default argument.

val finger = Finger(context = this)

or

val finger = Finger(context = this, errors = errors)

The latter uses only the system error messages if no own error message can be found in the map. So you can very well customize when to show which message.

Documentation

This project contains documentation. To generate it run ./gradlew finger:dokka. You will find it at project/documentation.

Proguard

-keep class de.adorsys.android.finger.**

-dontwarn de.adorsys.android.finger.**

Contributors

@luckyhandler

fingerprint-android's People

Contributors

asa06 avatar emjeschke avatar luckyhandler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fingerprint-android's Issues

Handling new FingerPrint enrolled on Phone

Hi, Thanks for this awesome Library.

How do you handle when a user enrolls a new fingerprint via the phone settings

This is required for security reasons to prompt a password in this case

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.