mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Save last foreground time instead of last unlock time.
This commit is contained in:
parent
0559176a8b
commit
f13012d21c
@ -76,7 +76,7 @@ public class Infinity extends Application implements LifecycleObserver {
|
|||||||
@Override
|
@Override
|
||||||
public void onActivityResumed(@NonNull Activity activity) {
|
public void onActivityResumed(@NonNull Activity activity) {
|
||||||
if (canStartLockScreenActivity && appLock
|
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)) {
|
&& !(activity instanceof LockScreenActivity)) {
|
||||||
Intent intent = new Intent(activity, LockScreenActivity.class);
|
Intent intent = new Intent(activity, LockScreenActivity.class);
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
@ -137,7 +137,9 @@ public class Infinity extends Application implements LifecycleObserver {
|
|||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
|
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
|
||||||
public void appInBackground() {
|
public void appInBackground() {
|
||||||
|
if (appLock) {
|
||||||
|
mSecuritySharedPreferences.edit().putLong(SharedPreferencesUtils.LAST_FOREGROUND_TIME, System.currentTimeMillis()).apply();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppComponent getAppComponent() {
|
public AppComponent getAppComponent() {
|
||||||
|
@ -24,7 +24,6 @@ import butterknife.ButterKnife;
|
|||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
|
||||||
|
|
||||||
public class LockScreenActivity extends BaseActivity {
|
public class LockScreenActivity extends BaseActivity {
|
||||||
|
|
||||||
@ -36,9 +35,6 @@ public class LockScreenActivity extends BaseActivity {
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("security")
|
|
||||||
SharedPreferences mSecurityPreferences;
|
|
||||||
@Inject
|
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,7 +67,6 @@ public class LockScreenActivity extends BaseActivity {
|
|||||||
public void onAuthenticationSucceeded(
|
public void onAuthenticationSucceeded(
|
||||||
@NonNull BiometricPrompt.AuthenticationResult result) {
|
@NonNull BiometricPrompt.AuthenticationResult result) {
|
||||||
super.onAuthenticationSucceeded(result);
|
super.onAuthenticationSucceeded(result);
|
||||||
saveUnlockTime();
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -83,15 +78,10 @@ public class LockScreenActivity extends BaseActivity {
|
|||||||
|
|
||||||
biometricPrompt.authenticate(promptInfo);
|
biometricPrompt.authenticate(promptInfo);
|
||||||
} else {
|
} else {
|
||||||
saveUnlockTime();
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveUnlockTime() {
|
|
||||||
mSecurityPreferences.edit().putLong(SharedPreferencesUtils.LAST_UNLOCK_TIME, System.currentTimeMillis()).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SharedPreferences getDefaultSharedPreferences() {
|
protected SharedPreferences getDefaultSharedPreferences() {
|
||||||
|
@ -329,7 +329,7 @@ public class SharedPreferencesUtils {
|
|||||||
public static final String SECURE_MODE = "secure_mode";
|
public static final String SECURE_MODE = "secure_mode";
|
||||||
public static final String APP_LOCK = "app_lock";
|
public static final String APP_LOCK = "app_lock";
|
||||||
public static final String APP_LOCK_TIMEOUT = "app_lock_timeout";
|
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
|
//Legacy Settings
|
||||||
public static final String MAIN_PAGE_TAB_1_TITLE_LEGACY = "main_page_tab_1_title";
|
public static final String MAIN_PAGE_TAB_1_TITLE_LEGACY = "main_page_tab_1_title";
|
||||||
|
Loading…
Reference in New Issue
Block a user