From bcaa9674fe8e6a380630369d2f29f45d59ef5911 Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Fri, 6 Aug 2021 04:52:20 +0700 Subject: [PATCH] Fix forced secure screen disabled after disabling incognito (#5634) --- .../ui/base/activity/BaseThemedActivity.kt | 13 ------------- .../tachiyomi/ui/security/SecureActivityDelegate.kt | 9 +++++++-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt index e32b734a70..20cc552902 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt @@ -3,16 +3,10 @@ package eu.kanade.tachiyomi.ui.base.activity import android.content.Context import android.os.Bundle import androidx.appcompat.app.AppCompatActivity -import androidx.lifecycle.lifecycleScope import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferenceValues 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.view.setSecureScreen -import kotlinx.coroutines.flow.launchIn -import uy.kohesive.injekt.Injekt -import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy abstract class BaseThemedActivity : AppCompatActivity() { @@ -25,13 +19,6 @@ abstract class BaseThemedActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { applyAppTheme(preferences) - - Injekt.get().incognitoMode() - .asImmediateFlow { - window.setSecureScreen(it) - } - .launchIn(lifecycleScope) - super.onCreate(savedInstanceState) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt index 59f5fc6b56..3c2595e805 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.lifecycleScope import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.util.system.AuthenticatorUtil import eu.kanade.tachiyomi.util.view.setSecureScreen +import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import uy.kohesive.injekt.injectLazy @@ -16,8 +17,12 @@ class SecureActivityDelegate(private val activity: FragmentActivity) { private val preferences: PreferencesHelper by injectLazy() fun onCreate() { - preferences.secureScreen().asFlow() - .onEach { activity.window.setSecureScreen(it || preferences.incognitoMode().get()) } + val secureScreenFlow = preferences.secureScreen().asFlow() + val incognitoModeFlow = preferences.incognitoMode().asFlow() + secureScreenFlow.combine(incognitoModeFlow) { secureScreen, incognitoMode -> + secureScreen || incognitoMode + } + .onEach { activity.window.setSecureScreen(it) } .launchIn(activity.lifecycleScope) }