mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 14:57:47 +01:00
Fix forced secure screen disabled after disabling incognito (#5634)
This commit is contained in:
parent
40aa3b7e18
commit
bcaa9674fe
2 changed files with 7 additions and 15 deletions
|
@ -3,16 +3,10 @@ package eu.kanade.tachiyomi.ui.base.activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
import eu.kanade.tachiyomi.util.view.setSecureScreen
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import uy.kohesive.injekt.Injekt
|
|
||||||
import uy.kohesive.injekt.api.get
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
abstract class BaseThemedActivity : AppCompatActivity() {
|
abstract class BaseThemedActivity : AppCompatActivity() {
|
||||||
|
@ -25,13 +19,6 @@ abstract class BaseThemedActivity : AppCompatActivity() {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
applyAppTheme(preferences)
|
applyAppTheme(preferences)
|
||||||
|
|
||||||
Injekt.get<PreferencesHelper>().incognitoMode()
|
|
||||||
.asImmediateFlow {
|
|
||||||
window.setSecureScreen(it)
|
|
||||||
}
|
|
||||||
.launchIn(lifecycleScope)
|
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import androidx.lifecycle.lifecycleScope
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
|
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
|
||||||
import eu.kanade.tachiyomi.util.view.setSecureScreen
|
import eu.kanade.tachiyomi.util.view.setSecureScreen
|
||||||
|
import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
@ -16,8 +17,12 @@ class SecureActivityDelegate(private val activity: FragmentActivity) {
|
||||||
private val preferences: PreferencesHelper by injectLazy()
|
private val preferences: PreferencesHelper by injectLazy()
|
||||||
|
|
||||||
fun onCreate() {
|
fun onCreate() {
|
||||||
preferences.secureScreen().asFlow()
|
val secureScreenFlow = preferences.secureScreen().asFlow()
|
||||||
.onEach { activity.window.setSecureScreen(it || preferences.incognitoMode().get()) }
|
val incognitoModeFlow = preferences.incognitoMode().asFlow()
|
||||||
|
secureScreenFlow.combine(incognitoModeFlow) { secureScreen, incognitoMode ->
|
||||||
|
secureScreen || incognitoMode
|
||||||
|
}
|
||||||
|
.onEach { activity.window.setSecureScreen(it) }
|
||||||
.launchIn(activity.lifecycleScope)
|
.launchIn(activity.lifecycleScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue