Fingerprint dialog
This commit is contained in:
parent
c199732fa4
commit
a5dc675627
@ -23,6 +23,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
//implementation 'com.mattprecious.swirl:swirl:1.1.0'
|
||||
implementation 'com.android.support:appcompat-v7:26.1.0'
|
||||
implementation 'com.android.support:design:26.1.0'
|
||||
implementation 'com.android.support:cardview-v7:26.1.0'
|
||||
@ -31,17 +32,16 @@ dependencies {
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||
implementation 'com.android.support:support-v4:26.1.0'
|
||||
implementation 'com.android.support:palette-v7:26.1.0'
|
||||
implementation 'com.android.support:recyclerview-v7:26.1.0'
|
||||
implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
|
||||
implementation 'com.github.armcha:SpaceNavigationView:1.6.0'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.5'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-core:2.8.5'
|
||||
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.5'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.2.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
|
||||
implementation 'com.squareup.retrofit2:converter-jackson:2.2.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
|
||||
implementation 'org.apache.commons:commons-lang3:3.6'
|
||||
implementation 'com.mattprecious.swirl:swirl:1.1.0'
|
||||
//implementation 'com.mattprecious.swirl:swirl:1.1.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.1'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
|
||||
|
@ -2,9 +2,11 @@ package com.nauk.coinfolio.Activities;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
@ -27,9 +29,9 @@ import android.support.v7.app.ActionBar;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nauk.coinfolio.FingerprintHelper.FingerprintHandler;
|
||||
import com.nauk.coinfolio.FingerprintToolkit.FingerprintDialogFragment;
|
||||
import com.nauk.coinfolio.FingerprintToolkit.FingerprintHandler;
|
||||
import com.nauk.coinfolio.R;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -165,44 +167,54 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setupActionBar();
|
||||
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
if(preferences.getBoolean("enable_fingerprint", false))
|
||||
{
|
||||
keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
|
||||
fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
|
||||
|
||||
if(!fingerprintManager.isHardwareDetected())
|
||||
{
|
||||
findViewById(R.id.fingerprint_switch).setVisibility(View.GONE);
|
||||
}
|
||||
DialogFragment newFragment = FingerprintDialogFragment.newInstance(
|
||||
R.layout.fragment_fingerprint_scanner);
|
||||
newFragment.show(getFragmentManager(), "dialog");
|
||||
|
||||
if(ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED)
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
{
|
||||
findViewById(R.id.fingerprint_switch).setVisibility(View.GONE);
|
||||
}
|
||||
keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
|
||||
fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);
|
||||
|
||||
if(!fingerprintManager.hasEnrolledFingerprints())
|
||||
{
|
||||
findViewById(R.id.fingerprint_switch).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(!keyguardManager.isKeyguardSecure())
|
||||
{
|
||||
findViewById(R.id.fingerprint_switch).setVisibility(View.GONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
generateKey();
|
||||
} catch (FingerprintException e) {
|
||||
e.printStackTrace();
|
||||
if(!fingerprintManager.isHardwareDetected())
|
||||
{
|
||||
findViewById(R.id.fingerprint_switch).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(initCipher())
|
||||
if(ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
cryptoObject = new FingerprintManager.CryptoObject(cipher);
|
||||
findViewById(R.id.fingerprint_switch).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
FingerprintHandler helper = new FingerprintHandler(this);
|
||||
helper.startAuth(fingerprintManager, cryptoObject);
|
||||
if(!fingerprintManager.hasEnrolledFingerprints())
|
||||
{
|
||||
findViewById(R.id.fingerprint_switch).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(!keyguardManager.isKeyguardSecure())
|
||||
{
|
||||
findViewById(R.id.fingerprint_switch).setVisibility(View.GONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
generateKey();
|
||||
} catch (FingerprintException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(initCipher())
|
||||
{
|
||||
cryptoObject = new FingerprintManager.CryptoObject(cipher);
|
||||
|
||||
FingerprintHandler helper = new FingerprintHandler(this);
|
||||
helper.startAuth(fingerprintManager, cryptoObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
package com.nauk.coinfolio.FingerprintToolkit;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.nauk.coinfolio.R;
|
||||
|
||||
/**
|
||||
* Created by Guitoune on 28/02/2018.
|
||||
*/
|
||||
|
||||
public class FingerprintDialogFragment extends DialogFragment{
|
||||
|
||||
public static FingerprintDialogFragment newInstance(int title)
|
||||
{
|
||||
FingerprintDialogFragment frag = new FingerprintDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("title", title);
|
||||
frag.setArguments(args);
|
||||
return frag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||
{
|
||||
View view = inflater.inflate(R.layout.fragment_fingerprint_scanner, container);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
package com.nauk.coinfolio.FingerprintHelper;
|
||||
package com.nauk.coinfolio.FingerprintToolkit;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.CancellationSignal;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Created by Guitoune on 28/02/2018.
|
||||
@ -31,4 +31,28 @@ public class FingerprintHandler extends FingerprintManager.AuthenticationCallbac
|
||||
}
|
||||
manager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationError(int errMsgId, CharSequence errString)
|
||||
{
|
||||
Toast.makeText(context, "Authentification error\n" + errString, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationFailed()
|
||||
{
|
||||
Toast.makeText(context, "Authentification failed", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationHelp(int helpMsgIf, CharSequence helpString)
|
||||
{
|
||||
Toast.makeText(context, "Authentification help\n" + helpString, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result)
|
||||
{
|
||||
Toast.makeText(context, "Success !", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
@ -87,21 +87,6 @@
|
||||
|
||||
<include layout="@layout/content_currency_summary" />
|
||||
|
||||
<!--<android.support.design.widget.BottomNavigationView
|
||||
android:id="@+id/navigation_home"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_marginStart="0dp"
|
||||
android:background="?android:attr/windowBackground"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:menu="@menu/navigation_home"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_gravity="bottom"
|
||||
android:visibility="gone"/>-->
|
||||
|
||||
<com.luseen.spacenavigation.SpaceNavigationView
|
||||
android:id="@+id/space"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -13,7 +13,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<com.mattprecious.swirl.SwirlView
|
||||
<!--<com.mattprecious.swirl.SwirlView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp" />
|
||||
android:layout_height="60dp" />-->
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user