Migrate to Metro DI (#3608)

Assisted-by: Claude:claude-opus-5
This commit is contained in:
AntsyLich
2026-08-17 00:47:48 +06:00
committed by GitHub
parent 1e5b1dc5e7
commit b2015d1ef3
314 changed files with 2416 additions and 2010 deletions
@@ -14,8 +14,7 @@ import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import mihon.app.di.appGraph
/**
* A custom [TextInputEditText] that sets [EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING] to imeOptions
@@ -34,7 +33,8 @@ class TachiyomiTextInputEditText @JvmOverloads constructor(
override fun onAttachedToWindow() {
super.onAttachedToWindow()
scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
setIncognito(scope!!)
val basePreferences = context.appGraph.basePreferences
setIncognito(basePreferences, scope!!)
}
override fun onDetachedFromWindow() {
@@ -48,8 +48,8 @@ class TachiyomiTextInputEditText @JvmOverloads constructor(
* Sets Flow to this [EditText] that sets [EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING] to imeOptions
* if [BasePreferences.incognitoMode] is true. Some IMEs may not respect this flag.
*/
fun EditText.setIncognito(viewScope: CoroutineScope) {
Injekt.get<BasePreferences>().incognitoMode.changes()
fun EditText.setIncognito(basePreferences: BasePreferences, viewScope: CoroutineScope) {
basePreferences.incognitoMode.changes()
.onEach {
imeOptions = if (it) {
imeOptions or EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING