From 81d9f52a2e868dc90a043e93c2453e55b484b704 Mon Sep 17 00:00:00 2001 From: lisonge Date: Tue, 14 Nov 2023 20:07:19 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=A7=BB=E9=99=A4=20matchLauncher=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/li/songe/gkd/data/Rule.kt | 9 +-------- app/src/main/java/li/songe/gkd/data/SubscriptionRaw.kt | 7 ------- app/src/main/java/li/songe/gkd/util/SubsState.kt | 4 ---- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/app/src/main/java/li/songe/gkd/data/Rule.kt b/app/src/main/java/li/songe/gkd/data/Rule.kt index bde68a0f1..6d250bdfe 100644 --- a/app/src/main/java/li/songe/gkd/data/Rule.kt +++ b/app/src/main/java/li/songe/gkd/data/Rule.kt @@ -22,7 +22,6 @@ data class Rule( val excludeMatches: List = emptyList(), val actionCd: Long = defaultMiniCd, val actionDelay: Long = 0, - val matchLauncher: Boolean = false, val quickFind: Boolean = false, val matchDelay: Long?, @@ -104,13 +103,7 @@ data class Rule( private val matchAnyActivity = activityIds.isEmpty() && excludeActivityIds.isEmpty() fun matchActivityId(activityId: String?): Boolean { - if (matchAnyActivity) return true - if (activityId == null) { - if (matchLauncher) { - return true - } - return false - } + if (matchAnyActivity || activityId == null) return true if (excludeActivityIds.any { activityId.startsWith(it) }) return false if (activityIds.isEmpty()) return true diff --git a/app/src/main/java/li/songe/gkd/data/SubscriptionRaw.kt b/app/src/main/java/li/songe/gkd/data/SubscriptionRaw.kt index 4c75c17e6..5c3ea1dd3 100644 --- a/app/src/main/java/li/songe/gkd/data/SubscriptionRaw.kt +++ b/app/src/main/java/li/songe/gkd/data/SubscriptionRaw.kt @@ -25,7 +25,6 @@ data class SubscriptionRaw( val excludeActivityIds: List? val actionCd: Long? val actionDelay: Long? - val matchLauncher: Boolean? val quickFind: Boolean? val matchDelay: Long? val matchTime: Long? @@ -39,7 +38,6 @@ data class SubscriptionRaw( val name: String?, override val actionCd: Long?, override val actionDelay: Long?, - override val matchLauncher: Boolean?, override val quickFind: Boolean?, override val actionMaximum: Int?, override val matchDelay: Long?, @@ -58,7 +56,6 @@ data class SubscriptionRaw( val enable: Boolean?, override val actionCd: Long?, override val actionDelay: Long?, - override val matchLauncher: Boolean?, override val quickFind: Boolean?, override val actionMaximum: Int?, override val matchDelay: Long?, @@ -106,7 +103,6 @@ data class SubscriptionRaw( val action: String?, override val actionCd: Long?, override val actionDelay: Long?, - override val matchLauncher: Boolean?, override val quickFind: Boolean?, override val actionMaximum: Int?, override val matchDelay: Long?, @@ -218,7 +214,6 @@ data class SubscriptionRaw( name = getString(rulesJson, "name"), preKeys = getIntIArray(rulesJson, "preKeys"), action = getString(rulesJson, "action"), - matchLauncher = getBoolean(rulesJson, "matchLauncher"), quickFind = getBoolean(rulesJson, "quickFind"), actionMaximum = getInt(rulesJson, "actionMaximum"), matchDelay = getLong(rulesJson, "matchDelay"), @@ -252,7 +247,6 @@ data class SubscriptionRaw( }.map { jsonToRuleRaw(it) }, - matchLauncher = getBoolean(groupsJson, "matchLauncher"), quickFind = getBoolean(groupsJson, "quickFind"), actionMaximum = getInt(groupsJson, "actionMaximum"), matchDelay = getLong(groupsJson, "matchDelay"), @@ -278,7 +272,6 @@ data class SubscriptionRaw( }).mapIndexed { index, jsonElement -> jsonToGroupRaw(jsonElement, index) }, - matchLauncher = getBoolean(appsJson, "matchLauncher"), quickFind = getBoolean(appsJson, "quickFind"), actionMaximum = getInt(appsJson, "actionMaximum"), matchDelay = getLong(appsJson, "matchDelay"), diff --git a/app/src/main/java/li/songe/gkd/util/SubsState.kt b/app/src/main/java/li/songe/gkd/util/SubsState.kt index 98590164e..4d2089e7c 100644 --- a/app/src/main/java/li/songe/gkd/util/SubsState.kt +++ b/app/src/main/java/li/songe/gkd/util/SubsState.kt @@ -86,9 +86,6 @@ val appIdToRulesFlow by lazy { } }.toSet() - val matchLauncher = - ruleRaw.matchLauncher ?: groupRaw.matchLauncher ?: appRaw.matchLauncher - ?: false val quickFind = ruleRaw.quickFind ?: groupRaw.quickFind ?: appRaw.quickFind ?: false @@ -108,7 +105,6 @@ val appIdToRulesFlow by lazy { groupRuleList.add( Rule( - matchLauncher = matchLauncher, quickFind = quickFind, actionCd = actionCd, actionDelay = actionDelay,