diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index fd68315bb4..cffddba7e0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.updater.UpdaterJob -import eu.kanade.tachiyomi.ui.security.BiometricUnlockDelegate +import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate import eu.kanade.tachiyomi.util.system.LocaleHelper import org.acra.ACRA import org.acra.annotation.ReportsCrashes @@ -64,7 +64,7 @@ open class App : Application(), LifecycleObserver { fun onAppBackgrounded() { val preferences: PreferencesHelper by injectLazy() if (preferences.lockAppAfter().getOrDefault() >= 0) { - BiometricUnlockDelegate.locked = true + SecureActivityDelegate.locked = true } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index d714dbd4cd..48b5be4065 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -111,6 +111,8 @@ object PreferenceKeys { const val lastAppUnlock = "last_app_unlock" + const val secureScreen = "secure_screen" + const val downloadNew = "download_new" const val downloadNewCategories = "download_new_categories" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index d4500176c8..6dd69a2c86 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -58,6 +58,8 @@ class PreferencesHelper(val context: Context) { fun lastAppUnlock() = rxPrefs.getLong(Keys.lastAppUnlock, 0) + fun secureScreen() = rxPrefs.getBoolean(Keys.secureScreen, false) + fun clear() = prefs.edit().clear().apply() fun themeMode() = rxPrefs.getString(Keys.themeMode, Values.THEME_MODE_SYSTEM) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt index 2935982f10..e284d94b7c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt @@ -8,7 +8,7 @@ import androidx.appcompat.app.AppCompatDelegate import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault -import eu.kanade.tachiyomi.ui.security.BiometricUnlockDelegate +import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate import eu.kanade.tachiyomi.util.system.LocaleHelper import uy.kohesive.injekt.injectLazy import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values @@ -45,11 +45,14 @@ abstract class BaseActivity : AppCompatActivity() { }) super.onCreate(savedInstanceState) + + SecureActivityDelegate.onCreate(this) } override fun onResume() { super.onResume() - BiometricUnlockDelegate.onResume(this) + + SecureActivityDelegate.onResume(this) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt index 7d120f5cb1..5105ac0484 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt @@ -1,6 +1,8 @@ package eu.kanade.tachiyomi.ui.base.activity +import android.os.Bundle import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter +import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate import eu.kanade.tachiyomi.util.system.LocaleHelper import nucleus.view.NucleusAppCompatActivity @@ -11,4 +13,16 @@ abstract class BaseRxActivity
> : NucleusAppCompatActivity
() {
initializeMenu()
}
- override fun onResume() {
- super.onResume()
- BiometricUnlockDelegate.onResume(this)
- }
-
/**
* Called when the activity is destroyed. Cleans up the viewer, configuration and any view.
*/
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricUnlockActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricUnlockActivity.kt
index fdfaad2b81..654628211a 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricUnlockActivity.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricUnlockActivity.kt
@@ -28,7 +28,7 @@ class BiometricUnlockActivity : AppCompatActivity() {
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
- BiometricUnlockDelegate.locked = false
+ SecureActivityDelegate.locked = false
preferences.lastAppUnlock().set(Date().time)
finish()
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricUnlockDelegate.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt
similarity index 71%
rename from app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricUnlockDelegate.kt
rename to app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt
index ab684fa649..d9310c0864 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/security/BiometricUnlockDelegate.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/security/SecureActivityDelegate.kt
@@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.ui.security
import android.content.Intent
+import android.view.WindowManager
import androidx.biometric.BiometricManager
import androidx.fragment.app.FragmentActivity
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@@ -8,12 +9,23 @@ import eu.kanade.tachiyomi.data.preference.getOrDefault
import uy.kohesive.injekt.injectLazy
import java.util.Date
-object BiometricUnlockDelegate {
+object SecureActivityDelegate {
private val preferences by injectLazy