mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-05 22:36:34 +00:00
if -> when
This commit is contained in:
committed by
Benoit Marty
parent
986fbcdce2
commit
9e00c60649
+45
-41
@@ -32,48 +32,52 @@ fun PermissionsView(
|
|||||||
) {
|
) {
|
||||||
if (state.showDialog.not()) return
|
if (state.showDialog.not()) return
|
||||||
|
|
||||||
if (state.permissionGranted) {
|
when {
|
||||||
// Notification Granted, nothing to do
|
state.permissionGranted -> {
|
||||||
} else if (state.permissionAlreadyDenied) {
|
// Notification Granted, nothing to do
|
||||||
// In this case, tell the user to go to the settings
|
}
|
||||||
ConfirmationDialog(
|
state.permissionAlreadyDenied -> {
|
||||||
modifier = modifier,
|
// In this case, tell the user to go to the settings
|
||||||
title = "System",
|
ConfirmationDialog(
|
||||||
content = "In order to let the application display notification, please grant the permission to the system settings",
|
modifier = modifier,
|
||||||
submitText = "Open settings",
|
title = "System",
|
||||||
onSubmitClicked = {
|
content = "In order to let the application display notification, please grant the permission to the system settings",
|
||||||
state.eventSink.invoke(PermissionsEvents.CloseDialog)
|
submitText = "Open settings",
|
||||||
openSystemSettings()
|
onSubmitClicked = {
|
||||||
},
|
state.eventSink.invoke(PermissionsEvents.CloseDialog)
|
||||||
onDismiss = { state.eventSink.invoke(PermissionsEvents.CloseDialog) },
|
openSystemSettings()
|
||||||
)
|
},
|
||||||
} else {
|
onDismiss = { state.eventSink.invoke(PermissionsEvents.CloseDialog) },
|
||||||
val textToShow = if (state.shouldShowRationale) {
|
)
|
||||||
// TODO Move to state
|
}
|
||||||
// If the user has denied the permission but the rationale can be shown,
|
else -> {
|
||||||
// then gently explain why the app requires this permission
|
val textToShow = if (state.shouldShowRationale) {
|
||||||
// permissions_rationale_msg_notification
|
// TODO Move to state
|
||||||
"To be able to receive notifications, please grant the permission. Else you will not be able to be alerted if you've got new messages."
|
// If the user has denied the permission but the rationale can be shown,
|
||||||
} else {
|
// then gently explain why the app requires this permission
|
||||||
// TODO Move to state
|
// permissions_rationale_msg_notification
|
||||||
// If it's the first time the user lands on this feature, or the user
|
"To be able to receive notifications, please grant the permission. Else you will not be able to be alerted if you've got new messages."
|
||||||
// doesn't want to be asked again for this permission, explain that the
|
} else {
|
||||||
// permission is required
|
// TODO Move to state
|
||||||
"To be able to receive notifications, please grant the permission."
|
// If it's the first time the user lands on this feature, or the user
|
||||||
|
// doesn't want to be asked again for this permission, explain that the
|
||||||
|
// permission is required
|
||||||
|
"To be able to receive notifications, please grant the permission."
|
||||||
|
}
|
||||||
|
ConfirmationDialog(
|
||||||
|
modifier = modifier,
|
||||||
|
title = "Notifications",
|
||||||
|
content = textToShow,
|
||||||
|
submitText = "Request permission",
|
||||||
|
onSubmitClicked = {
|
||||||
|
state.eventSink.invoke(PermissionsEvents.OpenSystemDialog)
|
||||||
|
},
|
||||||
|
onCancelClicked = {
|
||||||
|
state.eventSink.invoke(PermissionsEvents.CloseDialog)
|
||||||
|
},
|
||||||
|
onDismiss = {}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
ConfirmationDialog(
|
|
||||||
modifier = modifier,
|
|
||||||
title = "Notifications",
|
|
||||||
content = textToShow,
|
|
||||||
submitText = "Request permission",
|
|
||||||
onSubmitClicked = {
|
|
||||||
state.eventSink.invoke(PermissionsEvents.OpenSystemDialog)
|
|
||||||
},
|
|
||||||
onCancelClicked = {
|
|
||||||
state.eventSink.invoke(PermissionsEvents.CloseDialog)
|
|
||||||
},
|
|
||||||
onDismiss = {}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user