Reprint


Source link: https://github.com/ajalt/reprint

A simple, unified fingerprint authentication library for Android with RxJava extensions.

  • Eliminates the need to deal with the different available Fingerprint APIs, including Imprint and Samsung Pass.
  • Fixes undocumented bugs and idiosyncrasies in the underlying APIs.
  • Supports more Imprint devices than FingerprintManagerCompat from the support library.
  • Comes with help messages translated in over 80 locales that work with all APIs.
  • Provides optional RxJava interfaces.

Usage

See the sample app for a complete example.

In your Application.onCreate, initialize Reprint with Reprint.initialize(this). This will load the Marshmallow module, and the Spass module if you included it.

Then, anywhere in your code, you can call Reprint.authenticate to turn on the fingerprint reader and listen for a fingerprint. You can call Reprint.cancelAuthentication to turn the reader off before it finishes normally.

There are two ways to be notified of authentication results: traditional callback, and a ReactiveX Observable.

RxJava interface

If you include the reactive reprint library, you can be notified of authentication results through an Observable (or Flowable with RxJava 2) by calling RxReprint.authenticate. In this case, the subscriber's onNext will be called after each failure and after success.

RxReprint.authenticate()
  .subscribe(result -> {

switch (result.status) {

 case SUCCESS:

  showSuccess();

  break;

 case NONFATAL_FAILURE:

  showHelp(result.failureReason, result.errorMessage);

  break;

 case FATAL_FAILURE:

  showError(result.failureReason, result.errorMessage);

  break;

}

  
}
);

The failureReason is an enum value with general categories of reason that the authentication failed. This is useful for displaying custom help messages in your UI.

The errorMessage is a string that will contain some help text provided by the underlying SDK about the failure. You should show this text to the user, or some other message of your own based on the failureReason. This string will never be null from a failure, and will be localized into the current locale.

For detail on the other parameters, see the Javadocs.

One advantage that this interface has is that when the subscriber unsubscribes, the authentication request is automatically canceled. So you could, for example, use the RxLifecycle library to bind the observable, and the authentication will be canceled when your activity pauses.

Traditional Callbacks

If you want to use Reprint without RxJava, you can pass an AuthenticationListener to authenticate. The onFailure callback will be called repeatedly until the sensor is disabled or a fingerprint is authenticated correctly, at which point onSuccess will be called.

Reprint.authenticate(new AuthenticationListener() {

  public void onSuccess(int moduleTag) {

showSuccess();

  
}

public void onFailure(AuthenticationFailureReason failureReason, boolean fatal,

CharSequence errorMessage, int moduleTag, int errorCode) {

showError(failureReason, fatal, errorMessage, errorCode);

  
}
 
}
);

Documentation

The javadocs for the Reprint modules are available online:

Installation

Reprint is distributed with jitpack and split up into several libraries, so you can include only the parts that you use.

First, add Jitpack to your gradle repositories.

repositories {

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

Then add the core library and optionally the Samsung Pass interface and the ReactiveX interface. Reprint provides support for both RxJava 1 and 2; you should include the module that matches the version of RxJava that you use in your project.

dependencies {

 compile 'com.github.ajalt.reprint:core:3.2.0@aar' // required: supports marshmallow devices
 compile 'com.github.ajalt.reprint:reprint_spass:3.2.0@aar' // optional: support for pre-marshmallow Samsung devices
 compile 'com.github.ajalt.reprint:rxjava:3.2.0@aar' // optional: the RxJava 1 interface
 compile 'com.github.ajalt.reprint:rxjava2:3.2.0@aar' // optional: the RxJava 2 interface 
}

Permissions

Reprint requires the following permissions be declared in your AndroidManifest.xml. As long as you use the aar artifacts, these permissions will be included automatically.

<!-- Marshmallow fingerprint permission--> <uses-permission android:name="android.permission.USE_FINGERPRINT"/>  <!-- Samsung fingerprint permission, only required if you include the Spass module --> <uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>

License

Copyright 2015-2017 AJ Alt  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. 

Resources

This library is a package of functions that let you manipulate objects and or java date string. It combines the most common functions used when managing dates under android, such as converting a mysql / sqlLite date to a Date object and vis-versa, etc.

Custom view written in Kotlin to Display a translucent frame with corners as known from cameras. You can set the frame's alpha, the frame size, the length of the lines in the corner, their color and the width of them.

Improved AsyncQueryHandler that supports Bulk Insert operation

An Input box with different validators and ripple transition for android. It lets you to define custom animation for error text entrance and also comes up with seven ready validators.

Clean Architecture with Dagger2 + Retrofit2 + Picasso.

This application is an RSS Reader example of Clean Architecture with kotlin.

SugarLoader is a small library that adds sugar to Android Loader API.

Even when you rotate screen, tap home button, or anything, there is no risk to crash it or miss the callback, data will be loaded only once, then rendered to the restored activity/fragment, because there is Android Loader API under the hood.

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