Giter Club home page Giter Club logo

fingerprintauthhelper's Introduction

FingerprintAuthHelper

A small library that allows You to easily manage fingererprint authentication inside your Activity or Fragment on devices with fingerprint scanner and Android M and higher. Min sdk version 14.

  1. Demo app
  2. Usage
  3. Documentation
  4. ChangeLog
  5. Questions and help
  6. License

alt text alt text

Usage

Add the dependencies to your gradle file:
    dependencies {
        compile 'com.github.pro100svitlo:fingerprintAuthHelper:1.3.0'
    }
Inside your activity or fragment:
    private FingerprintAuthHelper mFAH;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    ...
        mFAH = new FingerprintAuthHelper
                .Builder(this, this) //(Context inscance of Activity, FahListener)
                .build();

        if (mFAH.isHardwareEnable()){
            //do some stuff here
        } else {
            //otherwise do
        }
    }

    ...

   @Override
    protected void onResume() {
        super.onResume();
        mFAH.startListening();
    }

    ...

    @Override
    protected void onStop() {
        super.onStop();
        mFAH.stopListening();
    }

    ...

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mFAH.onDestroy();
    }

    @Override
    public void onFingerprintStatus(boolean authSuccessful, int errorType, CharSequence errorMess) {
        // authSuccessful - boolean that shows auth status
        // errorType - if auth was failed, you can catch error type
        // errorMess - if auth was failed, errorMess will tell you (and user) the reason

        if (authSuccessful){
            // do some stuff here in case auth was successful
        } else if (mFAH != null){
          // do some stuff here in case auth failed
            switch (errorType){
                case FahErrorType.General.LOCK_SCREEN_DISABLED:
                case FahErrorType.General.NO_FINGERPRINTS:
                    mFAH.showSecuritySettingsDialog();
                    break;
                case FahErrorType.Auth.AUTH_NOT_RECOGNIZED:
                    //do some stuff here
                    break;
                case FahErrorType.Auth.AUTH_TO_MANY_TRIES:
                    //do some stuff here
                    break;
            }
        }
    }

    @Override
    public void onFingerprintListening(boolean listening, long milliseconds) {
        // listening - status of fingerprint listen process
        // milliseconds - timeout value, will be > 0, if listening = false & errorType = AUTH_TO_MANY_TRIES

        if (listening){
            //add some code here
        } else {
            //add some code here
        }
        if (milliseconds > 0) {
            //if u need, u can show timeout for user
        }
    }

That's pretty much all what you need to start the work! Full documentation and all options descriptions you can find here.


ChangeLog

  • v.1.3.0 //great thanks Boris Rosenow for helping with this release!
    1. kotlin style refactoring
    2. fix bug with multiple calling tryToStopMe()
    3. some library API updates (add few new and few deprecated methods)
  • v.1.2.2
    1. updated gradle version, Android SDK, .gitignore, kotlin version
    2. fixed known issue with Samsung firmware
  • v.1.2.1
    1. refactoring
  • v.1.2.0
    1. stability improvements
  • v.1.1.7
    1. new function cleanTimeOut() - in case you authinticate with other method. More details in docs.
    2. remove possibility to set max try count (becouse Fingerprint API update :)
    3. now on Kotlin :)
    4. refactoring
  • v.1.1.5
    1. refactoring
    2. small bugfix
  • v.1.1.4
    1. fix crashes on Sumsung devices
    2. add method isFingerprintEnrolled() to FingerprintAuthHelper
    3. small bugfix
  • v.1.1.3
    1. init context must be instance of Activity
    2. add method showSecuritySettingsDialog() to FingerprintAuthHelper
    3. add help error
  • v.1.1.2
    1. add possibility to set max count of tries

Questions and help

If you have some problems with using this library or something doesn't work correctly - just write me an email and describe your question or problem. I will try to do my best to help you and fix the problem if it exists. Here is my email: [email protected]. Or you also can leave an issue here.

License

The MIT License (MIT)

Copyright (c) 2016 FingerprintAuthHelper

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

fingerprintauthhelper's People

Contributors

bombo avatar pro100svitlo avatar ultraon 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  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  avatar  avatar  avatar  avatar

fingerprintauthhelper's Issues

operation cancelled

when I start authonticating the fingerprint and when I put an app in the background the authontication cancel message is given .

How can I force my bluetooth to connect only to the smartlock?

Hi, I am developing an application under Android 6.0. In my application I use bluetooth to connect to a smartlock. I want that when I activate bluetooth my application will only choose the bluetooth of my smartlock. What piece of code will allow me to do that. Thank you.

NullPointerException

Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'void com.pro100svitlo.fingerprintAuthHelper.FahListener.onFingerprintStatus(boolean, int, java.lang.CharSequence)' on a null object reference
at com.pro100svitlo.fingerprintAuthHelper.FahManager.onAuthenticationSucceeded(FahManager.java:226)
at android.hardware.fingerprint.FingerprintManager$MyHandler.sendAuthenticatedSucceeded(FingerprintManager.java:805)
at android.hardware.fingerprint.FingerprintManager$MyHandler.handleMessage(FingerprintManager.java:757)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5551)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)

NPE and crash is possible on c.getSystemService(FingerprintManager::class.java)

in FahManager :

private var fingerprintManager: FingerprintManager = c.getSystemService(FingerprintManager::class.java)

Now c.getSystemService(FingerprintManager::class.java) is annotated as Nullable thus could return null and cause NPE.

SDK sources:

public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass) {
...

Return value must be checked for null.

Crash on Samsung Galaxy Tab A 8.0" 2019

Hi, Library was working find but today i got NPE on Samsung Tab A with os 9.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.somename.some/com.somename.some.view.ui.activities.LoginActivity}: java.lang.IllegalStateException: c.getSystemService(FingerprintManager::class.java) must not be null
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3139)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3282)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1970)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7156)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Caused by: java.lang.IllegalStateException: c.getSystemService(FingerprintManager::class.java) must not be null
at com.pro100svitlo.fingerprintAuthHelper.FahManager.(FahManager.kt:45)
at com.pro100svitlo.fingerprintAuthHelper.FingerprintAuthHelper.(FingerprintAuthHelper.kt:38)
at com.pro100svitlo.fingerprintAuthHelper.FingerprintAuthHelper.(FingerprintAuthHelper.kt:17)
at com.pro100svitlo.fingerprintAuthHelper.FingerprintAuthHelper$Builder.build(FingerprintAuthHelper.kt:278)
at com.somename.some.view.ui.activities.LoginActivity.onCreate(LoginActivity.kt:63)
at android.app.Activity.performCreate(Activity.java:7340)
at android.app.Activity.performCreate(Activity.java:7331)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3282) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1970) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:214) 
at android.app.ActivityThread.main(ActivityThread.java:7156) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975) 

Question, turn off timeout

Hello, could I turn off timeout 45 sec some how after 5 failing scans?
I don't understand how works cleanTimeout(), what is the cases (example), I tried with it but it didn't work.

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.