Derive states from MainActivity alias enabled (#703)

This commit is contained in:
Zongle Wang
2026-04-10 16:41:17 +08:00
committed by GitHub
parent 8453bfc07d
commit 37b8ba6d5c
4 changed files with 17 additions and 12 deletions

View File

@@ -1,6 +1,8 @@
package com.github.kr328.clash.design.store
import android.content.ComponentName
import android.content.Context
import android.content.pm.PackageManager
import com.github.kr328.clash.common.store.Store
import com.github.kr328.clash.common.store.asStoreProvider
import com.github.kr328.clash.core.model.ProxySort
@@ -27,7 +29,11 @@ class UiStore(context: Context) {
var hideAppIcon: Boolean by store.boolean(
key = "hide_app_icon",
defaultValue = false
defaultValue = context.packageManager.getComponentEnabledSetting(context.mainActivityAlias)
.let { state ->
state != PackageManager.COMPONENT_ENABLED_STATE_ENABLED &&
state != PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
},
)
var hideFromRecents: Boolean by store.boolean(
@@ -74,5 +80,8 @@ class UiStore(context: Context) {
companion object {
private const val PREFERENCE_NAME = "ui"
val Context.mainActivityAlias: ComponentName
get() = ComponentName(this, "com.github.kr328.clash.MainActivityAlias")
}
}