From 7c60476cc7f4ea717ab0632da9a6b0d1eed70077 Mon Sep 17 00:00:00 2001 From: lisonge Date: Sat, 20 Jan 2024 23:08:53 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=9D=83=E9=99=90=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/li/songe/gkd/ui/ControlPage.kt | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/app/src/main/kotlin/li/songe/gkd/ui/ControlPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/ControlPage.kt index fdffd83..648e9bf 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/ControlPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/ControlPage.kt @@ -26,6 +26,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.core.app.NotificationManagerCompat import androidx.hilt.navigation.compose.hiltViewModel import li.songe.gkd.MainActivity import li.songe.gkd.appScope @@ -56,6 +57,9 @@ fun ControlPage() { val gkdAccessRunning by GkdAbService.isRunning.collectAsState() val manageRunning by ManageService.isRunning.collectAsState() val canDrawOverlays by usePollState { Settings.canDrawOverlays(context) } + val canNotif by usePollState { + NotificationManagerCompat.from(context).areNotificationsEnabled() + } Column( modifier = Modifier.verticalScroll( @@ -63,7 +67,8 @@ fun ControlPage() { ) ) { if (!gkdAccessRunning) { - AuthCard(title = "无障碍权限", + AuthCard( + title = "无障碍权限", desc = "用于获取屏幕信息,点击屏幕上的控件", onAuthClick = { appScope.launchTry { @@ -88,6 +93,31 @@ fun ControlPage() { } Divider() + if (!canNotif) { + AuthCard(title = "通知权限", + desc = "用于显示各类服务状态数据及前后台提示", + onAuthClick = { + checkOrRequestNotifPermission(context) + }) + Divider() + } + + if (!canDrawOverlays) { + AuthCard( + title = "悬浮窗权限", + desc = "用于后台提示,显示保存快照按钮等功能", + onAuthClick = { + appScope.launchTry { + val intent = Intent( + Settings.ACTION_MANAGE_OVERLAY_PERMISSION, + ) + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK + context.startActivity(intent) + } + }) + Divider() + } + TextSwitch( name = "常驻通知", desc = "在通知栏显示服务运行状态及统计数据", @@ -114,20 +144,6 @@ fun ControlPage() { }) Divider() - if (!canDrawOverlays) { - AuthCard( - title = "悬浮窗权限", - desc = "用于后台提示,显示保存快照按钮等功能", - onAuthClick = { - val intent = Intent( - Settings.ACTION_MANAGE_OVERLAY_PERMISSION, - ) - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK - context.startActivity(intent) - }) - Divider() - } - Row( horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically,