From 999bbfd74e78af617e7642e4fc4107791a09eb98 Mon Sep 17 00:00:00 2001 From: Lamparter Date: Tue, 16 Jul 2024 17:33:51 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A9=20Add=20Biometric=20activities=20p?= =?UTF-8?q?age=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WHY DOESN'T IT WORK 😭😭😭😭 --- app/src/main/AndroidManifest.xml | 19 ++++-- .../dev/riverside/credit/Authentication.kt | 25 ++++++++ .../java/dev/riverside/credit/Biometrics.kt | 2 +- .../dev/riverside/credit/ui/theme/Color.kt | 11 ++++ .../dev/riverside/credit/ui/theme/Theme.kt | 58 +++++++++++++++++++ .../dev/riverside/credit/ui/theme/Type.kt | 34 +++++++++++ app/src/main/res/navigation/nav_graph.xml | 32 ++++++---- app/src/main/res/values/strings.xml | 1 + 8 files changed, 165 insertions(+), 17 deletions(-) create mode 100644 app/src/main/java/dev/riverside/credit/Authentication.kt create mode 100644 app/src/main/java/dev/riverside/credit/ui/theme/Color.kt create mode 100644 app/src/main/java/dev/riverside/credit/ui/theme/Theme.kt create mode 100644 app/src/main/java/dev/riverside/credit/ui/theme/Type.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6a3735d..7c3681e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools"> @@ -19,6 +19,16 @@ android:supportsRtl="true" android:theme="@style/Theme.SmartTap" tools:targetApi="31"> + + + + + + + + + - - - - + \ No newline at end of file diff --git a/app/src/main/java/dev/riverside/credit/Authentication.kt b/app/src/main/java/dev/riverside/credit/Authentication.kt new file mode 100644 index 0000000..df5b2d7 --- /dev/null +++ b/app/src/main/java/dev/riverside/credit/Authentication.kt @@ -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() { + +} diff --git a/app/src/main/java/dev/riverside/credit/Biometrics.kt b/app/src/main/java/dev/riverside/credit/Biometrics.kt index 8f19974..19b1b53 100644 --- a/app/src/main/java/dev/riverside/credit/Biometrics.kt +++ b/app/src/main/java/dev/riverside/credit/Biometrics.kt @@ -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() { diff --git a/app/src/main/java/dev/riverside/credit/ui/theme/Color.kt b/app/src/main/java/dev/riverside/credit/ui/theme/Color.kt new file mode 100644 index 0000000..bf4207d --- /dev/null +++ b/app/src/main/java/dev/riverside/credit/ui/theme/Color.kt @@ -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) \ No newline at end of file diff --git a/app/src/main/java/dev/riverside/credit/ui/theme/Theme.kt b/app/src/main/java/dev/riverside/credit/ui/theme/Theme.kt new file mode 100644 index 0000000..7bf7d89 --- /dev/null +++ b/app/src/main/java/dev/riverside/credit/ui/theme/Theme.kt @@ -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 + ) +} \ No newline at end of file diff --git a/app/src/main/java/dev/riverside/credit/ui/theme/Type.kt b/app/src/main/java/dev/riverside/credit/ui/theme/Type.kt new file mode 100644 index 0000000..0cb6174 --- /dev/null +++ b/app/src/main/java/dev/riverside/credit/ui/theme/Type.kt @@ -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 + ) + */ +) \ No newline at end of file diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 2133f47..243678b 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -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"> + + + - + android:label="auth_biometric" + tools:layout="@layout/auth_biometric" > + android:id="@+id/action_biometrics_to_homepage" + app:destination="@id/homepage" /> + android:label="smart_tap" + tools:layout="@layout/smart_tap" /> + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d31c575..789d0a9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -45,4 +45,5 @@ Smart Tap Lorem Ipsum + Authentication \ No newline at end of file