Skip to content

Commit

Permalink
perf: 权限说明
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Jan 20, 2024
1 parent 1970d6a commit 7c60476
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions app/src/main/kotlin/li/songe/gkd/ui/ControlPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,14 +57,18 @@ 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(
state = rememberScrollState()
)
) {
if (!gkdAccessRunning) {
AuthCard(title = "无障碍权限",
AuthCard(
title = "无障碍权限",
desc = "用于获取屏幕信息,点击屏幕上的控件",
onAuthClick = {
appScope.launchTry {
Expand All @@ -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 = "在通知栏显示服务运行状态及统计数据",
Expand All @@ -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,
Expand Down

0 comments on commit 7c60476

Please sign in to comment.