From c2710ba3d4ec99095d3ab90fe126f4688ac25a01 Mon Sep 17 00:00:00 2001 From: lisonge Date: Tue, 30 Jan 2024 22:29:48 +0800 Subject: [PATCH] perf: update material api --- .../main/kotlin/li/songe/gkd/ui/AboutPage.kt | 33 +++++++++--------- .../kotlin/li/songe/gkd/ui/ClickLogPage.kt | 4 +-- .../kotlin/li/songe/gkd/ui/ControlPage.kt | 14 ++++---- .../main/kotlin/li/songe/gkd/ui/DebugPage.kt | 22 ++++++------ .../kotlin/li/songe/gkd/ui/SettingsPage.kt | 34 +++++++++++-------- .../kotlin/li/songe/gkd/ui/SnapshotPage.kt | 18 +++++----- .../kotlin/li/songe/gkd/ui/SubsManagePage.kt | 14 ++++---- .../main/kotlin/li/songe/gkd/util/Upgrade.kt | 4 ++- 8 files changed, 76 insertions(+), 67 deletions(-) diff --git a/app/src/main/kotlin/li/songe/gkd/ui/AboutPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/AboutPage.kt index d24888134..cd43b1502 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/AboutPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/AboutPage.kt @@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -80,7 +80,7 @@ fun AboutPage() { color = MaterialTheme.colorScheme.primary, ) } - Divider() + HorizontalDivider() Column( modifier = Modifier .fillMaxWidth() @@ -95,7 +95,7 @@ fun AboutPage() { fontSize = 14.sp, ) } - Divider() + HorizontalDivider() Column( modifier = Modifier .fillMaxWidth() @@ -111,19 +111,20 @@ fun AboutPage() { ) } @Suppress("SENSELESS_COMPARISON") if (GIT_COMMIT_URL != null && BuildConfig.GIT_COMMIT_ID != null) { - Divider() - Column(modifier = Modifier - .clickable { - appScope.launchTry { - context.startActivity( - Intent( - Intent.ACTION_VIEW, Uri.parse(GIT_COMMIT_URL) + HorizontalDivider() + Column( + modifier = Modifier + .clickable { + appScope.launchTry { + context.startActivity( + Intent( + Intent.ACTION_VIEW, Uri.parse(GIT_COMMIT_URL) + ) ) - ) + } } - } - .fillMaxWidth() - .padding(10.dp)) { + .fillMaxWidth() + .padding(10.dp)) { Text( text = "代码记录", fontSize = 18.sp ) @@ -135,7 +136,7 @@ fun AboutPage() { ) } } - Divider() + HorizontalDivider() Column( modifier = Modifier .fillMaxWidth() @@ -150,7 +151,7 @@ fun AboutPage() { fontSize = 14.sp, ) } - Divider() + HorizontalDivider() Column( modifier = Modifier .fillMaxWidth() diff --git a/app/src/main/kotlin/li/songe/gkd/ui/ClickLogPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/ClickLogPage.kt index f33244bee..7903b98aa 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/ClickLogPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/ClickLogPage.kt @@ -16,7 +16,7 @@ import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.outlined.Delete import androidx.compose.material3.AlertDialog import androidx.compose.material3.Card -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -181,7 +181,7 @@ fun ClickLogPage() { Text(text = (if (clickLog.ruleKey != null) "key=${clickLog.ruleKey}, " else "") + "index=${clickLog.ruleIndex}") } } - Divider() + HorizontalDivider() } item { Spacer(modifier = Modifier.height(10.dp)) 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 176bd1032..a380c7162 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/ControlPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/ControlPage.kt @@ -17,7 +17,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material.icons.automirrored.filled.OpenInNew import androidx.compose.material.icons.filled.Home -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -95,7 +95,7 @@ fun ControlPage() { ) }) } - Divider() + HorizontalDivider() if (!canNotif) { AuthCard(title = "通知权限", @@ -103,7 +103,7 @@ fun ControlPage() { onAuthClick = { checkOrRequestNotifPermission(context) }) - Divider() + HorizontalDivider() } if (!canDrawOverlays) { @@ -119,7 +119,7 @@ fun ControlPage() { context.startActivity(intent) } }) - Divider() + HorizontalDivider() } TextSwitch( @@ -146,7 +146,7 @@ fun ControlPage() { ManageService.stop(context) } }) - Divider() + HorizontalDivider() Row( horizontalArrangement = Arrangement.SpaceBetween, @@ -176,7 +176,7 @@ fun ControlPage() { } Icon(imageVector = Icons.AutoMirrored.Filled.OpenInNew, contentDescription = null) } - Divider() + HorizontalDivider() Row( horizontalArrangement = Arrangement.SpaceBetween, @@ -201,7 +201,7 @@ fun ControlPage() { contentDescription = null ) } - Divider() + HorizontalDivider() Column( modifier = Modifier diff --git a/app/src/main/kotlin/li/songe/gkd/ui/DebugPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/DebugPage.kt index b37c566ab..677c0c391 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/DebugPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/DebugPage.kt @@ -22,7 +22,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Edit import androidx.compose.material3.AlertDialog -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.LocalTextStyle @@ -128,7 +128,7 @@ fun DebugPage() { toast("Shizuku可能没有运行") } }) - Divider() + HorizontalDivider() } else { TextSwitch(name = "Shizuku模式", desc = "高级运行模式,能更准确识别界面活动ID", @@ -157,7 +157,7 @@ fun DebugPage() { } }) - Divider() + HorizontalDivider() } val httpServerRunning by HttpService.isRunning.collectAsState() @@ -226,14 +226,14 @@ fun DebugPage() { } ) } - Divider() + HorizontalDivider() SettingItem( title = "HTTP服务端口-${store.httpServerPort}", imageVector = Icons.Default.Edit ) { showPortDlg = true } - Divider() + HorizontalDivider() TextSwitch( name = "自动清除内存订阅", @@ -246,12 +246,12 @@ fun DebugPage() { ) ) } - Divider() + HorizontalDivider() SettingItem(title = "快照记录", onClick = { navController.navigate(SnapshotPageDestination) }) - Divider() + HorizontalDivider() val screenshotRunning by ScreenshotService.isRunning.collectAsState() TextSwitch( @@ -274,7 +274,7 @@ fun DebugPage() { ScreenshotService.stop() } }) - Divider() + HorizontalDivider() val floatingRunning by FloatingService.isRunning.collectAsState() TextSwitch( @@ -296,7 +296,7 @@ fun DebugPage() { FloatingService.stop(context) } } - Divider() + HorizontalDivider() TextSwitch( name = "音量快照", desc = "当音量变化时,生成快照,如果悬浮窗按钮不工作,可以使用这个", @@ -309,7 +309,7 @@ fun DebugPage() { ) } - Divider() + HorizontalDivider() TextSwitch( name = "截屏快照", desc = "当用户截屏时保存快照(需手动替换快照图片),仅支持部分小米设备", @@ -322,7 +322,7 @@ fun DebugPage() { ) } - Divider() + HorizontalDivider() TextSwitch( name = "隐藏快照状态栏", desc = "当保存快照时,隐藏截图里的顶部状态栏高度区域", diff --git a/app/src/main/kotlin/li/songe/gkd/ui/SettingsPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/SettingsPage.kt index a6318252e..93d8e2b20 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/SettingsPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/SettingsPage.kt @@ -14,11 +14,11 @@ import androidx.compose.foundation.selection.selectable import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.KeyboardArrowRight +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material.icons.filled.Settings import androidx.compose.material3.AlertDialog import androidx.compose.material3.Card -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.OutlinedTextField @@ -111,7 +111,7 @@ fun SettingsPage() { ) ) }) - Divider() + HorizontalDivider() TextSwitch(name = "前台悬浮窗", desc = "添加透明悬浮窗,关闭可能导致不点击/点击缓慢", @@ -123,7 +123,7 @@ fun SettingsPage() { ) ) }) - Divider() + HorizontalDivider() TextSwitch(name = "点击提示", desc = "触发点击时提示:[${store.clickToast}]", @@ -142,7 +142,7 @@ fun SettingsPage() { ) ) }) - Divider() + HorizontalDivider() Row(modifier = Modifier .clickable { @@ -160,11 +160,12 @@ fun SettingsPage() { ?: store.updateSubsInterval.toString(), fontSize = 14.sp ) Icon( - imageVector = Icons.Default.KeyboardArrowRight, contentDescription = "more" + imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight, + contentDescription = "more" ) } } - Divider() + HorizontalDivider() TextSwitch(name = "自动更新应用", desc = "打开应用时自动检测是否存在新版本", @@ -176,7 +177,7 @@ fun SettingsPage() { ) ) }) - Divider() + HorizontalDivider() SettingItem(title = if (checkUpdating) "检查更新ing" else "检查更新", onClick = { appScope.launchTry { @@ -187,7 +188,7 @@ fun SettingsPage() { } } }) - Divider() + HorizontalDivider() Row(modifier = Modifier .clickable { @@ -205,11 +206,12 @@ fun SettingsPage() { ?: store.enableDarkTheme.toString(), fontSize = 14.sp ) Icon( - imageVector = Icons.Default.KeyboardArrowRight, contentDescription = "more" + imageVector = Icons.AutoMirrored.Filled.KeyboardArrowRight, + contentDescription = "more" ) } } - Divider() + HorizontalDivider() TextSwitch(name = "保存日志", desc = "保存最近7天的日志,大概占用您5M的空间", @@ -232,7 +234,7 @@ fun SettingsPage() { } } }) - Divider() + HorizontalDivider() SettingItem(title = "分享日志", onClick = { vm.viewModelScope.launchTry(Dispatchers.IO) { @@ -244,12 +246,12 @@ fun SettingsPage() { } } }) - Divider() + HorizontalDivider() SettingItem(title = "高级模式", onClick = { navController.navigate(DebugPageDestination) }) - Divider() + HorizontalDivider() SettingItem(title = "关于", onClick = { navController.navigate(AboutPageDestination) @@ -462,7 +464,9 @@ fun SettingsPage() { AlertDialog( title = { Text(text = "上传文件中") }, text = { - LinearProgressIndicator(progress = uploadStatusVal.progress) + LinearProgressIndicator( + progress = { uploadStatusVal.progress }, + ) }, onDismissRequest = { }, confirmButton = { diff --git a/app/src/main/kotlin/li/songe/gkd/ui/SnapshotPage.kt b/app/src/main/kotlin/li/songe/gkd/ui/SnapshotPage.kt index b225f7b01..8f0bef9ef 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/SnapshotPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/SnapshotPage.kt @@ -20,7 +20,7 @@ import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.outlined.Delete import androidx.compose.material3.AlertDialog import androidx.compose.material3.Card -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.LinearProgressIndicator @@ -163,7 +163,7 @@ fun SnapshotPage() { ) } } - Divider() + HorizontalDivider() } item { Spacer(modifier = Modifier.height(10.dp)) @@ -207,7 +207,7 @@ fun SnapshotPage() { }) .then(modifier) ) - Divider() + HorizontalDivider() Text( text = "分享", modifier = Modifier @@ -218,7 +218,7 @@ fun SnapshotPage() { }) .then(modifier) ) - Divider() + HorizontalDivider() if (snapshotVal.githubAssetId != null) { Text( text = "复制链接", modifier = Modifier @@ -239,7 +239,7 @@ fun SnapshotPage() { .then(modifier) ) } - Divider() + HorizontalDivider() Text( text = "保存截图到相册", @@ -263,7 +263,7 @@ fun SnapshotPage() { }) .then(modifier) ) - Divider() + HorizontalDivider() Text( text = "替换截图(去除隐私)", modifier = Modifier @@ -292,7 +292,7 @@ fun SnapshotPage() { }) .then(modifier) ) - Divider() + HorizontalDivider() Text( text = "删除", modifier = Modifier .clickable(onClick = scope.launchAsFn { @@ -333,7 +333,9 @@ fun SnapshotPage() { AlertDialog( title = { Text(text = "上传文件中") }, text = { - LinearProgressIndicator(progress = uploadStatusVal.progress) + LinearProgressIndicator( + progress = { uploadStatusVal.progress }, + ) }, onDismissRequest = { }, confirmButton = { diff --git a/app/src/main/kotlin/li/songe/gkd/ui/SubsManagePage.kt b/app/src/main/kotlin/li/songe/gkd/ui/SubsManagePage.kt index 13ce6719e..76bc78aab 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/SubsManagePage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/SubsManagePage.kt @@ -21,8 +21,8 @@ import androidx.compose.material.icons.automirrored.filled.FormatListBulleted import androidx.compose.material.icons.filled.Add import androidx.compose.material3.AlertDialog import androidx.compose.material3.Card -import androidx.compose.material3.Divider import androidx.compose.material3.FloatingActionButton +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.MaterialTheme @@ -211,7 +211,7 @@ fun SubsManagePage() { } .fillMaxWidth() .padding(16.dp)) - Divider() + HorizontalDivider() Text(text = "查看类别", modifier = Modifier .clickable { menuSubItem = null @@ -219,7 +219,7 @@ fun SubsManagePage() { } .fillMaxWidth() .padding(16.dp)) - Divider() + HorizontalDivider() Text(text = "全局规则", modifier = Modifier .clickable { menuSubItem = null @@ -227,7 +227,7 @@ fun SubsManagePage() { } .fillMaxWidth() .padding(16.dp)) - Divider() + HorizontalDivider() } if (menuSubItemVal.id < 0 && subsRawVal != null) { Text(text = "分享文件", modifier = Modifier @@ -240,7 +240,7 @@ fun SubsManagePage() { } .fillMaxWidth() .padding(16.dp)) - Divider() + HorizontalDivider() } if (menuSubItemVal.updateUrl != null) { Text(text = "复制链接", modifier = Modifier @@ -251,7 +251,7 @@ fun SubsManagePage() { } .fillMaxWidth() .padding(16.dp)) - Divider() + HorizontalDivider() } if (subsRawVal?.supportUri != null) { Text(text = "问题反馈", modifier = Modifier @@ -265,7 +265,7 @@ fun SubsManagePage() { } .fillMaxWidth() .padding(16.dp)) - Divider() + HorizontalDivider() } if (menuSubItemVal.id != -2L) { Text(text = "删除订阅", modifier = Modifier diff --git a/app/src/main/kotlin/li/songe/gkd/util/Upgrade.kt b/app/src/main/kotlin/li/songe/gkd/util/Upgrade.kt index 3b650a964..fd7576868 100644 --- a/app/src/main/kotlin/li/songe/gkd/util/Upgrade.kt +++ b/app/src/main/kotlin/li/songe/gkd/util/Upgrade.kt @@ -147,7 +147,9 @@ fun UpgradeDialog() { AlertDialog( title = { Text(text = "下载新版本中") }, text = { - LinearProgressIndicator(progress = downloadStatusVal.progress) + LinearProgressIndicator( + progress = { downloadStatusVal.progress }, + ) }, onDismissRequest = {}, confirmButton = {