diff --git a/app/build.gradle b/app/build.gradle index 0d7d072..1af58da 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/main/java/com/nauk/coinfolio/Activities/SettingsActivity.java b/app/src/main/java/com/nauk/coinfolio/Activities/SettingsActivity.java index 550e688..5e71f0d 100644 --- a/app/src/main/java/com/nauk/coinfolio/Activities/SettingsActivity.java +++ b/app/src/main/java/com/nauk/coinfolio/Activities/SettingsActivity.java @@ -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); + } } } } diff --git a/app/src/main/java/com/nauk/coinfolio/FingerprintToolkit/FingerprintDialogFragment.java b/app/src/main/java/com/nauk/coinfolio/FingerprintToolkit/FingerprintDialogFragment.java new file mode 100644 index 0000000..1515bf2 --- /dev/null +++ b/app/src/main/java/com/nauk/coinfolio/FingerprintToolkit/FingerprintDialogFragment.java @@ -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; + } +} diff --git a/app/src/main/java/com/nauk/coinfolio/FingerprintHelper/FingerprintHandler.java b/app/src/main/java/com/nauk/coinfolio/FingerprintToolkit/FingerprintHandler.java similarity index 53% rename from app/src/main/java/com/nauk/coinfolio/FingerprintHelper/FingerprintHandler.java rename to app/src/main/java/com/nauk/coinfolio/FingerprintToolkit/FingerprintHandler.java index fecc7b3..bf42a86 100644 --- a/app/src/main/java/com/nauk/coinfolio/FingerprintHelper/FingerprintHandler.java +++ b/app/src/main/java/com/nauk/coinfolio/FingerprintToolkit/FingerprintHandler.java @@ -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(); + } } diff --git a/app/src/main/res/layout/activity_currency_summary.xml b/app/src/main/res/layout/activity_currency_summary.xml index 48961e4..3c4d473 100644 --- a/app/src/main/res/layout/activity_currency_summary.xml +++ b/app/src/main/res/layout/activity_currency_summary.xml @@ -87,21 +87,6 @@ - - - + android:layout_height="60dp" />--> \ No newline at end of file