Skip to content

Commit 766aa4f

Browse files
committed
pref: rm useless code
1 parent 16e9308 commit 766aa4f

File tree

14 files changed

+58
-67
lines changed

14 files changed

+58
-67
lines changed

app/src/main/kotlin/li/songe/gkd/store/SettingsStore.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@ data class SettingsStore(
3333
val useSystemToast: Boolean = false,
3434
val useCustomNotifText: Boolean = false,
3535
val customNotifTitle: String = META.appName,
36-
val customNotifText: String = $$"${i}全局/${k}应用/${u}规则组/${n}触发",
36+
val customNotifText: String = $$"${i}全局/${k}应用/${u}规则/${n}触发",
3737
val updateChannel: Int = if (META.isBeta) UpdateChannelOption.Beta.value else UpdateChannelOption.Stable.value,
3838
val appSort: Int = AppSortOption.ByUsedTime.value,
3939
val showBlockApp: Boolean = true,
4040
val appRuleSort: Int = RuleSortOption.ByDefault.value,
4141
val subsAppSort: Int = AppSortOption.ByUsedTime.value,
42+
val subsCategorySort: Int = AppSortOption.ByUsedTime.value,
4243
val subsAppShowUninstall: Boolean = false,
4344
val subsAppGroupType: Int = AppGroupOption.UserGroup.value or AppGroupOption.SystemGroup.value,
45+
val subsCategoryGroupType: Int = AppGroupOption.UserGroup.value or AppGroupOption.SystemGroup.value,
4446
val subsAppShowBlock: Boolean = false,
47+
val subsCategoryShowBlock: Boolean = false,
4548
val subsExcludeSort: Int = AppSortOption.ByUsedTime.value,
4649
val subsExcludeShowBlockApp: Boolean = true,
4750
val subsExcludeShowInnerDisabledApp: Boolean = true,

app/src/main/kotlin/li/songe/gkd/ui/ImagePreviewPage.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import androidx.compose.ui.unit.dp
3939
import androidx.compose.ui.zIndex
4040
import androidx.core.view.WindowCompat
4141
import androidx.core.view.WindowInsetsCompat
42+
import androidx.core.view.WindowInsetsControllerCompat
4243
import androidx.navigation3.runtime.NavKey
4344
import coil3.ImageLoader
4445
import coil3.compose.AsyncImagePainter
@@ -81,8 +82,12 @@ fun ImagePreviewPage(route: ImagePreviewRoute) {
8182
val context = LocalActivity.current as MainActivity
8283
DisposableEffect(null) {
8384
val controller = WindowCompat.getInsetsController(context.window, context.window.decorView)
85+
val oldBehavior = controller.systemBarsBehavior
86+
controller.systemBarsBehavior =
87+
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
8488
controller.hide(WindowInsetsCompat.Type.statusBars())
8589
onDispose {
90+
controller.systemBarsBehavior = oldBehavior
8691
controller.show(WindowInsetsCompat.Type.statusBars())
8792
}
8893
}
@@ -115,7 +120,7 @@ fun ImagePreviewPage(route: ImagePreviewRoute) {
115120
color = Color.Black.copy(alpha = 0.7f),
116121
blurRadius = with(LocalDensity.current) { 2.dp.toPx() },
117122
offset = with(LocalDensity.current) {
118-
Offset( 1.dp.toPx(), 1.dp.toPx() )
123+
Offset(1.dp.toPx(), 1.dp.toPx())
119124
}
120125
)
121126
)

app/src/main/kotlin/li/songe/gkd/ui/UpsertRuleGroupPage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fun UpsertRuleGroupPage(route: UpsertRuleGroupRoute) {
105105
PerfIconButton(imageVector = PerfIcon.ArrowBack, onClick = checkIfSaveText)
106106
},
107107
title = {
108-
Text(text = if (vm.isEdit) "编辑规则组" else "添加规则组")
108+
Text(text = if (vm.isEdit) "编辑规则" else "添加规则")
109109
},
110110
actions = {
111111
PerfIconButton(
@@ -147,7 +147,7 @@ fun UpsertRuleGroupPage(route: UpsertRuleGroupRoute) {
147147
colors = textColors,
148148
visualTransformation = getJson5Transformation(LocalDarkTheme.current),
149149
placeholder = {
150-
Text(text = if (vm.isApp) "请输入应用规则组\n" else "请输入全局规则组\n")
150+
Text(text = if (vm.isApp) "请输入应用规则\n" else "请输入全局规则\n")
151151
},
152152
)
153153
}

app/src/main/kotlin/li/songe/gkd/ui/UpsertRuleGroupVm.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class UpsertRuleGroupVm(val route: UpsertRuleGroupRoute) : ViewModel() {
8181
}
8282
RawSubscription.parseApp(jsonObject).let { newApp ->
8383
if (newApp.groups.isEmpty()) {
84-
error("至少输入一个规则组")
84+
error("至少输入一个规则")
8585
}
8686
newApp.groups.first()
8787
}
@@ -97,7 +97,7 @@ class UpsertRuleGroupVm(val route: UpsertRuleGroupRoute) : ViewModel() {
9797
}
9898
newGroup.errorDesc?.let(::error)
9999
if (newGroup.key != groupKey) {
100-
error("不能更改规则组的key")
100+
error("不能更改规则的key")
101101
}
102102
val newSubs = if (appId != null) {
103103
newGroup as RawSubscription.RawAppGroup
@@ -125,7 +125,7 @@ class UpsertRuleGroupVm(val route: UpsertRuleGroupRoute) : ViewModel() {
125125
val newApp = try {
126126
RawSubscription.parseApp(jsonObject).apply {
127127
if (groups.isEmpty()) {
128-
error("至少输入一个规则组")
128+
error("至少输入一个规则")
129129
}
130130
}
131131
} catch (e: Exception) {
@@ -161,7 +161,7 @@ class UpsertRuleGroupVm(val route: UpsertRuleGroupRoute) : ViewModel() {
161161
}
162162
RawSubscription.parseApp(jsonObject).apply {
163163
if (groups.isEmpty()) {
164-
error("至少输入一个规则组")
164+
error("至少输入一个规则")
165165
}
166166
}.groups
167167
} else {
@@ -222,9 +222,9 @@ private fun checkGroupKeyName(
222222
newGroup: RawSubscription.RawGroupProps
223223
) {
224224
if (groups.any { it.name == newGroup.name }) {
225-
error("已存在同名「${newGroup.name}规则组")
225+
error("已存在同名「${newGroup.name}规则")
226226
}
227227
if (groups.any { it.key == newGroup.key }) {
228-
error("已存在同 key=${newGroup.key} 规则组")
228+
error("已存在同 key=${newGroup.key} 规则")
229229
}
230230
}

app/src/main/kotlin/li/songe/gkd/ui/component/SubsSheet.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fun SubsSheet(
193193
if (subscription.globalGroups.isNotEmpty() || subsItem.isLocal) {
194194
Row(
195195
modifier = Modifier
196-
.clickable(onClickLabel = "查看全局规则组列表", onClick = throttle {
196+
.clickable(onClickLabel = "查看全局规则列表", onClick = throttle {
197197
setSubsId(null)
198198
sheetSubsIdFlow.value = null
199199
mainVm.navigatePage(SubsGlobalGroupListRoute(subsItem.id))
@@ -210,7 +210,7 @@ fun SubsSheet(
210210
style = MaterialTheme.typography.labelLarge,
211211
)
212212
Text(
213-
text = if (subscription.globalGroups.isNotEmpty()) "${subscription.globalGroups.size} 全局规则组" else "暂无",
213+
text = if (subscription.globalGroups.isNotEmpty()) "${subscription.globalGroups.size} 全局规则" else "暂无",
214214
style = MaterialTheme.typography.labelMedium,
215215
color = MaterialTheme.colorScheme.onSurfaceVariant.let {
216216
if (subscription.globalGroups.isEmpty()) {
@@ -229,7 +229,7 @@ fun SubsSheet(
229229
if (subscription.appGroups.isNotEmpty() || subsItem.isLocal) {
230230
Row(
231231
modifier = Modifier
232-
.clickable(onClickLabel = "查看应用规则组列表", onClick = throttle {
232+
.clickable(onClickLabel = "查看应用规则列表", onClick = throttle {
233233
setSubsId(null)
234234
sheetSubsIdFlow.value = null
235235
mainVm.navigatePage(SubsAppListRoute(subsItem.id))
@@ -246,7 +246,7 @@ fun SubsSheet(
246246
style = MaterialTheme.typography.labelLarge,
247247
)
248248
Text(
249-
text = if (subscription.appGroups.isNotEmpty()) "${subscription.apps.size} 应用 ${subscription.appGroups.size} 规则组" else "暂无",
249+
text = if (subscription.appGroups.isNotEmpty()) "${subscription.apps.size} 应用 ${subscription.appGroups.size} 规则" else "暂无",
250250
style = MaterialTheme.typography.labelMedium,
251251
color = MaterialTheme.colorScheme.onSurfaceVariant.let {
252252
if (subscription.appGroups.isEmpty()) {

app/src/main/kotlin/li/songe/gkd/ui/component/TooltipIconButtonBox.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import androidx.compose.material3.TooltipBox
77
import androidx.compose.material3.TooltipDefaults
88
import androidx.compose.material3.rememberTooltipState
99
import androidx.compose.runtime.Composable
10-
import androidx.compose.runtime.collectAsState
1110
import li.songe.gkd.ui.share.LocalIsTalkbackEnabled
1211

1312
@Composable
1413
fun TooltipIconButtonBox(contentDescription: String?, content: @Composable () -> Unit) {
1514
// 视障用户使用 TalkBack 朗读 contentDescription,不需要 Tooltip
16-
if (contentDescription.isNullOrEmpty() || LocalIsTalkbackEnabled.current.collectAsState().value) {
15+
if (contentDescription.isNullOrEmpty() || LocalIsTalkbackEnabled.current) {
1716
content()
1817
} else {
1918
TooltipBox(

app/src/main/kotlin/li/songe/gkd/ui/home/AppListPage.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import androidx.compose.runtime.getValue
3333
import androidx.compose.runtime.mutableIntStateOf
3434
import androidx.compose.runtime.mutableStateOf
3535
import androidx.compose.runtime.remember
36-
import androidx.compose.runtime.saveable.LocalSaveableStateRegistry
3736
import androidx.compose.runtime.saveable.rememberSaveable
3837
import androidx.compose.runtime.setValue
3938
import androidx.compose.ui.Alignment
@@ -81,7 +80,6 @@ import li.songe.gkd.ui.style.EmptyHeight
8180
import li.songe.gkd.ui.style.appItemPadding
8281
import li.songe.gkd.util.AppGroupOption
8382
import li.songe.gkd.util.AppSortOption
84-
import li.songe.gkd.util.LogUtils
8583
import li.songe.gkd.util.appListAuthAbnormalFlow
8684
import li.songe.gkd.util.getUpDownTransform
8785
import li.songe.gkd.util.ruleSummaryFlow
@@ -109,10 +107,6 @@ fun useAppListPage(): ScaffoldExt {
109107
val refreshing by updateAppMutex.state.collectAsState()
110108
val pullToRefreshState = rememberPullToRefreshState()
111109
val editWhiteListMode by vm.editWhiteListModeFlow.collectAsState()
112-
val savedStateRegistry = LocalSaveableStateRegistry.current
113-
if (savedStateRegistry != null) {
114-
LogUtils.d(savedStateRegistry.performSave())
115-
}
116110
val scrollKey = rememberSaveable { mutableIntStateOf(0) }
117111
val (scrollBehavior, listState) = useListScrollState(scrollKey)
118112
LaunchedEffect(null) {

app/src/main/kotlin/li/songe/gkd/ui/home/SettingsPage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ fun useSettingsPage(): ScaffoldExt {
133133
}
134134
mainVm.dialogFlow.updateDialogOptions(
135135
title = "文案规则",
136-
text = $$"触发文案支持变量替换,规则如下\n${1} 子规则名称\n${2} 规则组名称\n${3} 触发次数\n\n示例模板\n${1}/${2}/${3}\n\n替换结果\n子规则a/规则组A/3",
136+
text = $$"触发文案支持变量替换,规则如下\n${1} 子规则名称\n${2} 规则名称\n${3} 触发次数\n\n示例模板\n${1}/${2}/${3}\n\n替换结果\n子规则a/规则A/3",
137137
confirmAction = confirmAction,
138138
onDismissRequest = confirmAction,
139139
)
@@ -207,7 +207,7 @@ fun useSettingsPage(): ScaffoldExt {
207207
}
208208
mainVm.dialogFlow.updateDialogOptions(
209209
title = "文案规则",
210-
text = $$"通知文案支持变量替换,规则如下\n${i} 全局规则数\n${k} 应用数\n${u} 应用规则组数\n${n} 触发次数\n\n示例模板\n${i}全局/${k}应用/${u}规则组/${n}触发\n\n替换结果\n0全局/1应用/2规则组/3触发",
210+
text = $$"通知文案支持变量替换,规则如下\n${i} 全局规则数\n${k} 应用数\n${u} 应用规则数\n${n} 触发次数\n\n示例模板\n${i}全局/${k}应用/${u}规则/${n}触发\n\n替换结果\n0全局/1应用/2规则/3触发",
211211
confirmAction = confirmAction,
212212
onDismissRequest = confirmAction,
213213
)
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package li.songe.gkd.ui.share
22

3-
import androidx.compose.runtime.compositionLocalOf
4-
import kotlinx.coroutines.flow.MutableStateFlow
5-
import kotlinx.coroutines.flow.StateFlow
3+
import androidx.compose.runtime.staticCompositionLocalOf
64
import li.songe.gkd.MainViewModel
75

8-
val LocalMainViewModel = compositionLocalOf<MainViewModel> {
6+
val LocalMainViewModel = staticCompositionLocalOf<MainViewModel> {
97
error("not found MainViewModel")
108
}
119

12-
val LocalDarkTheme = compositionLocalOf { false }
10+
val LocalDarkTheme = staticCompositionLocalOf { false }
1311

14-
val LocalIsTalkbackEnabled = compositionLocalOf<StateFlow<Boolean>> {
15-
MutableStateFlow(false)
12+
val LocalIsTalkbackEnabled = staticCompositionLocalOf {
13+
false
1614
}

app/src/main/kotlin/li/songe/gkd/ui/style/Theme.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ import androidx.compose.runtime.DisposableEffect
1717
import androidx.compose.runtime.LaunchedEffect
1818
import androidx.compose.runtime.collectAsState
1919
import androidx.compose.runtime.getValue
20+
import androidx.compose.runtime.mutableStateOf
2021
import androidx.compose.runtime.remember
2122
import androidx.compose.runtime.rememberCoroutineScope
23+
import androidx.compose.runtime.setValue
2224
import androidx.compose.ui.graphics.Color
2325
import androidx.compose.ui.graphics.toArgb
2426
import androidx.core.view.WindowInsetsControllerCompat
25-
import kotlinx.coroutines.flow.MutableStateFlow
2627
import kotlinx.coroutines.flow.SharingStarted
2728
import kotlinx.coroutines.flow.debounce
2829
import kotlinx.coroutines.flow.map
@@ -79,12 +80,10 @@ fun AppTheme(
7980
}
8081
}
8182

82-
val isTalkbackEnabledFlow = remember {
83-
MutableStateFlow(app.a11yManager.isTouchExplorationEnabled)
84-
}
83+
var isTalkbackEnabled by remember { mutableStateOf(app.a11yManager.isTouchExplorationEnabled) }
8584
DisposableEffect(null) {
8685
val listener = AccessibilityManager.TouchExplorationStateChangeListener {
87-
isTalkbackEnabledFlow.value = it
86+
isTalkbackEnabled = it
8887
}
8988
app.a11yManager.addTouchExplorationStateChangeListener(listener)
9089
onDispose {
@@ -93,7 +92,7 @@ fun AppTheme(
9392
}
9493
CompositionLocalProvider(
9594
LocalDarkTheme provides darkTheme,
96-
LocalIsTalkbackEnabled provides isTalkbackEnabledFlow
95+
LocalIsTalkbackEnabled provides isTalkbackEnabled
9796
) {
9897
MaterialTheme(
9998
colorScheme = colorScheme.animation(),

0 commit comments

Comments
 (0)