aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-09-03 13:07:25 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-09-03 13:07:25 +0000
commitf13012d21c4634f325b766a45ea6bd96baea696a (patch)
tree0079113aead3fbe30262a4506faf7c3dcb57033d /app/src/main/java
parent0559176a8b2064de134cbe9a725dc027da6694d1 (diff)
downloadinfinity-for-reddit-f13012d21c4634f325b766a45ea6bd96baea696a.tar
infinity-for-reddit-f13012d21c4634f325b766a45ea6bd96baea696a.tar.gz
infinity-for-reddit-f13012d21c4634f325b766a45ea6bd96baea696a.tar.bz2
infinity-for-reddit-f13012d21c4634f325b766a45ea6bd96baea696a.tar.lz
infinity-for-reddit-f13012d21c4634f325b766a45ea6bd96baea696a.tar.xz
infinity-for-reddit-f13012d21c4634f325b766a45ea6bd96baea696a.tar.zst
infinity-for-reddit-f13012d21c4634f325b766a45ea6bd96baea696a.zip
Save last foreground time instead of last unlock time.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/LockScreenActivity.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java2
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";