diff --git a/app/src/main/java/cc/ioctl/util/ui/dsl/RecyclerListViewController.kt b/app/src/main/java/cc/ioctl/util/ui/dsl/RecyclerListViewController.kt index 4c4c66016c..4122ff2b59 100644 --- a/app/src/main/java/cc/ioctl/util/ui/dsl/RecyclerListViewController.kt +++ b/app/src/main/java/cc/ioctl/util/ui/dsl/RecyclerListViewController.kt @@ -35,7 +35,7 @@ import io.github.qauxv.util.SyncUtils import io.github.qauxv.dsl.item.DslTMsgListItemInflatable import io.github.qauxv.dsl.item.TMsgListItem import io.github.qauxv.dsl.item.UiAgentItem -import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow class RecyclerListViewController( val context: Context, @@ -90,7 +90,7 @@ class RecyclerListViewController( for (i in itemList.indices) { val item = itemList[i] if (item is UiAgentItem) { - val valueStateFlow: MutableStateFlow? = item.agentProvider.uiItemAgent.valueState + val valueStateFlow: StateFlow? = item.agentProvider.uiItemAgent.valueState if (valueStateFlow != null) { lifecycleScope.launchWhenStarted { valueStateFlow.collect { diff --git a/app/src/main/java/io/github/qauxv/base/IUiItemAgent.kt b/app/src/main/java/io/github/qauxv/base/IUiItemAgent.kt index 18c1bea692..de91f0d6fb 100644 --- a/app/src/main/java/io/github/qauxv/base/IUiItemAgent.kt +++ b/app/src/main/java/io/github/qauxv/base/IUiItemAgent.kt @@ -25,7 +25,7 @@ package io.github.qauxv.base import android.app.Activity import android.content.Context import android.view.View -import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow /** * It's a single "cell" of the UI on the settings page. @@ -63,7 +63,7 @@ import kotlinx.coroutines.flow.MutableStateFlow interface IUiItemAgent { val titleProvider: (IUiItemAgent) -> String val summaryProvider: ((IUiItemAgent, Context) -> CharSequence?)? - val valueState: MutableStateFlow? + val valueState: StateFlow? val validator: ((IUiItemAgent) -> Boolean)? val switchProvider: ISwitchCellAgent? val onClickListener: ((IUiItemAgent, Activity, View) -> Unit)? diff --git a/app/src/main/java/io/github/qauxv/dsl/LegacyDslUiPreference.kt b/app/src/main/java/io/github/qauxv/dsl/LegacyDslUiPreference.kt index 225ab1fe15..46d57b3cc0 100644 --- a/app/src/main/java/io/github/qauxv/dsl/LegacyDslUiPreference.kt +++ b/app/src/main/java/io/github/qauxv/dsl/LegacyDslUiPreference.kt @@ -6,7 +6,7 @@ import android.view.View import io.github.qauxv.base.ISwitchCellAgent import io.github.qauxv.base.IUiItemAgent import io.github.qauxv.hook.BaseFunctionHook -import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow fun BaseFunctionHook.uiSwitchPreference(init: UiSwitchPreferenceItemFactory.() -> Unit): IUiItemAgent { val uiSwitchPreferenceFactory = UiSwitchPreferenceItemFactory(this) @@ -26,7 +26,7 @@ class UiSwitchPreferenceItemFactory(receiver: BaseFunctionHook) : IUiItemAgent { override val titleProvider: (IUiItemAgent) -> String = { title } override val summaryProvider: ((IUiItemAgent, Context) -> String?) = { _, _ -> summary } - override val valueState: MutableStateFlow? = null + override val valueState: StateFlow? = null override val validator: ((IUiItemAgent) -> Boolean) = { receiver.isAvailable } override val switchProvider: ISwitchCellAgent by lazy { object : ISwitchCellAgent { @@ -49,7 +49,7 @@ class UiClickableItemFactory(receiver: BaseFunctionHook) : IUiItemAgent { override val titleProvider: (IUiItemAgent) -> String = { title } override val summaryProvider: ((IUiItemAgent, Context) -> String?) = { _, _ -> summary } - override val valueState: MutableStateFlow? = null + override val valueState: StateFlow? = null override val validator: ((IUiItemAgent) -> Boolean) = { receiver.isAvailable } override val switchProvider: ISwitchCellAgent? = null override var onClickListener: ((IUiItemAgent, Activity, View) -> Unit)? = null diff --git a/app/src/main/java/io/github/qauxv/fragment/SettingsMainFragment.kt b/app/src/main/java/io/github/qauxv/fragment/SettingsMainFragment.kt index eac96dfc7b..c1ef488930 100644 --- a/app/src/main/java/io/github/qauxv/fragment/SettingsMainFragment.kt +++ b/app/src/main/java/io/github/qauxv/fragment/SettingsMainFragment.kt @@ -52,7 +52,7 @@ import io.github.qauxv.util.SyncUtils.async import io.github.qauxv.util.SyncUtils.runOnUiThread import io.github.qauxv.util.UiThread import io.github.qauxv.util.isInHostProcess -import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow import me.singleneuron.util.forSuBanXia class SettingsMainFragment : BaseRootLayoutFragment() { @@ -158,7 +158,7 @@ class SettingsMainFragment : BaseRootLayoutFragment() { for (i in itemList.indices) { val item = itemList[i] if (item is UiAgentItem) { - val valueStateFlow: MutableStateFlow? = item.agentProvider.uiItemAgent.valueState + val valueStateFlow: StateFlow? = item.agentProvider.uiItemAgent.valueState if (valueStateFlow != null) { lifecycleScope.launchWhenResumed { valueStateFlow.collect { diff --git a/app/src/main/java/io/github/qauxv/hook/BasePlainUiAgentItem.kt b/app/src/main/java/io/github/qauxv/hook/BasePlainUiAgentItem.kt index 490dc147d6..4383b2612f 100644 --- a/app/src/main/java/io/github/qauxv/hook/BasePlainUiAgentItem.kt +++ b/app/src/main/java/io/github/qauxv/hook/BasePlainUiAgentItem.kt @@ -26,7 +26,7 @@ import android.content.Context import io.github.qauxv.base.ISwitchCellAgent import io.github.qauxv.base.IUiItemAgent import io.github.qauxv.base.IUiItemAgentProvider -import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow /** * Just a button to be shown [IUiItemAgent] @@ -37,7 +37,7 @@ abstract class BasePlainUiAgentItem( ) : IUiItemAgent, IUiItemAgentProvider { override val titleProvider: (IUiItemAgent) -> String = { title } override val summaryProvider: ((IUiItemAgent, Context) -> CharSequence?) = { _, _ -> description } - override val valueState: MutableStateFlow? = null + override val valueState: StateFlow? = null override val validator: ((IUiItemAgent) -> Boolean)? = null override val switchProvider: ISwitchCellAgent? = null override val extraSearchKeywordProvider: ((IUiItemAgent, Context) -> Array?)? = null diff --git a/app/src/main/java/io/github/qauxv/hook/CommonConfigFunctionHook.kt b/app/src/main/java/io/github/qauxv/hook/CommonConfigFunctionHook.kt index c231a0e20f..77e43891b8 100644 --- a/app/src/main/java/io/github/qauxv/hook/CommonConfigFunctionHook.kt +++ b/app/src/main/java/io/github/qauxv/hook/CommonConfigFunctionHook.kt @@ -30,7 +30,7 @@ import io.github.qauxv.base.ISwitchCellAgent import io.github.qauxv.base.IUiItemAgent import io.github.qauxv.util.SyncUtils import io.github.qauxv.util.dexkit.DexKitTarget -import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow /** * A function that has a custom configuration UI. They usually do NOT have a switch. @@ -59,7 +59,7 @@ abstract class CommonConfigFunctionHook( * The current human-readable state of the function(optional). * Keep it as short as possible(e.g. "5 enabled", "disabled", no more than 10 characters). */ - abstract val valueState: MutableStateFlow? + abstract val valueState: StateFlow? /** * Called when the function UI item is clicked. @@ -83,7 +83,7 @@ abstract class CommonConfigFunctionHook( pangu_spacing(description.toString()) else description } - override val valueState: MutableStateFlow? + override val valueState: StateFlow? get() = this@CommonConfigFunctionHook.valueState override val validator: ((IUiItemAgent) -> Boolean) = { _ -> true } override val switchProvider: ISwitchCellAgent? = null diff --git a/app/src/main/java/io/github/qauxv/hook/CommonSwitchFunctionHook.kt b/app/src/main/java/io/github/qauxv/hook/CommonSwitchFunctionHook.kt index 776c0f5aea..35fc62798d 100644 --- a/app/src/main/java/io/github/qauxv/hook/CommonSwitchFunctionHook.kt +++ b/app/src/main/java/io/github/qauxv/hook/CommonSwitchFunctionHook.kt @@ -30,7 +30,7 @@ import io.github.qauxv.base.ISwitchCellAgent import io.github.qauxv.base.IUiItemAgent import io.github.qauxv.util.SyncUtils import io.github.qauxv.util.dexkit.DexKitTarget -import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow /** * A function that only has a enable/disable switch function. @@ -74,7 +74,7 @@ abstract class CommonSwitchFunctionHook( pangu_spacing(description.toString()) else description } - override val valueState: MutableStateFlow? = null + override val valueState: StateFlow? = null override val validator: ((IUiItemAgent) -> Boolean) = { _ -> true } override val switchProvider: ISwitchCellAgent? by lazy { object : ISwitchCellAgent { diff --git a/app/src/main/java/io/github/qauxv/router/decorator/BaseSwitchFunctionDecorator.kt b/app/src/main/java/io/github/qauxv/router/decorator/BaseSwitchFunctionDecorator.kt index 2c6f9840d1..c3306b0aab 100644 --- a/app/src/main/java/io/github/qauxv/router/decorator/BaseSwitchFunctionDecorator.kt +++ b/app/src/main/java/io/github/qauxv/router/decorator/BaseSwitchFunctionDecorator.kt @@ -28,7 +28,7 @@ import android.view.View import io.github.qauxv.base.ISwitchCellAgent import io.github.qauxv.base.IUiItemAgent import io.github.qauxv.util.dexkit.DexKitTarget -import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow abstract class BaseSwitchFunctionDecorator( hookKey: String? = null, @@ -53,7 +53,7 @@ abstract class BaseSwitchFunctionDecorator( private fun uiItemAgent() = object : IUiItemAgent { override val titleProvider: (IUiItemAgent) -> String = { _ -> name } override val summaryProvider: (IUiItemAgent, Context) -> CharSequence? = { _, _ -> description } - override val valueState: MutableStateFlow? = null + override val valueState: StateFlow? = null override val validator: ((IUiItemAgent) -> Boolean) = { _ -> true } override val switchProvider: ISwitchCellAgent? by lazy { object : ISwitchCellAgent {