Skip to content

Commit

Permalink
💄 Add correct navigation graph names
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamparter committed Jul 16, 2024
1 parent a994aac commit fe76096
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 32 deletions.
13 changes: 9 additions & 4 deletions app/src/main/java/dev/riverside/credit/Biometrics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import android.hardware.biometrics.BiometricManager.Authenticators
import androidx.biometric.BiometricManager
import androidx.core.content.ContextCompat
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
import dev.riverside.credit.databinding.AuthBiometricBinding
import java.util.concurrent.Executor
import kotlin.system.exitProcess

class Biometrics : Fragment() {

Expand Down Expand Up @@ -42,22 +45,24 @@ class Biometrics : Fragment() {
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
val navController = view?.findNavController()
navController?.navigate(R.id.action_FirstFragment_to_SecondFragment)
navController?.navigate(R.id.action_biometrics_to_homepage)
}

override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
// TODO: Handle failure
exitProcess(77)
}
}

// Initialize BiometricPrompt instance
val biometricPrompt = BiometricPrompt(this, executor, callback)

val promptInfo = BiometricPrompt.PromptInfo.Builder()
.setTitle("Biometric Authentication")
.setSubtitle("Log in using your biometric credential")
.setNegativeButtonText("Cancel")
.setTitle("Verify that it's you")
.setDescription("For your security, you need to verify that it's you before using Smart Tap")
.setNegativeButtonText(" ")
.setConfirmationRequired(true)
.build()

// Start authentication
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/dev/riverside/credit/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import androidx.navigation.ui.navigateUp
import androidx.navigation.ui.setupActionBarWithNavController
import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.biometric.BiometricPrompt
import androidx.compose.material3.NavigationBar
import androidx.core.content.ContextCompat
import dev.riverside.credit.databinding.ActivityMainBinding
import java.util.concurrent.Executor
import kotlin.system.exitProcess

class Main : AppCompatActivity() {

Expand Down
26 changes: 19 additions & 7 deletions app/src/main/res/layout/auth_biometric.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Biometrics">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Biometrics">

</androidx.core.widget.NestedScrollView>
<ImageView
android:id="@+id/imageView5"
android:layout_width="559dp"
android:layout_height="389dp"
android:layout_marginTop="68dp"
android:src="@mipmap/credit"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:contentDescription="@string/app_name"/>

</androidx.constraintlayout.widget.ConstraintLayout>
14 changes: 3 additions & 11 deletions app/src/main/res/layout/smart_tap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,12 @@

<ImageView
android:id="@+id/imageView5"
android:layout_width="360dp"
android:layout_height="132dp"
android:layout_marginTop="56dp"
android:layout_width="559dp"
android:layout_height="389dp"
android:layout_marginTop="68dp"
android:src="@drawable/credit_foreground"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.025"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
tools:layout_editor_absoluteX="247dp"
tools:layout_editor_absoluteY="125dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
27 changes: 17 additions & 10 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/FirstFragment">

app:startDestination="@id/biometrics">
<activity
android:id="@+id/main"
android:name="dev.riverside.credit.Main"
android:label="activity_main"
tools:layout="@layout/activity_main" />
<fragment
android:id="@+id/FirstFragment"
android:id="@+id/biometrics"
android:name="dev.riverside.credit.Biometrics"
android:label="@string/first_fragment_label"
android:label="auth_biometric"
tools:layout="@layout/auth_biometric">

<action
android:id="@+id/action_FirstFragment_to_SecondFragment"
app:destination="@id/SecondFragment" />
android:id="@+id/action_biometrics_to_homepage"
app:destination="@id/homepage" />
<deepLink
android:id="@+id/deepLink"
android:autoVerify="true"
app:uri="credit://auth" />
</fragment>
<fragment
android:id="@+id/SecondFragment"
android:id="@+id/homepage"
android:name="dev.riverside.credit.Homepage"
android:label="@string/second_fragment_label"
tools:layout="@layout/smart_tap"/>
android:label="smart_tap"
tools:layout="@layout/smart_tap" />
</navigation>

0 comments on commit fe76096

Please sign in to comment.