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

View File

@@ -5,6 +5,7 @@ import android.graphics.Color
import android.os.Build
import android.view.View
import android.view.Window
import android.view.WindowManager
import eu.kanade.tachiyomi.util.system.InternalResourceHelper
import eu.kanade.tachiyomi.util.system.getResourceColor
@@ -42,3 +43,11 @@ fun Window.setNavigationBarTransparentCompat(context: Context) {
context.getResourceColor(android.R.attr.navigationBarColor, 0.7F)
}
}
fun Window.setSecureScreen(enabled: Boolean) {
if (enabled) {
setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
} else {
clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
}
}