diff --git a/app/src/main/java/com/anthonyla/paperize/presentation/MainActivity.kt b/app/src/main/java/com/anthonyla/paperize/presentation/MainActivity.kt index b194c37..1e8d355 100644 --- a/app/src/main/java/com/anthonyla/paperize/presentation/MainActivity.kt +++ b/app/src/main/java/com/anthonyla/paperize/presentation/MainActivity.kt @@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.runtime.* +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -39,12 +40,20 @@ class MainActivity : ComponentActivity() { // Track if DataStore has loaded at least once // This prevents the loading screen from showing again if the composable is recomposed - val appSettings by settingsViewModel.appSettings.collectAsStateWithLifecycle() + val appSettingsState by settingsViewModel.appSettings.collectAsStateWithLifecycle() + + // Remember if we've ever loaded settings to prevent losing NavigationGraph during recreation + var settingsLoadedOnce by rememberSaveable { mutableStateOf(false) } + val currentSettings = appSettingsState + + if (currentSettings != null) { + settingsLoadedOnce = true + } PaperizeTheme( - darkMode = appSettings?.darkMode ?: false, - dynamicTheming = appSettings?.dynamicTheming ?: false + darkMode = currentSettings?.darkMode ?: false, + dynamicTheming = currentSettings?.dynamicTheming ?: false ) { Surface( modifier = Modifier.fillMaxSize(), @@ -52,11 +61,10 @@ class MainActivity : ComponentActivity() { ) { // Only render navigation once DataStore has loaded // After first load, always show navigation even during updates - val currentSettings = appSettings - if (currentSettings != null) { + if (settingsLoadedOnce) { NavigationGraph( - startDestination = if (currentSettings.firstLaunch) StartupRoute else HomeRoute, - animate = currentSettings.animate, + startDestination = if (currentSettings?.firstLaunch != false) StartupRoute else HomeRoute, + animate = currentSettings?.animate ?: true, onFirstLaunchComplete = { settingsViewModel.updateFirstLaunch(false) } diff --git a/app/src/main/java/com/anthonyla/paperize/presentation/common/navigation/NavigationGraph.kt b/app/src/main/java/com/anthonyla/paperize/presentation/common/navigation/NavigationGraph.kt index 63eee32..4a02b59 100644 --- a/app/src/main/java/com/anthonyla/paperize/presentation/common/navigation/NavigationGraph.kt +++ b/app/src/main/java/com/anthonyla/paperize/presentation/common/navigation/NavigationGraph.kt @@ -67,6 +67,9 @@ fun NavigationGraph( navController.navigate(WallpaperModeSelectionRoute) { popUpTo { inclusive = true } } + }, + onPrivacyClick = { + navController.navigate(PrivacyRoute) } ) } diff --git a/app/src/main/java/com/anthonyla/paperize/presentation/components/OnboardingLayout.kt b/app/src/main/java/com/anthonyla/paperize/presentation/components/OnboardingLayout.kt index a22f54a..a8d6052 100644 --- a/app/src/main/java/com/anthonyla/paperize/presentation/components/OnboardingLayout.kt +++ b/app/src/main/java/com/anthonyla/paperize/presentation/components/OnboardingLayout.kt @@ -5,13 +5,16 @@ import androidx.compose.animation.core.tween import androidx.compose.animation.fadeIn import androidx.compose.animation.slideInVertically import androidx.compose.foundation.background +import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.rememberScrollState @@ -50,87 +53,101 @@ fun OnboardingLayout( visible = true } - Column( - modifier = modifier - .fillMaxSize() - .padding(AppSpacing.extraLarge) - ) { + BoxWithConstraints(modifier = modifier.fillMaxSize()) { + val maxHeight = maxHeight + Column( modifier = Modifier - .weight(1f) - .verticalScroll(rememberScrollState()), + .fillMaxSize() + .verticalScroll(rememberScrollState()) + .padding(AppSpacing.extraLarge), horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center - ) { - AnimatedVisibility( - visible = visible, - enter = fadeIn(animationSpec = tween(500)) + - slideInVertically( - animationSpec = tween(500), - initialOffsetY = { 50 } - ) - ) { - Box( - modifier = Modifier - .size(120.dp) // Larger container for the icon background - .background( - color = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.5f), - shape = CircleShape - ), - contentAlignment = Alignment.Center - ) { - iconContent() - } - } - - Spacer(modifier = Modifier.height(AppSpacing.extraLarge)) - - AnimatedVisibility( - visible = visible, - enter = fadeIn(animationSpec = tween(500, delayMillis = 100)) + - slideInVertically( - animationSpec = tween(500, delayMillis = 100), - initialOffsetY = { 50 } - ) - ) { - Text( - text = title, - style = MaterialTheme.typography.headlineLarge, - color = MaterialTheme.colorScheme.onSurface, - fontWeight = FontWeight.Bold, - textAlign = TextAlign.Center - ) - } - - Spacer(modifier = Modifier.height(AppSpacing.large)) - - AnimatedVisibility( - visible = visible, - enter = fadeIn(animationSpec = tween(500, delayMillis = 200)) + - slideInVertically( - animationSpec = tween(500, delayMillis = 200), - initialOffsetY = { 50 } - ) - ) { - content() - } - } - - Spacer(modifier = Modifier.height(AppSpacing.medium)) - - // Actions pinned to bottom - AnimatedVisibility( - visible = visible, - enter = fadeIn(animationSpec = tween(500, delayMillis = 300)) + - slideInVertically( - animationSpec = tween(500, delayMillis = 300), - initialOffsetY = { 100 } - ) + verticalArrangement = Arrangement.Top // Top here, centering happens in inner Column ) { Column( - verticalArrangement = Arrangement.spacedBy(AppSpacing.medium) + modifier = Modifier + .fillMaxWidth() + .heightIn(min = maxHeight - (AppSpacing.extraLarge * 2)), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center ) { - actions() + Column( + modifier = Modifier.fillMaxWidth(), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center + ) { + AnimatedVisibility( + visible = visible, + enter = fadeIn(animationSpec = tween(500)) + + slideInVertically( + animationSpec = tween(500), + initialOffsetY = { 50 } + ) + ) { + Box( + modifier = Modifier + .size(120.dp) // Larger container for the icon background + .background( + color = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.5f), + shape = CircleShape + ), + contentAlignment = Alignment.Center + ) { + iconContent() + } + } + + Spacer(modifier = Modifier.height(AppSpacing.extraLarge)) + + AnimatedVisibility( + visible = visible, + enter = fadeIn(animationSpec = tween(500, delayMillis = 100)) + + slideInVertically( + animationSpec = tween(500, delayMillis = 100), + initialOffsetY = { 50 } + ) + ) { + Text( + text = title, + style = MaterialTheme.typography.headlineLarge, + color = MaterialTheme.colorScheme.onSurface, + fontWeight = FontWeight.Bold, + textAlign = TextAlign.Center + ) + } + + Spacer(modifier = Modifier.height(AppSpacing.large)) + + AnimatedVisibility( + visible = visible, + enter = fadeIn(animationSpec = tween(500, delayMillis = 200)) + + slideInVertically( + animationSpec = tween(500, delayMillis = 200), + initialOffsetY = { 50 } + ) + ) { + content() + } + } + + Spacer(modifier = Modifier.height(AppSpacing.extraLarge)) + + // Actions now part of the scrollable content to handle small heights (landscape) + AnimatedVisibility( + visible = visible, + enter = fadeIn(animationSpec = tween(500, delayMillis = 300)) + + slideInVertically( + animationSpec = tween(500, delayMillis = 300), + initialOffsetY = { 100 } + ) + ) { + Column( + modifier = Modifier.fillMaxWidth(), + verticalArrangement = Arrangement.spacedBy(AppSpacing.medium) + ) { + actions() + } + } } } } diff --git a/app/src/main/java/com/anthonyla/paperize/presentation/screens/privacy/PrivacyScreen.kt b/app/src/main/java/com/anthonyla/paperize/presentation/screens/privacy/PrivacyScreen.kt index c3da9ee..f662d1e 100644 --- a/app/src/main/java/com/anthonyla/paperize/presentation/screens/privacy/PrivacyScreen.kt +++ b/app/src/main/java/com/anthonyla/paperize/presentation/screens/privacy/PrivacyScreen.kt @@ -25,7 +25,7 @@ fun PrivacyScreen( Scaffold( topBar = { TopAppBar( - title = { Text(stringResource(R.string.privacy_screen)) }, + title = { Text(stringResource(R.string.privacy_policy)) }, navigationIcon = { IconButton(onClick = onNavigateBack) { Icon( diff --git a/app/src/main/java/com/anthonyla/paperize/presentation/screens/startup/StartupScreen.kt b/app/src/main/java/com/anthonyla/paperize/presentation/screens/startup/StartupScreen.kt index 3cd9c3f..8a34941 100644 --- a/app/src/main/java/com/anthonyla/paperize/presentation/screens/startup/StartupScreen.kt +++ b/app/src/main/java/com/anthonyla/paperize/presentation/screens/startup/StartupScreen.kt @@ -6,16 +6,21 @@ import androidx.appcompat.content.res.AppCompatResources import com.anthonyla.paperize.presentation.components.OnboardingLayout import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.Image +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material3.Button import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -38,6 +43,7 @@ import com.anthonyla.paperize.presentation.theme.AppSpacing @Composable fun StartupScreen( onAgree: () -> Unit, + onPrivacyClick: () -> Unit, modifier: Modifier = Modifier ) { val context = LocalContext.current @@ -78,7 +84,9 @@ fun StartupScreen( // Cleaner privacy notice Card( - modifier = Modifier.fillMaxWidth(), + modifier = Modifier + .fillMaxWidth() + .clickable { onPrivacyClick() }, shape = MaterialTheme.shapes.large, colors = CardDefaults.cardColors( containerColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.5f) @@ -88,24 +96,36 @@ fun StartupScreen( color = MaterialTheme.colorScheme.outlineVariant ) ) { - Column( - modifier = Modifier.padding(AppSpacing.large) + Row( + modifier = Modifier + .fillMaxWidth() + .padding(AppSpacing.large), + verticalAlignment = Alignment.CenterVertically ) { - Text( - text = stringResource(R.string.privacy_notice), - style = MaterialTheme.typography.titleMedium, - fontWeight = FontWeight.SemiBold, - color = MaterialTheme.colorScheme.onSurface - ) + Column(modifier = Modifier.weight(1f)) { + Text( + text = stringResource(R.string.privacy_notice), + style = MaterialTheme.typography.titleMedium, + fontWeight = FontWeight.SemiBold, + color = MaterialTheme.colorScheme.onSurface + ) - Spacer(modifier = Modifier.height(AppSpacing.small)) + Spacer(modifier = Modifier.height(AppSpacing.small)) - Text( - text = stringResource( - R.string.please_read_and_agree_to_the_following_privacy_notice_to_use_the_app - ), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.onSurfaceVariant + Text( + text = stringResource( + R.string.please_read_and_agree_to_the_following_privacy_notice_to_use_the_app + ), + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.onSurfaceVariant + ) + } + + Icon( + imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight, + contentDescription = null, + tint = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(start = AppSpacing.small) ) } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8b194e7..0c17f21 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,7 +23,6 @@ I\'m In Allow Privacy Policy - Privacy Screen Reset to default Reset all data Are you sure you want to reset all settings and data to default?