localisation: onboarding

This commit is contained in:
2026-06-08 18:49:05 +02:00
parent 7b26bc21c4
commit ceed94b253
5 changed files with 43 additions and 15 deletions
@@ -328,6 +328,7 @@ val EnHomeStrings = AppStrings(
connect = "Connect",
notificationsTitle = "Stay in the loop",
notificationsSubtitle = "Get notified instantly when you receive a payment.",
notificationsAlreadyGranted = "You're all set - permissions have been granted.",
allowNotifications = "Allow Notifications",
notificationsNote = "You can change this later in system Settings.",
notificationsAutoGranted = "Notifications are enabled automatically on your device.",
@@ -328,6 +328,7 @@ val EsHomeStrings = AppStrings(
connect = "Conectar",
notificationsTitle = "Mantente al día",
notificationsSubtitle = "Recibe notificaciones al instante cuando recibas un pago.",
notificationsAlreadyGranted = "Todo listo — los permisos han sido concedidos.",
allowNotifications = "Permitir notificaciones",
notificationsNote = "Puedes cambiar esto más tarde en los Ajustes del sistema.",
notificationsAutoGranted = "Las notificaciones se activan automáticamente en tu dispositivo.",
@@ -328,6 +328,7 @@ val EuStrings = AppStrings(
connect = "Konektatu",
notificationsTitle = "Egon eguneratuta",
notificationsSubtitle = "Jaso jakinarazpenak berehala transakzio bat jasotzen duzunean.",
notificationsAlreadyGranted = "Dena prest dago — baimenak emanda daude.",
allowNotifications = "Baimendu jakinarazpenak",
notificationsNote = "Hau geroago alda dezakezu sistemaren Ezarpenetan.",
notificationsAutoGranted = "Jakinarazpenak automatikoki gaituta daude zure gailuan.",
@@ -327,6 +327,7 @@ data class OnboardingStrings(
val done: String,
val notificationsTitle: String,
val notificationsSubtitle: String,
val notificationsAlreadyGranted: String,
val allowNotifications: String,
val notificationsNote: String,
val notificationsAutoGranted: String,
@@ -1,8 +1,10 @@
package com.bitcointxoko.gudariwallet.ui.onboarding
import android.Manifest
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.PowerManager
import android.provider.Settings
@@ -51,7 +53,10 @@ import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.core.content.ContextCompat
import androidx.core.net.toUri
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
import androidx.work.WorkInfo
import com.bitcointxoko.gudariwallet.i18n.AppStrings
import com.bitcointxoko.gudariwallet.sync.HistoricalSyncWorker
@@ -233,9 +238,25 @@ fun NotificationsPage(
strings: AppStrings,
onRequestNotificationPermission: () -> Unit
) {
// On API < 33, the permission doesn't exist — show a reduced UI
val context = LocalContext.current
// On API < 33, POST_NOTIFICATIONS doesn't exist — it's implicitly granted
val needsPermission = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
// Helper to do the actual check
fun checkGranted(): Boolean = !needsPermission || ContextCompat.checkSelfPermission(
context,
Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED
// Reactive state — re-evaluated on every resume (e.g. returning from the
// system permission dialog), mirroring how BatteryPage re-checks on recompose
var alreadyGranted by remember { mutableStateOf(checkGranted()) }
LifecycleEventEffect(Lifecycle.Event.ON_RESUME) {
alreadyGranted = checkGranted()
}
OnboardingPageScaffold(
title = strings.onboarding.notificationsTitle, // ← "Stay in the loop"
subtitle = strings.onboarding.notificationsSubtitle // ← "Get notified instantly when you receive a payment."
@@ -244,11 +265,23 @@ fun NotificationsPage(
imageVector = Icons.Default.Notifications,
contentDescription = null,
modifier = Modifier.size(72.dp),
tint = MaterialTheme.colorScheme.primary
// Mirror the BatteryPage tint behaviour
tint = if (alreadyGranted)
MaterialTheme.colorScheme.primary
else
MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(Modifier.height(32.dp))
if (needsPermission) {
if (alreadyGranted) {
Text(
text = strings.onboarding.notificationsAutoGranted,
// ← reuse existing string, or add a new "notificationsAlreadyGranted"
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.primary,
textAlign = TextAlign.Center
)
} else {
Button(
onClick = onRequestNotificationPermission,
modifier = Modifier.fillMaxWidth()
@@ -257,19 +290,10 @@ fun NotificationsPage(
}
Spacer(Modifier.height(8.dp))
Text(
text = strings.onboarding.notificationsNote,
text = strings.onboarding.notificationsNote,
// ← "You can change this later in system Settings."
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
textAlign = TextAlign.Center
)
} else {
// API < 33: permission granted implicitly, nothing to request
Text(
text = strings.onboarding.notificationsAutoGranted,
// ← "Notifications are enabled automatically on your device."
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
textAlign = TextAlign.Center
)
}