Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Julian Dehm
briar
Commits
3388682d
Verified
Commit
3388682d
authored
Sep 05, 2018
by
akwizgran
Browse files
Use updated settings from event.
parent
7b116f15
Changes
1
Hide whitespace changes
Inline
Side-by-side
briar-android/src/main/java/org/briarproject/briar/android/account/LockManagerImpl.java
View file @
3388682d
...
...
@@ -96,7 +96,7 @@ public class LockManagerImpl implements LockManager, Service, EventListener {
@Override
public
void
startService
()
{
// only load the setting here, because database isn't open before
load
Lockable
Setting
();
loadSetting
s
();
}
@Override
...
...
@@ -170,34 +170,33 @@ public class LockManagerImpl implements LockManager, Service, EventListener {
@Override
public
void
eventOccurred
(
Event
event
)
{
if
(
event
instanceof
SettingsUpdatedEvent
)
{
SettingsUpdatedEvent
e
=
(
SettingsUpdatedEvent
)
event
;
String
namespace
=
e
.
getNamespace
();
if
(
namespace
.
equals
(
SETTINGS_NAMESPACE
))
{
loadLockableSetting
();
SettingsUpdatedEvent
s
=
(
SettingsUpdatedEvent
)
event
;
if
(
s
.
getNamespace
().
equals
(
SETTINGS_NAMESPACE
))
{
applySettings
(
s
.
getSettings
());
}
}
}
private
void
load
Lockable
Setting
()
{
private
void
loadSetting
s
()
{
dbExecutor
.
execute
(()
->
{
try
{
Settings
settings
=
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
);
applySettings
(
settingsManager
.
getSettings
(
SETTINGS_NAMESPACE
));
}
catch
(
DbException
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
()
{
return
timeoutMinutes
!=
timeoutNever
&&
lockable
.
getValue
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment