diff options
Diffstat (limited to '')
3 files changed, 5 insertions, 13 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java index 39e56874..e0eb462d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java @@ -76,7 +76,7 @@ public class Infinity extends Application implements LifecycleObserver { @Override public void onActivityResumed(@NonNull Activity activity) { if (canStartLockScreenActivity && appLock - && System.currentTimeMillis() - mSecuritySharedPreferences.getLong(SharedPreferencesUtils.LAST_UNLOCK_TIME, 0) >= appLockTimeout + && System.currentTimeMillis() - mSecuritySharedPreferences.getLong(SharedPreferencesUtils.LAST_FOREGROUND_TIME, 0) >= appLockTimeout && !(activity instanceof LockScreenActivity)) { Intent intent = new Intent(activity, LockScreenActivity.class); activity.startActivity(intent); @@ -137,7 +137,9 @@ public class Infinity extends Application implements LifecycleObserver { @OnLifecycleEvent(Lifecycle.Event.ON_STOP) public void appInBackground() { - + if (appLock) { + mSecuritySharedPreferences.edit().putLong(SharedPreferencesUtils.LAST_FOREGROUND_TIME, System.currentTimeMillis()).apply(); + } } public AppComponent getAppComponent() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java index 7569ab66..aa90f5b4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java @@ -24,7 +24,6 @@ import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; -import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; public class LockScreenActivity extends BaseActivity { @@ -36,9 +35,6 @@ public class LockScreenActivity extends BaseActivity { @Named("default") SharedPreferences mSharedPreferences; @Inject - @Named("security") - SharedPreferences mSecurityPreferences; - @Inject CustomThemeWrapper mCustomThemeWrapper; @Override @@ -71,7 +67,6 @@ public class LockScreenActivity extends BaseActivity { public void onAuthenticationSucceeded( @NonNull BiometricPrompt.AuthenticationResult result) { super.onAuthenticationSucceeded(result); - saveUnlockTime(); finish(); } }); @@ -83,15 +78,10 @@ public class LockScreenActivity extends BaseActivity { biometricPrompt.authenticate(promptInfo); } else { - saveUnlockTime(); finish(); } } - private void saveUnlockTime() { - mSecurityPreferences.edit().putLong(SharedPreferencesUtils.LAST_UNLOCK_TIME, System.currentTimeMillis()).apply(); - } - @Override protected SharedPreferences getDefaultSharedPreferences() { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java index a2d243b2..27e6a0b4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -329,7 +329,7 @@ public class SharedPreferencesUtils { public static final String SECURE_MODE = "secure_mode"; public static final String APP_LOCK = "app_lock"; public static final String APP_LOCK_TIMEOUT = "app_lock_timeout"; - public static final String LAST_UNLOCK_TIME = "last_unlock_time"; + public static final String LAST_FOREGROUND_TIME = "last_foreground_time"; //Legacy Settings public static final String MAIN_PAGE_TAB_1_TITLE_LEGACY = "main_page_tab_1_title"; |