-
Notifications
You must be signed in to change notification settings - Fork 0
Add About section to Settings; bump version to 1.0.1 #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,9 @@ | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| package fr.benju.tasks.feature.settings | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import android.content.Intent | ||||||||||||||||||||||
| import android.net.Uri | ||||||||||||||||||||||
| import androidx.compose.foundation.clickable | ||||||||||||||||||||||
| import androidx.compose.foundation.layout.Arrangement | ||||||||||||||||||||||
| import androidx.compose.foundation.layout.Column | ||||||||||||||||||||||
| import androidx.compose.foundation.layout.Row | ||||||||||||||||||||||
|
|
@@ -22,6 +25,7 @@ import androidx.compose.runtime.Composable | |||||||||||||||||||||
| import androidx.compose.runtime.getValue | ||||||||||||||||||||||
| import androidx.compose.ui.Alignment | ||||||||||||||||||||||
| import androidx.compose.ui.Modifier | ||||||||||||||||||||||
| import androidx.compose.ui.platform.LocalContext | ||||||||||||||||||||||
| import androidx.compose.ui.res.painterResource | ||||||||||||||||||||||
| import androidx.compose.ui.res.stringResource | ||||||||||||||||||||||
| import androidx.compose.ui.unit.dp | ||||||||||||||||||||||
|
|
@@ -34,6 +38,7 @@ fun SettingsScreen( | |||||||||||||||||||||
| onBack: () -> Unit = {} | ||||||||||||||||||||||
| ) { | ||||||||||||||||||||||
| val isDarkMode by viewModel.darkModeFlow.collectAsStateWithLifecycle() | ||||||||||||||||||||||
| val context = LocalContext.current | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Scaffold( | ||||||||||||||||||||||
| topBar = { | ||||||||||||||||||||||
|
|
@@ -77,10 +82,91 @@ fun SettingsScreen( | |||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Text( | ||||||||||||||||||||||
| text = stringResource(R.string.settings_version), | ||||||||||||||||||||||
| style = MaterialTheme.typography.bodySmall, | ||||||||||||||||||||||
| color = MaterialTheme.colorScheme.onSurfaceVariant | ||||||||||||||||||||||
| text = stringResource(R.string.settings_about), | ||||||||||||||||||||||
| style = MaterialTheme.typography.titleMedium, | ||||||||||||||||||||||
| modifier = Modifier.padding(bottom = 8.dp) | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Row( | ||||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||||
| .fillMaxWidth() | ||||||||||||||||||||||
| .clickable { | ||||||||||||||||||||||
| val intent = Intent(Intent.ACTION_SENDTO).apply { | ||||||||||||||||||||||
| data = Uri.parse("mailto:begonin@gmail.com") | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| runCatching { context.startActivity(intent) } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| .padding(vertical = 12.dp), | ||||||||||||||||||||||
|
Comment on lines
+91
to
+99
|
||||||||||||||||||||||
| verticalAlignment = Alignment.CenterVertically | ||||||||||||||||||||||
| ) { | ||||||||||||||||||||||
| Text( | ||||||||||||||||||||||
| text = stringResource(R.string.settings_contact_support), | ||||||||||||||||||||||
| style = MaterialTheme.typography.bodyMedium | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Row( | ||||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||||
| .fillMaxWidth() | ||||||||||||||||||||||
| .clickable { | ||||||||||||||||||||||
| val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://benju.fr/support.html")) | ||||||||||||||||||||||
| runCatching { context.startActivity(intent) } | ||||||||||||||||||||||
|
Comment on lines
+111
to
+113
|
||||||||||||||||||||||
| } | ||||||||||||||||||||||
| .padding(vertical = 12.dp), | ||||||||||||||||||||||
| verticalAlignment = Alignment.CenterVertically | ||||||||||||||||||||||
|
Comment on lines
+109
to
+116
|
||||||||||||||||||||||
| ) { | ||||||||||||||||||||||
| Text( | ||||||||||||||||||||||
| text = stringResource(R.string.settings_support_me), | ||||||||||||||||||||||
| style = MaterialTheme.typography.bodyMedium | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Row( | ||||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||||
| .fillMaxWidth() | ||||||||||||||||||||||
| .clickable { | ||||||||||||||||||||||
| val intent = Intent( | ||||||||||||||||||||||
| Intent.ACTION_VIEW, | ||||||||||||||||||||||
| Uri.parse("market://details?id=${context.packageName}") | ||||||||||||||||||||||
| ).apply { | ||||||||||||||||||||||
| addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY or Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_MULTIPLE_TASK) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| val fallback = Intent( | ||||||||||||||||||||||
| Intent.ACTION_VIEW, | ||||||||||||||||||||||
| Uri.parse("https://play.google.com/store/apps/details?id=${context.packageName}") | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| runCatching { context.startActivity(intent) } | ||||||||||||||||||||||
| .onFailure { runCatching { context.startActivity(fallback) } } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| .padding(vertical = 12.dp), | ||||||||||||||||||||||
| verticalAlignment = Alignment.CenterVertically | ||||||||||||||||||||||
| ) { | ||||||||||||||||||||||
| Text( | ||||||||||||||||||||||
| text = stringResource(R.string.settings_rate_app), | ||||||||||||||||||||||
| style = MaterialTheme.typography.bodyMedium | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Row( | ||||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||||
| .fillMaxWidth() | ||||||||||||||||||||||
| .padding(vertical = 12.dp), | ||||||||||||||||||||||
| horizontalArrangement = Arrangement.SpaceBetween, | ||||||||||||||||||||||
| verticalAlignment = Alignment.CenterVertically | ||||||||||||||||||||||
| ) { | ||||||||||||||||||||||
| Text( | ||||||||||||||||||||||
| text = stringResource(R.string.settings_version), | ||||||||||||||||||||||
| style = MaterialTheme.typography.bodyMedium | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| val versionName = runCatching { | ||||||||||||||||||||||
| context.packageManager.getPackageInfo(context.packageName, 0).versionName.orEmpty() | ||||||||||||||||||||||
|
||||||||||||||||||||||
| context.packageManager.getPackageInfo(context.packageName, 0).versionName.orEmpty() | |
| if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) { | |
| context.packageManager.getPackageInfo( | |
| context.packageName, | |
| android.content.pm.PackageManager.PackageInfoFlags.of(0) | |
| ).versionName.orEmpty() | |
| } else { | |
| @Suppress("DEPRECATION") | |
| context.packageManager.getPackageInfo(context.packageName, 0).versionName.orEmpty() | |
| } |
Copilot
AI
Apr 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
versionName is computed by calling PackageManager.getPackageInfo(...) directly in the composable body, which will re-run on every recomposition. Cache this (e.g., with remember/produceState) so it’s only resolved once per composition (or when context.packageName changes).
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,13 @@ | |
| <!-- Settings --> | ||
| <string name="settings_title">Settings</string> | ||
| <string name="settings_dark_mode">Dark Mode</string> | ||
| <string name="settings_version">Version 1.0.0</string> | ||
|
|
||
| <!-- About --> | ||
| <string name="settings_about">About</string> | ||
| <string name="settings_contact_support">Contact Support</string> | ||
| <string name="settings_support_me">Support me</string> | ||
| <string name="settings_rate_app">Rate the app</string> | ||
| <string name="settings_version">Version</string> | ||
|
Comment on lines
+9
to
+12
|
||
|
|
||
| <!-- Content Descriptions --> | ||
| <string name="cd_back">Back</string> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The support email address is hardcoded in the UI code. For easier future updates (and to keep UI strings/config in one place), consider moving this address into a string resource or a small constants file (and building the
mailto:Uri from it).