Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fa3b4eac1 | ||
|
|
197bcc6f5e |
@@ -34,8 +34,8 @@ android {
|
||||
applicationId = "pl.firmatpp.kierowca"
|
||||
minSdk = 26
|
||||
targetSdk = 35
|
||||
versionCode = 108
|
||||
versionName = "1.0.55"
|
||||
versionCode = 109
|
||||
versionName = "1.0.56"
|
||||
setProperty("archivesBaseName", "pl.firmatpp.kierowca")
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
||||
@@ -228,6 +228,22 @@ fun DriverApp(
|
||||
viewModel.openLeaveRequest(initialLeaveRequestId)
|
||||
}
|
||||
}
|
||||
LaunchedEffect(state.screen, state.notifyNewRoutes, state.notificationPermissionDenied, appInForeground) {
|
||||
if (!appInForeground || state.screen != DriverScreen.Profile || !state.notifyNewRoutes) return@LaunchedEffect
|
||||
|
||||
if (canPostNotifications(context)) {
|
||||
if (state.notificationPermissionDenied) {
|
||||
viewModel.clearNotificationPermissionWarning()
|
||||
}
|
||||
return@LaunchedEffect
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && !hasPostNotificationsRuntimePermission(context)) {
|
||||
notificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
|
||||
} else {
|
||||
viewModel.markNotificationPermissionBlocked()
|
||||
}
|
||||
}
|
||||
|
||||
Box(Modifier.fillMaxSize().background(TppTheme.colors.surface)) {
|
||||
when (state.screen) {
|
||||
@@ -2238,13 +2254,18 @@ private fun ProfileScreen(
|
||||
Text("Zmiana powiadomień wymaga połączenia z internetem.", color = TppTheme.colors.muted, style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
if (state.notificationPermissionDenied) {
|
||||
Text(
|
||||
"Android blokuje powiadomienia dla tej aplikacji. Token FCM może być zarejestrowany, ale powiadomienie nie pojawi się na telefonie, dopóki nie włączysz zgody systemowej.",
|
||||
color = TppTheme.colors.error,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
)
|
||||
Button(
|
||||
onClick = onOpenNotificationSettings,
|
||||
modifier = Modifier.fillMaxWidth().height(48.dp),
|
||||
colors = ButtonDefaults.buttonColors(containerColor = TppTheme.colors.navy),
|
||||
shape = MaterialTheme.shapes.small,
|
||||
) {
|
||||
Text("Przejdź do ustawień", fontWeight = FontWeight.Bold)
|
||||
Text("Otwórz ustawienia powiadomień", fontWeight = FontWeight.Bold)
|
||||
}
|
||||
}
|
||||
HorizontalDivider(color = TppTheme.colors.outline.copy(alpha = 0.55f))
|
||||
|
||||
@@ -639,6 +639,24 @@ class DriverViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
}
|
||||
|
||||
fun markNotificationPermissionBlocked() {
|
||||
_state.update {
|
||||
it.copy(
|
||||
notificationPermissionDenied = true,
|
||||
error = "Powiadomienia są włączone w aplikacji, ale Android blokuje ich wyświetlanie. Włącz powiadomienia w ustawieniach aplikacji.",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun clearNotificationPermissionWarning() {
|
||||
_state.update {
|
||||
it.copy(
|
||||
notificationPermissionDenied = false,
|
||||
error = if (it.error?.contains("powiadom", ignoreCase = true) == true) null else it.error,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun setThemeMode(themeMode: AppThemeMode) {
|
||||
_state.update { it.copy(themeMode = themeMode) }
|
||||
viewModelScope.launch {
|
||||
|
||||
Reference in New Issue
Block a user