mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 06:09:55 +01:00
Use updated settings from event.
This commit is contained in:
@@ -96,7 +96,7 @@ public class LockManagerImpl implements LockManager, Service, EventListener {
|
|||||||
@Override
|
@Override
|
||||||
public void startService() {
|
public void startService() {
|
||||||
// only load the setting here, because database isn't open before
|
// only load the setting here, because database isn't open before
|
||||||
loadLockableSetting();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -170,34 +170,33 @@ public class LockManagerImpl implements LockManager, Service, EventListener {
|
|||||||
@Override
|
@Override
|
||||||
public void eventOccurred(Event event) {
|
public void eventOccurred(Event event) {
|
||||||
if (event instanceof SettingsUpdatedEvent) {
|
if (event instanceof SettingsUpdatedEvent) {
|
||||||
SettingsUpdatedEvent e = (SettingsUpdatedEvent) event;
|
SettingsUpdatedEvent s = (SettingsUpdatedEvent) event;
|
||||||
String namespace = e.getNamespace();
|
if (s.getNamespace().equals(SETTINGS_NAMESPACE)) {
|
||||||
if (namespace.equals(SETTINGS_NAMESPACE)) {
|
applySettings(s.getSettings());
|
||||||
loadLockableSetting();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadLockableSetting() {
|
private void loadSettings() {
|
||||||
dbExecutor.execute(() -> {
|
dbExecutor.execute(() -> {
|
||||||
try {
|
try {
|
||||||
Settings settings =
|
applySettings(settingsManager.getSettings(SETTINGS_NAMESPACE));
|
||||||
settingsManager.getSettings(SETTINGS_NAMESPACE);
|
|
||||||
// is the app lockable?
|
|
||||||
lockableSetting = settings.getBoolean(PREF_SCREEN_LOCK, false);
|
|
||||||
boolean newValue = hasScreenLock(appContext) && lockableSetting;
|
|
||||||
lockable.postValue(newValue);
|
|
||||||
// what is the timeout in minutes?
|
|
||||||
timeoutMinutes = settings.getInt(PREF_SCREEN_LOCK_TIMEOUT,
|
|
||||||
timeoutDefault);
|
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
logException(LOG, WARNING, e);
|
||||||
lockableSetting = false;
|
|
||||||
lockable.postValue(false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void applySettings(Settings settings) {
|
||||||
|
// is the app lockable?
|
||||||
|
lockableSetting = settings.getBoolean(PREF_SCREEN_LOCK, false);
|
||||||
|
boolean newValue = hasScreenLock(appContext) && lockableSetting;
|
||||||
|
lockable.postValue(newValue);
|
||||||
|
// what is the timeout in minutes?
|
||||||
|
timeoutMinutes = settings.getInt(PREF_SCREEN_LOCK_TIMEOUT,
|
||||||
|
timeoutDefault);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean timeoutEnabled() {
|
private boolean timeoutEnabled() {
|
||||||
return timeoutMinutes != timeoutNever && lockable.getValue();
|
return timeoutMinutes != timeoutNever && lockable.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user