localisation: onboarding
This commit is contained in:
@@ -328,6 +328,7 @@ val EnHomeStrings = AppStrings(
|
|||||||
connect = "Connect",
|
connect = "Connect",
|
||||||
notificationsTitle = "Stay in the loop",
|
notificationsTitle = "Stay in the loop",
|
||||||
notificationsSubtitle = "Get notified instantly when you receive a payment.",
|
notificationsSubtitle = "Get notified instantly when you receive a payment.",
|
||||||
|
notificationsAlreadyGranted = "You're all set - permissions have been granted.",
|
||||||
allowNotifications = "Allow Notifications",
|
allowNotifications = "Allow Notifications",
|
||||||
notificationsNote = "You can change this later in system Settings.",
|
notificationsNote = "You can change this later in system Settings.",
|
||||||
notificationsAutoGranted = "Notifications are enabled automatically on your device.",
|
notificationsAutoGranted = "Notifications are enabled automatically on your device.",
|
||||||
|
|||||||
@@ -328,6 +328,7 @@ val EsHomeStrings = AppStrings(
|
|||||||
connect = "Conectar",
|
connect = "Conectar",
|
||||||
notificationsTitle = "Mantente al día",
|
notificationsTitle = "Mantente al día",
|
||||||
notificationsSubtitle = "Recibe notificaciones al instante cuando recibas un pago.",
|
notificationsSubtitle = "Recibe notificaciones al instante cuando recibas un pago.",
|
||||||
|
notificationsAlreadyGranted = "Todo listo — los permisos han sido concedidos.",
|
||||||
allowNotifications = "Permitir notificaciones",
|
allowNotifications = "Permitir notificaciones",
|
||||||
notificationsNote = "Puedes cambiar esto más tarde en los Ajustes del sistema.",
|
notificationsNote = "Puedes cambiar esto más tarde en los Ajustes del sistema.",
|
||||||
notificationsAutoGranted = "Las notificaciones se activan automáticamente en tu dispositivo.",
|
notificationsAutoGranted = "Las notificaciones se activan automáticamente en tu dispositivo.",
|
||||||
|
|||||||
@@ -328,6 +328,7 @@ val EuStrings = AppStrings(
|
|||||||
connect = "Konektatu",
|
connect = "Konektatu",
|
||||||
notificationsTitle = "Egon eguneratuta",
|
notificationsTitle = "Egon eguneratuta",
|
||||||
notificationsSubtitle = "Jaso jakinarazpenak berehala transakzio bat jasotzen duzunean.",
|
notificationsSubtitle = "Jaso jakinarazpenak berehala transakzio bat jasotzen duzunean.",
|
||||||
|
notificationsAlreadyGranted = "Dena prest dago — baimenak emanda daude.",
|
||||||
allowNotifications = "Baimendu jakinarazpenak",
|
allowNotifications = "Baimendu jakinarazpenak",
|
||||||
notificationsNote = "Hau geroago alda dezakezu sistemaren Ezarpenetan.",
|
notificationsNote = "Hau geroago alda dezakezu sistemaren Ezarpenetan.",
|
||||||
notificationsAutoGranted = "Jakinarazpenak automatikoki gaituta daude zure gailuan.",
|
notificationsAutoGranted = "Jakinarazpenak automatikoki gaituta daude zure gailuan.",
|
||||||
|
|||||||
@@ -327,6 +327,7 @@ data class OnboardingStrings(
|
|||||||
val done: String,
|
val done: String,
|
||||||
val notificationsTitle: String,
|
val notificationsTitle: String,
|
||||||
val notificationsSubtitle: String,
|
val notificationsSubtitle: String,
|
||||||
|
val notificationsAlreadyGranted: String,
|
||||||
val allowNotifications: String,
|
val allowNotifications: String,
|
||||||
val notificationsNote: String,
|
val notificationsNote: String,
|
||||||
val notificationsAutoGranted: String,
|
val notificationsAutoGranted: String,
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.bitcointxoko.gudariwallet.ui.onboarding
|
package com.bitcointxoko.gudariwallet.ui.onboarding
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
import android.content.ActivityNotFoundException
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.provider.Settings
|
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.input.VisualTransformation
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.compose.LifecycleEventEffect
|
||||||
import androidx.work.WorkInfo
|
import androidx.work.WorkInfo
|
||||||
import com.bitcointxoko.gudariwallet.i18n.AppStrings
|
import com.bitcointxoko.gudariwallet.i18n.AppStrings
|
||||||
import com.bitcointxoko.gudariwallet.sync.HistoricalSyncWorker
|
import com.bitcointxoko.gudariwallet.sync.HistoricalSyncWorker
|
||||||
@@ -233,9 +238,25 @@ fun NotificationsPage(
|
|||||||
strings: AppStrings,
|
strings: AppStrings,
|
||||||
onRequestNotificationPermission: () -> Unit
|
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
|
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(
|
OnboardingPageScaffold(
|
||||||
title = strings.onboarding.notificationsTitle, // ← "Stay in the loop"
|
title = strings.onboarding.notificationsTitle, // ← "Stay in the loop"
|
||||||
subtitle = strings.onboarding.notificationsSubtitle // ← "Get notified instantly when you receive a payment."
|
subtitle = strings.onboarding.notificationsSubtitle // ← "Get notified instantly when you receive a payment."
|
||||||
@@ -244,11 +265,23 @@ fun NotificationsPage(
|
|||||||
imageVector = Icons.Default.Notifications,
|
imageVector = Icons.Default.Notifications,
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier.size(72.dp),
|
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))
|
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(
|
Button(
|
||||||
onClick = onRequestNotificationPermission,
|
onClick = onRequestNotificationPermission,
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
@@ -263,15 +296,6 @@ fun NotificationsPage(
|
|||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
textAlign = TextAlign.Center
|
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,
|
|
||||||
textAlign = TextAlign.Center
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user