diff --git a/app/src/main/kotlin/li/songe/gkd/data/RawSubscription.kt b/app/src/main/kotlin/li/songe/gkd/data/RawSubscription.kt index d5baa183b..9b7012a4b 100644 --- a/app/src/main/kotlin/li/songe/gkd/data/RawSubscription.kt +++ b/app/src/main/kotlin/li/songe/gkd/data/RawSubscription.kt @@ -57,8 +57,27 @@ data class RawSubscription( } @IgnoredOnParcel - val allGroupSize by lazy { - globalGroups.size + appGroups.size + val numText by lazy { + val appsSize = apps.size + val appGroupsSize = appGroups.size + val globalGroupSize = globalGroups.size + if (appGroupsSize + globalGroupSize > 0) { + if (globalGroupSize > 0) { + "${globalGroupSize}全局" + if (appGroupsSize > 0) { + "/" + } else { + "" + } + } else { + "" + } + if (appGroupsSize > 0) { + "${appsSize}应用/${appGroupsSize}规则组" + } else { + "" + } + } else { + "暂无规则" + } } @Serializable diff --git a/app/src/main/kotlin/li/songe/gkd/service/ManageService.kt b/app/src/main/kotlin/li/songe/gkd/service/ManageService.kt index c9c050ed1..5985b6231 100644 --- a/app/src/main/kotlin/li/songe/gkd/service/ManageService.kt +++ b/app/src/main/kotlin/li/songe/gkd/service/ManageService.kt @@ -33,15 +33,11 @@ class ManageService : CompositionService({ ) { allRules, clickCount, enableService, abRunning -> if (!abRunning) return@combine "无障碍未授权" if (!enableService) return@combine "服务已暂停" - (if (allRules.allGroupSize > 0) { - if (allRules.appSize > 0) { - "${allRules.appSize}应用/${allRules.allGroupSize}规则组" - } else { - "${allRules.allGroupSize}规则组" - } + allRules.numText + if (clickCount > 0) { + "/${clickCount}点击" } else { - "暂无规则" - }) + if (clickCount > 0) "/${clickCount}点击" else "" + "" + } }.stateIn(scope, SharingStarted.Eagerly, "").collect { text -> createNotif( context, defaultChannel.id, abNotif.copy( diff --git a/app/src/main/kotlin/li/songe/gkd/ui/ControlVm.kt b/app/src/main/kotlin/li/songe/gkd/ui/ControlVm.kt index ece5126e1..64d6fefcd 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/ControlVm.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/ControlVm.kt @@ -38,15 +38,11 @@ class ControlVm @Inject constructor() : ViewModel() { }.stateIn(viewModelScope, SharingStarted.Eagerly, null) val subsStatusFlow = combine(allRulesFlow, clickCountFlow) { allRules, clickCount -> - (if (allRules.allGroupSize > 0) { - if (allRules.appSize > 0) { - "${allRules.appSize}应用/${allRules.allGroupSize}规则组" - } else { - "${allRules.allGroupSize}规则组" - } + allRules.numText + if (clickCount > 0) { + "/${clickCount}点击" } else { - "暂无规则" - }) + if (clickCount > 0) "/${clickCount}点击" else "" + "" + } }.stateIn(viewModelScope, SharingStarted.Eagerly, "") } \ No newline at end of file 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 b99842869..7bf945c3c 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/SettingsPage.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/SettingsPage.kt @@ -113,7 +113,7 @@ fun SettingsPage() { Divider() TextSwitch(name = "前台悬浮窗", - desc = "添加前台透明悬浮窗,关闭可能导致不点击/点击缓慢", + desc = "添加透明悬浮窗,关闭可能导致不点击/点击缓慢", checked = store.enableAbFloatWindow, onCheckedChange = { updateStorage( diff --git a/app/src/main/kotlin/li/songe/gkd/ui/component/SubsItemCard.kt b/app/src/main/kotlin/li/songe/gkd/ui/component/SubsItemCard.kt index 34148d5d5..1d550407c 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/component/SubsItemCard.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/component/SubsItemCard.kt @@ -76,19 +76,9 @@ fun SubsItemCard( ) Spacer(modifier = Modifier.width(10.dp)) } - val apps = rawSubscription.apps - val groupsSize = rawSubscription.allGroupSize - val ruleNumText = if (groupsSize > 0) { - if (apps.isNotEmpty()) { - "${apps.size}应用/${groupsSize}规则组" - } else { - "${groupsSize}规则组" - } - } else { - "暂无规则" - } + Text( - text = ruleNumText, + text = rawSubscription.numText, fontSize = 14.sp ) } diff --git a/app/src/main/kotlin/li/songe/gkd/util/SubsState.kt b/app/src/main/kotlin/li/songe/gkd/util/SubsState.kt index 387bb8cd0..c6bcdb304 100644 --- a/app/src/main/kotlin/li/songe/gkd/util/SubsState.kt +++ b/app/src/main/kotlin/li/songe/gkd/util/SubsState.kt @@ -97,8 +97,26 @@ data class AllRules( val appIdToRules: Map> = emptyMap(), val appIdToGroups: Map> = emptyMap(), ) { - val appSize = appIdToRules.keys.size - val allGroupSize = globalGroups.size + appIdToGroups.values.sumOf { s -> s.size } + private val appSize = appIdToRules.keys.size + private val appGroupSize = appIdToGroups.values.sumOf { s -> s.size } + + val numText = if (globalGroups.size + appGroupSize > 0) { + if (globalGroups.isNotEmpty()) { + "${globalGroups.size}全局" + if (appGroupSize > 0) { + "/" + } else { + "" + } + } else { + "" + } + if (appGroupSize > 0) { + "${appSize}应用/${appGroupSize}规则组" + } else { + "" + } + } else { + "暂无规则" + } } val allRulesFlow by lazy {