FingerprintAssistant


Source link: https://github.com/dev-prajwal21/FingerprintAssistant

FingerprintAssistant

FingerprintAssistant is a library built to seamlessly integrate fingerprint api's into any android project. The custom callback structure implemented will provide callbacks for all possible scenarios encountered while integrating fingerprint api's. FingerprintAssistant primarily address the elimination of validations overhead and focus on business logic to make fingerprint auth as easy and as fast as possible.

Usage

Add the following line in project's root level gradle,

maven {
 url 'https://jitpack.io' 
}
 

Add the below line in module level gradle,

compile 'com.github.dev-prajwal21:FingerprintAssistant:1.0' 

Implement the interface FingerprintAuthListener in the activity and implement the method shown below,

@Override public void onAuthentication(int helpOrErrorCode, CharSequence infoString, FingerprintManager.AuthenticationResult authenticationResult, int authCode) {

  switch (authCode) {

case ResponseCode.AUTH_ERROR:

 // Show appropriate message

 break;

case ResponseCode.AUTH_FAILED:

 // Show appropriate message

 break;

case ResponseCode.AUTH_HELP:

 // Show appropriate message

 break;

case ResponseCode.AUTH_SUCCESS:

 // Do whatever you want

 break;
  
}
 
}
 

In the activity, create an object of FingerprintHelper class and pass the context and keystore name as shown below,

FingerprintHelper fingerPrintHelper = new FingerprintHelper(this, "Your-preferred-keystore-name");
 

Call the following method on the fingerPrintHelper object created to receive the response code from FingerprintAssistant,

int responseCode = fingerPrintHelper.checkAndEnableFingerPrintService();
 

Check for the various response code values returned and take appropriate action,

switch (responseCode) {

case ResponseCode.FINGERPRINT_SERVICE_INITIALISATION_SUCCESS:

 showToast("Fingerprint sensor service initialisation success");

 break;

case ResponseCode.OS_NOT_SUPPORTED:

 showToast("OS doesn't support fingerprint api");

 break;

case ResponseCode.FINGER_PRINT_SENSOR_UNAVAILABLE:

 showToast("Fingerprint sensor not found");

 break;

case ResponseCode.ENABLE_FINGER_PRINT_SENSOR_ACCESS:

 showToast("Provide access to use fingerprint sensor");

 break;

case ResponseCode.NO_FINGER_PRINTS_ARE_ENROLLED:

 showToast("No fingerprints found");

 break;

case ResponseCode.FINGERPRINT_SERVICE_INITIALISATION_FAILED:

 showToast("Fingerprint service initialisation failed");

 break;

case ResponseCode.DEVICE_NOT_KEY_GUARD_SECURED:

 showToast("Device is not key guard protected");

 break;
  
}
 

If the response code received is ResponseCode.FINGERPRINT_SERVICE_INITIALISATION_SUCCESS, then start scanning the fingerprint sensor by creating an instance of FingerprintResultsHandler as shown below,

  FingerprintResultsHandler fingerprintResultsHandler = new FingerprintResultsHandler(this);

fingerprintResultsHandler.setFingerprintAuthListener(this);

fingerprintResultsHandler.startListening(fingerPrintHelper.getFingerprintManager(), fingerPrintHelper.getCryptoObject());
 

Touch the fingerprint sensor and get the appropriate results in the onAuthentication callback method.


Additionally to better control the scanning of fingerprint sensor, start and stop the scanning respectively in the following lifecycle methods of the activity,

  @Override protected void onResume() {

  super.onResume();

  // Start fingerprint scanning and listen for fingerprint callbacks
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

if (fingerprintResultsHandler != null && !fingerprintResultsHandler.isAlreadyListening()) {

 fingerprintResultsHandler.startListening(fingerPrintHelper.getFingerprintManager(), fingerPrintHelper.getCryptoObject());

}

  
}
 
}
  @Override protected void onStop() {

  super.onStop();

  // Stop fingerprint scanning and listening for fingerprint callbacks
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

if (fingerprintResultsHandler != null) {

 fingerprintResultsHandler.stopListening();

}

  
}
 
}
 

Note: Please take a look at the sample app for more clarity on implementation.

Happy Coding :)

License

GNU General Public License v3.0

Resources

Swipe right to display drawer with flowing effects.

Customizable Snackbar with material design.

A smooth download button with progress.

RxFlux is small light-weight framework that makes it easy to follow the Flux pattern with RxJava functionalities.

This is a small attempt to attract users when they are using in app feature to send out an email. The usage of this repo serves the purpose like contacting the support desk, inviting another user over email or any other form of email based features.

A small Android library to get the market name of an Android device.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes