PinLock


Source link: https://github.com/manupsunny/PinLock

PinLock

An Android library which can be used for implementing PIN lock mechanism in Android applications.

Usage

First, add PinLock dependency to your build.gradle. PinLock is available in both Maven and jCenter.

compile "com.manusunny:pinlock:+" 
1. Setting PIN

Create a new class by extending SetPinActivity.java. And implement method onPinSet(),

public class SetPinActivitySample extends SetPinActivity {

  public void onPinSet(String pin){

//Save 'pin' as SharedPreference
  
}
 
}

That's it. Now you can start this activity using startActivityForResult(). And handle the results in onActivityResult(). Activity will return one of these result codes:

  1. PinListener.SUCCESS
  2. PinListener.CANCELLED
2. Confirming PIN

Create a new class by extending ConfirmPinActivity.java. And implement two methods,

public class ConfirmPinActivitySample extends SetPinActivity {

  @Override
  public boolean isPinCorrect(String pin) {

String currentPin = // get it from SharedPreferences

return pin.equals(currentPin);

  
}

@Override
  public void onForgotPin() {

// handle forgot PIN scenario
  
}
 
}

Now you can start this activity using startActivityForResult(). And handle the results in onActivityResult(). Activity will return one of these result codes:

  1. PinListener.SUCCESS
  2. PinListener.CANCELLED
  3. PinListener.FORGOT

Customizing the Plugin

1. Customizing Styles

All styles in this library are configurable. Give required styles in res/values/styles.xml

Example:

<resources>
  <style name="PinLock" >

<item name="pinLength">4</item>

<item name="backgroundColor">#FFFFFF</item>

 <item name="keypadButtonShape">@drawable/rectangle</item>

<item name="keypadTextColor">#000000</item>

<item name="keypadTextSize">20</item>

<item name="keypadWidth">200dp</item>

<item name="keypadHeight">230dp</item>

<item name="keypadVerticalSpacing">2dp</item>

<item name="keypadHorizontalSpacing">2dp</item>

<item name="keypadClickAnimationDuration">100</item>

 <item name="cancelForgotTextColor">#000000</item>

<item name="cancelForgotTextSize">14</item>

 <item name="infoTextColor">#000000</item>

<item name="infoTextSize">20</item>

 <item name="vibrateOnClick">true</item>

<item name="vibrateDuration">20</item>

 <item name="statusEmptyBackground">@drawable/dot_empty</item>

<item name="statusFilledBackground">@drawable/dot_filled</item>

<item name="statusDotDiameter">8dp</item>

<item name="statusDotSpacing">10dp</item>
  </style> </resources>
2. Customizing Labels

You can customize the messages and labels used in the library. Give new texts in res/values/strings.xml

Example:

<resources>
  <string name="message_enter_pin">Enter PIN</string>
  <string name="message_enter_new_pin">Enter new PIN</string>
  <string name="message_confirm_pin">Re enter PIN</string>
  <string name="message_invalid_pin">Invalid PIN. Try again</string>
  <string name="message_pin_mismatch">PIN mismatch. Try again</string>

<string name="button_cancel">Cancel</string>
  <string name="button_forgot_pin">Forgot PIN</string> </resources>

Supporting Multiple Languages

You can support multiple languages by providing texts in different languages. If texts are not available for the selected language, English will be used as the fallback language. Add res/values-<language_code> folder for each new language, and provide tranlated contents in strings.xml file.

Folder Structure :

|res
  |values

 // Default language (en)

|strings.xml
  |values-es
 // Spanish

|strings.xml
  |values-de
 // German

|strings.xml 

Example:

Sample file for Spanish res/values-es/strings.xml

<resources>
  <string name="message_enter_pin">Ingrese el PIN</string>
  <string name="message_enter_new_pin">Ingrese un nuevo PIN</string>
  <string name="message_confirm_pin">Confirme el PIN</string>
  <string name="message_invalid_pin">PIN inválido. Intente de nuevo</string>
  <string name="message_pin_mismatch">El PIN no coincide. Intente de nuevo</string>

<string name="button_cancel">Cancelar</string>
  <string name="button_forgot_pin">Olvidé mi PIN</string> </resources>

A list of languages which are currently supported by Android along with their codes are available here.

License

Copyright 2016 © Manu Sunny  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. 

Sample Screenshots

SetPin ConfirmPin ChangePin

Resources

Asks the user if (s)he wants to open the Play Store to rate your application when certain requirements are met. This can and should be configured to be very cautious. Don't annoy your users!

Infer is a static analysis tool for Java, Objective-C and C, written in OCaml.

You have a small team. Setting up crash reporting tools, event tracking tools, and log management services is not what you want to spend your hours doing. You know these are important to the health of your application, but you just want to code.

That's where Foam comes into play.

This app is a simple Bluetooth connection debugging tool:

  • Connect to a Bluetooth device
  • Display incoming raw data
  • Send raw data to the Bluetooth device

Android library project that intends to simplify the usage of Adapters for ListView/GridView and RecyclerView. You won't have to code any boring adapter again!

Quote it is a social platform for sharing quotes and wise sayings. It is great to share and spread the wisdom and thought full.

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