Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Added Base Fingerprint Dialog for Custom Fingerprint Dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianEstrada committed Apr 18, 2018
1 parent f70e233 commit 3c0534c
Show file tree
Hide file tree
Showing 9 changed files with 495 additions and 339 deletions.
21 changes: 11 additions & 10 deletions app/src/main/java/dk/nodes/locksmith/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import android.util.Log
import dk.nodes.locksmith.core.Locksmith
import dk.nodes.locksmith.core.exceptions.LocksmithEncryptionException
import dk.nodes.locksmith.core.exceptions.LocksmithEncryptionException.Type.*
import dk.nodes.locksmith.core.fingerprint.FingerprintDialog
import dk.nodes.locksmith.core.models.FingerprintDialogEvent
import dk.nodes.locksmith.core.models.OnFingerprintDialogEventListener
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity(), FingerprintDialog.OnFingerprintDialogEventListener {
class MainActivity : AppCompatActivity(), OnFingerprintDialogEventListener {
private val TAG = MainActivity::class.simpleName

private val originalData = "Mary had a little lamb\n" +
Expand Down Expand Up @@ -131,27 +132,27 @@ class MainActivity : AppCompatActivity(), FingerprintDialog.OnFingerprintDialogE
mainTvDecryptedData.text = currentData
}

override fun onFingerprintEvent(event: FingerprintDialog.FingerprintDialogEvent) {
override fun onFingerprintEvent(event: FingerprintDialogEvent) {
when (event) {
FingerprintDialog.FingerprintDialogEvent.CANCEL -> {
FingerprintDialogEvent.CANCEL -> {
Log.w(TAG, "CANCEL")
}
FingerprintDialog.FingerprintDialogEvent.SUCCESS -> {
FingerprintDialogEvent.SUCCESS -> {
Log.w(TAG, "SUCCESS")
}
FingerprintDialog.FingerprintDialogEvent.ERROR -> {
FingerprintDialogEvent.ERROR -> {
Log.w(TAG, "ERROR")
}
FingerprintDialog.FingerprintDialogEvent.ERROR_SECURE -> {
FingerprintDialogEvent.ERROR_SECURE -> {
Log.w(TAG, "ERROR_SECURE")
}
FingerprintDialog.FingerprintDialogEvent.ERROR_HARDWARE -> {
FingerprintDialogEvent.ERROR_HARDWARE -> {
Log.w(TAG, "ERROR_HARDWARE")
}
FingerprintDialog.FingerprintDialogEvent.ERROR_ENROLLMENT -> {
FingerprintDialogEvent.ERROR_ENROLLMENT -> {
Log.w(TAG, "ERROR_ENROLLMENT")
}
FingerprintDialog.FingerprintDialogEvent.ERROR_CIPHER -> {
FingerprintDialogEvent.ERROR_CIPHER -> {
Log.w(TAG, "ERROR_ENROLLMENT")
}
}
Expand Down
115 changes: 115 additions & 0 deletions app/src/main/res/layout/dialog_custom_fingerprint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#FFF"
android:elevation="4dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:minWidth="300dp"
android:padding="24dp">

<TextView
android:id="@+id/dialogFragmentTvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:lineSpacingExtra="8sp"
android:textColor="#de000000"
android:textSize="20sp"
android:textStyle="normal"
tools:text="Fingerprint login" />

<TextView
android:id="@+id/dialogFragmentTvDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:fontFamily="sans-serif"
android:lineSpacingExtra="8sp"
android:textColor="#8a000000"
android:textSize="16sp"
android:textStyle="normal"
tools:text="Use your fingerprint for faster, easier access to your account" />

<TextView
android:id="@+id/dialogFragmentTvSubtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:fontFamily="sans-serif"
android:lineSpacingExtra="8sp"
android:textColor="#8a000000"
android:textSize="16sp"
android:textStyle="normal"
tools:text="Confirm fingerprint to continue" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:clipChildren="false"
android:gravity="center_vertical"
android:orientation="horizontal">

<ImageView
android:id="@+id/dialogFragmentIvFingerprint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/background_circle"
android:backgroundTint="@color/fingerprint_normal"
android:contentDescription="@string/description_fingerprint_icon"
android:elevation="4dp"
android:padding="@dimen/padding_medium"
android:src="@drawable/ic_fingerprint_white_24dp" />

<TextView
android:id="@+id/dialogFragmentTvMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:fontFamily="sans-serif"
android:lineSpacingExtra="10sp"
android:textColor="#8a000000"
android:textSize="14sp"
android:textStyle="normal"
tools:text="Example message goes here" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center_vertical|end"
android:orientation="horizontal">

<Button
android:id="@+id/dialogFragmentBtnUsePassword"
style="?android:attr/buttonBarNegativeButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:letterSpacing="0.02"
android:textColor="#bc1e3d"
android:textSize="14sp"
android:textStyle="normal"
tools:text="Use Password" />

<Button
android:id="@+id/dialogFragmentBtnCancel"
style="?android:attr/buttonBarNegativeButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:letterSpacing="0.02"
android:textColor="#bc1e3d"
android:textSize="14sp"
android:textStyle="normal"
tools:text="Cancel" />

</LinearLayout>

</LinearLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<string name="fingerprintDialogTitle">Login</string>
<string name="fingerprintDialogSubtitle">Login to your Nodes Account</string>
<string name="fingerprintDialogDescription">Touch the finger print sensor to authorize your account</string>

<string name="fingerprintDialogUsePassword">Use Password</string>
<string name="fingerprintDialogErrorMessage">Error Authenticating</string>
<string name="fingerprintDialogSuccessMessage">Successfully Authenticated!</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import dk.nodes.locksmith.core.encryption.EncryptionManager;
import dk.nodes.locksmith.core.exceptions.LocksmithCreationException;
import dk.nodes.locksmith.core.exceptions.LocksmithEncryptionException;
import dk.nodes.locksmith.core.fingerprint.FingerprintDialog;
import dk.nodes.locksmith.core.fingerprint.FingerprintDialogBase;
import dk.nodes.locksmith.core.fingerprint.FingerprintDialogBuilder;

@SuppressLint("StaticFieldLeak")
public class Locksmith {
Expand Down Expand Up @@ -80,8 +81,8 @@ public long decryptLong(String data) throws LocksmithEncryptionException {


@RequiresApi(api = Build.VERSION_CODES.M)
public FingerprintDialog.Builder getFingerprintDialogBuilder(Context context) {
return new FingerprintDialog.Builder(context);
public FingerprintDialogBuilder getFingerprintDialogBuilder(Context context) {
return new FingerprintDialogBuilder(context);
}

// Getters
Expand Down
Loading

0 comments on commit 3c0534c

Please sign in to comment.