Skip to content

Commit

Permalink
perf: 移除 matchLauncher 字段
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Nov 14, 2023
1 parent a66cc44 commit 81d9f52
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 19 deletions.
9 changes: 1 addition & 8 deletions app/src/main/java/li/songe/gkd/data/Rule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ data class Rule(
val excludeMatches: List<Selector> = emptyList(),
val actionCd: Long = defaultMiniCd,
val actionDelay: Long = 0,
val matchLauncher: Boolean = false,
val quickFind: Boolean = false,

val matchDelay: Long?,
Expand Down Expand Up @@ -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

Expand Down
7 changes: 0 additions & 7 deletions app/src/main/java/li/songe/gkd/data/SubscriptionRaw.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ data class SubscriptionRaw(
val excludeActivityIds: List<String>?
val actionCd: Long?
val actionDelay: Long?
val matchLauncher: Boolean?
val quickFind: Boolean?
val matchDelay: Long?
val matchTime: Long?
Expand All @@ -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?,
Expand All @@ -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?,
Expand Down Expand Up @@ -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?,
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/java/li/songe/gkd/util/SubsState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -108,7 +105,6 @@ val appIdToRulesFlow by lazy {

groupRuleList.add(
Rule(
matchLauncher = matchLauncher,
quickFind = quickFind,
actionCd = actionCd,
actionDelay = actionDelay,
Expand Down

0 comments on commit 81d9f52

Please sign in to comment.