Coder Social home page Coder Social logo

amirarcane / lock-screen Goto Github PK

View Code? Open in Web Editor NEW
142.0 16.0 68.0 5.31 MB

Simple and beautiful Lock Screen library to set an check pin code. Integrated with fingerprint authentication.

License: MIT License

Java 100.00%
android fingerprint pincode authentication lockscreen

lock-screen's Introduction

Lock Screen

Simple and beautiful Lock Screen library to set an check pin code. Integrated with fingerprint authentication.

Easily secure your app with Lock Screen library as easy as starting an intent.

With great animations for fingerprint authentication.

Set Pin:

Screenshots

Check Pin:

Screenshots

Lock Screen gets a 4 digit pincode from user at first running time. After that every time that you start the intent, It asks
for pincode.

Watching this repository will allow GitHub to email you whenever I publish a release.


Gradle Dependency

Add this line to your build.gradle project

compile 'com.amirarcane.lock-screen:lockscreen:2.0.0'

Usage

Just add Lock Screen activity to your manifest:

<activity android:name="com.amirarcane.lockscreen.activity.EnterPinActivity"
          android:theme="@style/Theme.AppCompat.NoActionBar"/>

Now easily start the Intent:

 Intent intent = new Intent(getContext(), EnterPinActivity.class);
 startActivity(intent);

That's it. As easy as piece of cake.

At first run It checks if you entered pin before or not, If pin was set, It asks for Entering pin else It asks for setting pincode. If you need to change pin or for any reason you want to set pin again just start the intent like below:

  Intent intent = EnterPinActivity.getIntent(getContext(), SET_PIN);
  startActivity(intent);

SET_PIN is boolean.

If you need to handle back press of Lock Screen activity, just try onActivityResult:

  @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          switch (requestCode) {
              case REQUEST_CODE:
              if (resultCode == EnterPinActivity.RESULT_BACK_PRESSED) {
                  Toast.makeText(MainActivity.this, "back pressed", Toast.LENGTH_LONG).show();
              }
              break;
          }
      }

See MainActivity class in Sample app for understanding how this library works.


Customization

If you need to set font for this library try like below:

  Intent intent = EnterPinActivity.getIntent(getContext(), FONT_TEXT, FONT_NUMBERS);
  startActivity(intent);

FONT_TEXT and FONT_NUMBERS are path of your fonts in assets folder like "font/Arial.ttf"

IF need set pin and changing fonts, do this:

  Intent intent = EnterPinActivity.getIntent(getContext(), SET_PIN, FONT_TEXT, FONT_NUMBERS);
  startActivity(intent);

I customized PinLockView by andrognito for my Lock Screen view. In case of any further customization, fork the library and change it.

lock-screen's People

Contributors

akshaypathak avatar amirarcane 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  avatar  avatar

lock-screen's Issues

Build.gradle error

compile 'com.amirarcane.lock-screen:lockscreen:1.0.0'
unable to add Error:(49, 13) Failed to resolve: com.amirarcane.lock-screen:lockscreen:1.0.0

Exception on unsupported fingerprint samsung device.

Please finish checkForFingerPrint() if device is not supported.

if (!mFingerprintManager.isHardwareDetected()) {
// If a fingerprint sensor isn’t available, then inform the user that they’ll be unable to use your app’s fingerprint functionality//
// textView.setText("Your device doesn't support fingerprint authentication");
mImageViewFingerView.setVisibility(View.GONE);
mTextFingerText.setVisibility(View.GONE);
return; // my suggestion
}

Otherwise, exception will raise when call mFingerprintManager.hasEnrolledFingerprints() on SamSung J2-Prime if KEY_PIN is created.

EnterPinActivity.class can't resolve

i've added compile line to a project i already have and it throws an error so i have to add it as classpath
classpath 'com.amirarcane.lock-screen:lockscreen:2.0.0'

then i've added that line to my manifest and "EnterPinActivity" is red.

not sure what i'm doing wrong, my project has two modules.

pls help!

help get intent

how if true password get page application and show text // no back mainactive
Cheese_Sun-10May20_19 11

Uncaught exception in EnterPinActivity

Hello, for first i would like to say great job for this lib.
We integrate your package directly in our app for make some customization, and we caught a crash report from Crashlytics.
We are not able to reproduce the error with emulator and we don't have fingerprint android, but
in EnterPinActivity line 271 and 282 you are throwing a new exception that is not handled in the calling function line 439.

if (initCipher()) {
                        //If the mCipher is initialized successfully, then create a CryptoObject instance//
                        mCryptoObject = new FingerprintManager.CryptoObject(mCipher);

                        // Here, I’m referencing the FingerprintHandler class that we’ll create in the next section. This class will be responsible
                        // for starting the authentication process (via the startAuth method) and processing the authentication process events//
                        FingerprintHandler helper = new FingerprintHandler(this);
                        helper.startAuth(mFingerprintManager, mCryptoObject);
                        helper.setFingerPrintListener(fingerPrintListener);
                    }

I just add another try with no exception manage.

try {
                    if (initCipher()) {
                        //If the mCipher is initialized successfully, then create a CryptoObject instance//
                        mCryptoObject = new FingerprintManager.CryptoObject(mCipher);

                        // Here, I’m referencing the FingerprintHandler class that we’ll create in the next section. This class will be responsible
                        // for starting the authentication process (via the startAuth method) and processing the authentication process events//
                        FingerprintHandler helper = new FingerprintHandler(this);
                        helper.startAuth(mFingerprintManager, mCryptoObject);
                        helper.setFingerPrintListener(fingerPrintListener);
                    }
                } catch (Exception e){
                    e.printStackTrace();
                }

Gradle Wrapper Folder is missing

For running Gradle commands on the command line, the gradle wrapper folder is needed. It is missing although the gradlew and gradlew.bat files are included.

how to remove the pin

Hi sir. Thanks for the helpful code but how can we remove the pin with this library is that possible?
Thanks a lot again

Fingerprint sensor stays activated after verify pin successfully.

I have one plus 6t phone and it has on screen fingerprint sensor. I am using this library for security purpose. It worked good but there is one issue with the library.
Here are the steps.

  1. I open Enterpinactivity first time. It will ask me to set a pin. I set it to ex.1123
  2. I open it second time it ask me for pin/fingerprint. I choose to enter pin.
  3. It will successfully done. But the fingerprint sensor still shows up to on screen.

Please resolve this issue.

Note - You need to release fingerprint sensor if pin code verify successfully.

fingerprintManager is NULL

Can you add validation ? :
if(fingerprintManager!= null)

in activity EnterPinActivity , line 399, some devices chrash

Wrong Pin Entered Count access is private

private void checkPin(String pin) {
    if (Utils.sha256(pin).equals(getPinFromSharedPreferences())) {
        setResult(RESULT_OK);
        finish();
    } else {
        shake();

  //            mTryCount++;

        mTextAttempts.setText(getString(R.string.pinlock_wrongpin));
        mPinLockView.resetPinLockView();

  //            if (mTryCount == 1) {
  //                mTextAttempts.setText(getString(R.string.pinlock_firsttry));
 //                mPinLockView.resetPinLockView();
  //            } else if (mTryCount == 2) {
 //                mTextAttempts.setText(getString(R.string.pinlock_secondtry));
 //                mPinLockView.resetPinLockView();
 //            } else if (mTryCount > 2) {
 //                setResult(RESULT_TOO_MANY_TRIES);
 //                finish();
  //            }
     }
  }

All lines are commented , i need to use them in my code however these lines and come under private access of method checkPin() , Help ASAP.

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.