@@ -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
|
||||
|
||||
Reference in New Issue
Block a user