Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fa3b4eac1 | ||
|
|
197bcc6f5e |
@@ -34,8 +34,8 @@ android {
|
|||||||
applicationId = "pl.firmatpp.kierowca"
|
applicationId = "pl.firmatpp.kierowca"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 108
|
versionCode = 109
|
||||||
versionName = "1.0.55"
|
versionName = "1.0.56"
|
||||||
setProperty("archivesBaseName", "pl.firmatpp.kierowca")
|
setProperty("archivesBaseName", "pl.firmatpp.kierowca")
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
|||||||
@@ -228,6 +228,22 @@ fun DriverApp(
|
|||||||
viewModel.openLeaveRequest(initialLeaveRequestId)
|
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)) {
|
Box(Modifier.fillMaxSize().background(TppTheme.colors.surface)) {
|
||||||
when (state.screen) {
|
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)
|
Text("Zmiana powiadomień wymaga połączenia z internetem.", color = TppTheme.colors.muted, style = MaterialTheme.typography.bodySmall)
|
||||||
}
|
}
|
||||||
if (state.notificationPermissionDenied) {
|
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(
|
Button(
|
||||||
onClick = onOpenNotificationSettings,
|
onClick = onOpenNotificationSettings,
|
||||||
modifier = Modifier.fillMaxWidth().height(48.dp),
|
modifier = Modifier.fillMaxWidth().height(48.dp),
|
||||||
colors = ButtonDefaults.buttonColors(containerColor = TppTheme.colors.navy),
|
colors = ButtonDefaults.buttonColors(containerColor = TppTheme.colors.navy),
|
||||||
shape = MaterialTheme.shapes.small,
|
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))
|
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) {
|
fun setThemeMode(themeMode: AppThemeMode) {
|
||||||
_state.update { it.copy(themeMode = themeMode) }
|
_state.update { it.copy(themeMode = themeMode) }
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
|
|||||||
Reference in New Issue
Block a user