mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 06:09:55 +01:00
Screen Lock Timeout: Address review comments
This commit is contained in:
@@ -63,11 +63,15 @@ public class LockManagerImpl implements LockManager, Service, EventListener {
|
|||||||
private volatile boolean lockableSetting = false;
|
private volatile boolean lockableSetting = false;
|
||||||
private volatile int timeoutMinutes;
|
private volatile int timeoutMinutes;
|
||||||
private int activitiesRunning = 0;
|
private int activitiesRunning = 0;
|
||||||
|
private boolean alarmSet = false;
|
||||||
|
// This is to ensure that we don't start unlocked after a timeout and thus
|
||||||
|
// is set to the elapsed real time when no more activities are running.
|
||||||
|
// Its value is only relevant as long as no activity is running.
|
||||||
private long idleTime;
|
private long idleTime;
|
||||||
private final MutableLiveData<Boolean> lockable = new MutableLiveData<>();
|
private final MutableLiveData<Boolean> lockable = new MutableLiveData<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public LockManagerImpl(Application app, SettingsManager settingsManager,
|
LockManagerImpl(Application app, SettingsManager settingsManager,
|
||||||
AndroidNotificationManager notificationManager,
|
AndroidNotificationManager notificationManager,
|
||||||
@DatabaseExecutor Executor dbExecutor) {
|
@DatabaseExecutor Executor dbExecutor) {
|
||||||
this.appContext = app.getApplicationContext();
|
this.appContext = app.getApplicationContext();
|
||||||
@@ -108,7 +112,10 @@ public class LockManagerImpl implements LockManager, Service, EventListener {
|
|||||||
setLocked(true);
|
setLocked(true);
|
||||||
}
|
}
|
||||||
activitiesRunning++;
|
activitiesRunning++;
|
||||||
alarmManager.cancel(lockIntent);
|
if (alarmSet) {
|
||||||
|
alarmManager.cancel(lockIntent);
|
||||||
|
alarmSet = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
@@ -118,10 +125,11 @@ public class LockManagerImpl implements LockManager, Service, EventListener {
|
|||||||
if (activitiesRunning == 0) {
|
if (activitiesRunning == 0) {
|
||||||
idleTime = elapsedRealtime();
|
idleTime = elapsedRealtime();
|
||||||
if (!locked && timeoutEnabled()) {
|
if (!locked && timeoutEnabled()) {
|
||||||
alarmManager.cancel(lockIntent);
|
if (alarmSet) alarmManager.cancel(lockIntent);
|
||||||
long triggerAt =
|
long triggerAt =
|
||||||
elapsedRealtime() + MINUTES.toMillis(timeoutMinutes);
|
elapsedRealtime() + MINUTES.toMillis(timeoutMinutes);
|
||||||
alarmManager.set(ELAPSED_REALTIME, triggerAt, lockIntent);
|
alarmManager.set(ELAPSED_REALTIME, triggerAt, lockIntent);
|
||||||
|
alarmSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +154,8 @@ public class LockManagerImpl implements LockManager, Service, EventListener {
|
|||||||
if (locked && !hasScreenLock(appContext)) {
|
if (locked && !hasScreenLock(appContext)) {
|
||||||
lockable.postValue(false);
|
lockable.postValue(false);
|
||||||
locked = false;
|
locked = false;
|
||||||
} else if (!locked && activitiesRunning == 0 && timeoutEnabled()) {
|
} else if (!locked && activitiesRunning == 0 && timeoutEnabled() &&
|
||||||
|
timedOut()) {
|
||||||
setLocked(true);
|
setLocked(true);
|
||||||
}
|
}
|
||||||
return locked;
|
return locked;
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
<string name="groups_button">Private Groups</string>
|
<string name="groups_button">Private Groups</string>
|
||||||
<string name="forums_button">Forums</string>
|
<string name="forums_button">Forums</string>
|
||||||
<string name="blogs_button">Blogs</string>
|
<string name="blogs_button">Blogs</string>
|
||||||
|
<!-- This is part of the main menu. The app will be locked when this is tapped. -->
|
||||||
<string name="lock_button">Lock App</string>
|
<string name="lock_button">Lock App</string>
|
||||||
<string name="settings_button">Settings</string>
|
<string name="settings_button">Settings</string>
|
||||||
<string name="sign_out_button">Sign Out</string>
|
<string name="sign_out_button">Sign Out</string>
|
||||||
@@ -357,18 +358,23 @@
|
|||||||
|
|
||||||
<!-- Settings Security and Panic -->
|
<!-- Settings Security and Panic -->
|
||||||
<string name="security_settings_title">Security</string>
|
<string name="security_settings_title">Security</string>
|
||||||
<string name="pref_lock_title">Screen Lock</string>
|
<string name="pref_lock_title">Screen lock</string>
|
||||||
<string name="pref_lock_summary">Use the device\'s screen lock to protect Briar while signed in</string>
|
<string name="pref_lock_summary">Use the device\'s screen lock to protect Briar while signed in</string>
|
||||||
<string name="pref_lock_disabled_summary">Set up a screen lock for your device to protect Briar while signed in</string>
|
<string name="pref_lock_disabled_summary">To use this feature, set up a screen lock for your device</string>
|
||||||
<string name="pref_lock_timeout_title">Screen Lock Inactivity Timeout</string>
|
<string name="pref_lock_timeout_title">Screen lock inactivity timeout</string>
|
||||||
<!-- The %s placeholder is replaces with the following time spans, e.g. after 5 Minutes -->
|
<!-- The %s placeholder is replaced with the following time spans, e.g. 5 Minutes, 1 Hour -->
|
||||||
<string name="pref_lock_timeout_summary">When not using Briar, automatically lock it %s</string>
|
<string name="pref_lock_timeout_summary">When not using Briar, automatically lock it after %s</string>
|
||||||
<string name="pref_lock_timeout_1">after 1 Minute</string>
|
<!-- Will be shown in a list of lock times. Should fit into the %s of "automatically lock it after %s" -->
|
||||||
<string name="pref_lock_timeout_5">after 5 Minutes</string>
|
<string name="pref_lock_timeout_1">1 minute</string>
|
||||||
<string name="pref_lock_timeout_15">after 15 Minutes</string>
|
<!-- Will be shown in a list of lock times. Should fit into the %s of "automatically lock it after %s" -->
|
||||||
<string name="pref_lock_timeout_30">after 30 Minutes</string>
|
<string name="pref_lock_timeout_5">5 minutes</string>
|
||||||
<string name="pref_lock_timeout_60">after 1 Hour</string>
|
<!-- Will be shown in a list of lock times. Should fit into the %s of "automatically lock it after %s" -->
|
||||||
<string name="pref_lock_timeout_never">never</string>
|
<string name="pref_lock_timeout_15">15 minutes</string>
|
||||||
|
<!-- Will be shown in a list of lock times. Should fit into the %s of "automatically lock it after %s" -->
|
||||||
|
<string name="pref_lock_timeout_30">30 minutes</string>
|
||||||
|
<!-- Will be shown in a list of lock times. Should fit into the %s of "automatically lock it after %s" -->
|
||||||
|
<string name="pref_lock_timeout_60">1 hour</string>
|
||||||
|
<string name="pref_lock_timeout_never">Never</string>
|
||||||
<string name="pref_lock_timeout_never_summary">Never lock Briar automatically</string>
|
<string name="pref_lock_timeout_never_summary">Never lock Briar automatically</string>
|
||||||
|
|
||||||
<string name="change_password">Change password</string>
|
<string name="change_password">Change password</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user