Enable secure screen when incognito mode is enabled (#5339)

* Enable secure screen when incognito mode is enabled

* Fix incognito banner not showing up after configuration changes
This commit is contained in:
Ivan Iskandar
2021-06-08 09:41:12 +07:00
committed by GitHub
parent 3d58b78062
commit fb8aafb69f
4 changed files with 25 additions and 8 deletions
@@ -1,11 +1,11 @@
package eu.kanade.tachiyomi.ui.security
import android.content.Intent
import android.view.WindowManager
import androidx.fragment.app.FragmentActivity
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.launchIn
import kotlinx.coroutines.flow.onEach
import uy.kohesive.injekt.injectLazy
@@ -17,13 +17,7 @@ class SecureActivityDelegate(private val activity: FragmentActivity) {
fun onCreate() {
preferences.secureScreen().asFlow()
.onEach {
if (it) {
activity.window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
} else {
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
}
}
.onEach { activity.window.setSecureScreen(it || preferences.incognitoMode().get()) }
.launchIn(activity.lifecycleScope)
}