Skip to content

Commit 51b5496

Browse files
committed
Fix UI not updating after granting notifications permission
1 parent dca83c3 commit 51b5496

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ android {
4141
else -> 0
4242
}
4343

44-
val vCode = 421
44+
val vCode = 424
4545
versionCode = vCode - singleAbiNum
46-
versionName = "2.1.13"
46+
versionName = "2.1.14"
4747

4848
ndk {
4949
//noinspection ChromeOsAbiSupport

app/src/main/java/com/ismartcoding/plain/ui/page/web/WebSettingsPage.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ fun WebSettingsPage(
8888
var permissionList by remember { mutableStateOf(Permissions.getWebList(context)) }
8989
var shouldIgnoreOptimize by remember { mutableStateOf(!powerManager.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID)) }
9090
var systemAlertWindow by remember { mutableStateOf(Permission.SYSTEM_ALERT_WINDOW.can(context)) }
91+
var notificationListenerGranted by remember { mutableStateOf(Permission.NOTIFICATION_LISTENER.can(context)) }
9192
val sharedFlow = Channel.sharedFlow
9293

9394
val learnMore = stringResource(id = R.string.learn_more)
@@ -99,6 +100,7 @@ fun WebSettingsPage(
99100
is PermissionsResultEvent -> {
100101
permissionList = Permissions.getWebList(context)
101102
systemAlertWindow = Permission.SYSTEM_ALERT_WINDOW.can(context)
103+
notificationListenerGranted = Permission.NOTIFICATION_LISTENER.can(context)
102104
if (event.map[Permission.NOTIFICATION_LISTENER.toSysPermission()] == true) {
103105
// Only enable listener if web is enabled
104106
PNotificationListenerService.toggle(context, WebPreference.getAsync(context))
@@ -107,6 +109,7 @@ fun WebSettingsPage(
107109

108110
is WindowFocusChangedEvent -> {
109111
shouldIgnoreOptimize = !powerManager.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID)
112+
notificationListenerGranted = Permission.NOTIFICATION_LISTENER.can(context)
110113
}
111114

112115
is IgnoreBatteryOptimizationResultEvent -> {
@@ -230,7 +233,7 @@ fun WebSettingsPage(
230233
title = permission.getText(),
231234
subtitle =
232235
stringResource(
233-
if (m.granted) R.string.system_permission_granted else R.string.system_permission_not_granted,
236+
if (notificationListenerGranted) R.string.system_permission_granted else R.string.system_permission_not_granted,
234237
),
235238
) {
236239
PSwitch(activated = enabledPermissions.contains(permission.name)) { enable ->

0 commit comments

Comments
 (0)