FingerprintManager


Source link: https://github.com/JesusM/FingerprintManager

KFingerprintManager

A small library to handle Android fingerprint APIs.

This library offers an easy way to handle authorisation and encryption tasks using Android Fingerprint APIs. It's based on Android fingerprint dialog sample made by Google: https://github.com/googlesamples/android-FingerprintDialog.

Use

This library can be used to provide basic authentication through fingerprint API, using manual password as backup option. It also allows you to encrypt messages using fingerprint APIs. This library provides a sample to show how it can be used.

Basic use:

You import via gradle from https://jitpack.io adding this to your root build.gradle file:

 allprojects {

 repositories {

...

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

 
}
  
}

and then adding the library as dependency:

dependencies {

compile 'com.github.JesusM:FingerprintManager:{
latest_version
}
' 
}

(you can see which is the { latest_version } value from releases tab)

Create the fingerprint manager.

fingerPrintManager = KFingerprintManager(context, key);

key is the name for the symmetric key that is created in the Android Key Store. KFingerprintManager.InitialisationCallback contains a set of method that are called whether the fingerprint is ready to be used or when there is any error (like no fingerprint has been enrolled yet, or if there has been a problem initialising it).

Once the library is ready to be used, it provides two features: authentication and encryption.

Authentication

Authentication provides the simplest way to authenticate a user. Once it uses its fingerprint scanner, you'll obtain enough information to allow any operation that requires a user authentication. The library API is pretty simple, just call startAuthentication method passing to it a callback that will let you know the result of the operation. If the authentication went ok, you'll obtain a CryptoObject object that will let you use for authentication operations (see encryption to see what you can do with that data)

Logic to authenticate using fingerprint:

  fingerPrintManager.authenticate(object : KFingerprintManager.AuthenticationCallback {

 override fun onAuthenticationFailedWithHelp(help: String?) {

  // Logic when decryption failed with a message

 
}

  override fun onAuthenticationSuccess() {

  // Logic when authentication has been successful

 
}

  override fun onSuccessWithManualPassword(password: String) {

  // Logic when authentication has been successful writting password manually

 
}

  override fun onFingerprintNotRecognized() {

  // Logic when fingerprint was not recognized

 
}

  override fun onFingerprintNotAvailable() {

  // Logic when fingerprint is not available

 
}

  override fun onCancelled() {

  // Logic when operation is cancelled by user

 
}

}
, getSupportFragmentManager());

Encryption/Decryption

Encryption/decryption operations will be only done using fingerprint APIs, so if fingerprint is not present or suitable, it will fail.

Logic to encrypt an String message using the library:

  fingerPrintManager.encrypt(messageToBeEncrypted, object : KFingerprintManager.EncryptionCallback {

 override fun onFingerprintNotRecognized() {

  // Logic when fingerprint was not recognized

 
}

  override fun onAuthenticationFailedWithHelp(help: String?) {

  // Logic when decryption failed with a message

 
}

  override fun onFingerprintNotAvailable() {

  // Logic when fingerprint is not available

 
}

  override fun onEncryptionSuccess(messageEncrypted: String) {

  // Logic to handle the encrypted message

 
}

  override fun onEncryptionFailed() {

  // Logic to handle decryption failure

 
}

  override fun onCancelled() {

  // Logic when operation is cancelled by user

 
}

 
}
, getSupportFragmentManager());

Logic to decrypt an already encrypted message:

  fingerPrintManager.decrypt(messageToDecrypt, object : KFingerprintManager.DecryptionCallback {

 override fun onDecryptionSuccess(messageDecrypted: String) {

  // Logic that handles successful decryption result

 
}

  override fun onDecryptionFailed() {

  // Logic to handle decryption failure

 
}

  override fun onFingerprintNotRecognized() {

  // Logic when fingerprint was not recognized

 
}

  override fun onAuthenticationFailedWithHelp(help: String?) {

  // Logic when decryption failed with a message

 
}

  override fun onFingerprintNotAvailable() {

  // Logic when fingerprint is not available

 
}

  override fun onCancelled() {

  // Logic when operation is cancelled by user

 
}

 
}
, getSupportFragmentManager());

Customisation:

The library allows you to customise how the visual component is displayed. In order to do that, you can follow these steps:

1.- Declare a xml them like this:

  <style name ="DialogThemeLight" parent="Theme.AppCompat.Light.Dialog.MinWidth">

 <item name="colorAccent">@color/dialog_light_theme_accent</item>

 <item name="android:colorAccent">@color/dialog_light_theme_accent</item>

 <item name="android:background">@color/dialog_light_theme_background</item>

 <item name="android:textColorPrimary">@color/dialog_light_theme_text_color_primary</item>

 <item name="android:textColorSecondary">@color/dialog_light_theme_text_color_secondary</item>
</style>

2.- Once you have the theme, the library provides a method to set it:

fingerPrintManager.setAuthenticationStyle(theme);

In the screenshots section you can see some samples of the customisations.

Screenshots:

Authentication using fingerprint and manual password using a light theme.



Same screens but this time using a dark theme.

Resources

License

MIT License

Copyright 2016 The Android Open Source Project, Inc.

Copyright (c) 2017 Jesús

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.

Resources

Proteus is meant to be a drop-in replacement for Android’s LayoutInflater; but unlike the compiled XML layouts bundled in the APK, Proteus inflates layouts at runtime.

With Proteus, you can control your Apps layout from the backend (no WebViews). Forget the boilerplate code to findViewById, cast it to a TextView, and then setText(). Proteus has runtime data bindings and formatters. Plugin in your own custom views and attributes and formatters.

SmartDeviceLink (SDL) is a standard set of protocols and messages that connect applications on a smartphone to a vehicle head unit. This messaging enables a consumer to interact with their application using common in-vehicle interfaces such as a touch screen display, embedded voice recognition, steering wheel controls and various vehicle knobs and buttons. There are three main components that make up the SDL ecosystem.

Simple custom ImageView for android giving you a simple way to enable overlapping of two images one over the other.

OkHttp-Stats is an android library built on top of OkHttp3, which is responsible for intercepting all the network calls and for calculating network stats such as the average network speed of the user.

This is more of an analytical tool which can be used to track the success and error response logs.

Can be plugged in to any app which uses okhttp in their networking stack.

Example app to use Protobuf in Android using Square's Wire library.

Espresso's consistency makes it really easy to learn.

Want to match a view with a specific id? Use withId(R.id.some_id). Need to match with a piece of text? Use withText(R.id.some_text) or withText("some text). Awesome, consistent and it's very clear what it is you are doing.

However...

After a few hours writing test code you'll find your code being a little bit too verbose. Not anymore.

Why should you need to explicitly specify that you are matching with some text if you are passing in some text as a parameter? Some for the view id, you can already see that it is a view id.

Ristretto allows you to write the same test code as you already write, but less verbose.

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