Skip to content

Commit

Permalink
💩 Add Biometric activities page?
Browse files Browse the repository at this point in the history
WHY DOESN'T IT WORK 😭😭😭😭
  • Loading branch information
Lamparter committed Jul 16, 2024
1 parent 5244444 commit 999bbfd
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 17 deletions.
19 changes: 14 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
Expand All @@ -19,25 +19,34 @@
android:supportsRtl="true"
android:theme="@style/Theme.SmartTap"
tools:targetApi="31">
<activity
android:name=".Authentication"
android:exported="true"
android:theme="@style/Theme.SmartTap">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<service
android:name=".HCE"
android:exported="true"
android:permission="android.permission.BIND_NFC_SERVICE">
<intent-filter>
<action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />
</intent-filter>

<meta-data
android:name="android.nfc.cardemulation.host_apdu_service"
android:resource="@xml/apduservice" />
</service>

<activity
android:name=".Main"
android:exported="true"
android:theme="@style/Theme.SmartTap">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
25 changes: 25 additions & 0 deletions app/src/main/java/dev/riverside/credit/Authentication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package dev.riverside.credit

import android.os.Bundle
import android.view.LayoutInflater
import com.google.android.material.snackbar.Snackbar
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
import androidx.navigation.ui.setupActionBarWithNavController
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.biometric.BiometricPrompt
import androidx.compose.material3.NavigationBar
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import dev.riverside.credit.databinding.ActivityMainBinding
import dev.riverside.credit.databinding.AuthBiometricBinding
import java.util.concurrent.Executor

class Authentication : AppCompatActivity() {

}
2 changes: 1 addition & 1 deletion app/src/main/java/dev/riverside/credit/Biometrics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ 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() {
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/dev/riverside/credit/ui/theme/Color.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.riverside.credit.ui.theme

import androidx.compose.ui.graphics.Color

val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
58 changes: 58 additions & 0 deletions app/src/main/java/dev/riverside/credit/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package dev.riverside.credit.ui.theme

import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext

private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80
)

private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40

/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
)

@Composable
fun SmartTapTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}

darkTheme -> DarkColorScheme
else -> LightColorScheme
}

MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
)
}
34 changes: 34 additions & 0 deletions app/src/main/java/dev/riverside/credit/ui/theme/Type.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package dev.riverside.credit.ui.theme

import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp

// Set of Material typography styles to start with
val Typography = Typography(
bodyLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 22.sp,
lineHeight = 28.sp,
letterSpacing = 0.sp
),
labelSmall = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Medium,
fontSize = 11.sp,
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)
32 changes: 21 additions & 11 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@
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/authentication">
<fragment
android:id="@+id/FirstFragment"
android:id="@+id/authentication"
android:name="dev.riverside.credit.Authentication"
android:label="Authentication" >
<action
android:id="@+id/action_authentication_to_biometrics"
app:destination="@id/biometrics" />
</fragment>
<fragment
android:id="@+id/biometrics"
android:name="dev.riverside.credit.Biometrics"
android:label="@string/first_fragment_label"
tools:layout="@layout/auth_biometric">

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" />
</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" />
<fragment
android:id="@+id/biometricAuthorisation"
android:name="dev.riverside.credit.Authentication.BiometricAuthorisation"
android:label="BiometricAuthorisation" />
</navigation>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@
</string>
<string name="service_name">Smart Tap</string>
<string name="aid_group_description">Lorem Ipsum</string>
<string name="title_activity_authentication">Authentication</string>
</resources>

0 comments on commit 999bbfd

Please sign in to comment.