mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
Derive states from MainActivity alias enabled (#703)
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user