Use constants for default settings.

This commit is contained in:
akwizgran
2020-06-29 12:24:55 +01:00
parent 08a8a0b281
commit 02cf6bfcaa

View File

@@ -115,18 +115,18 @@ public class PluginViewModel extends AndroidViewModel implements EventListener {
} else if (e instanceof SettingsUpdatedEvent) { } else if (e instanceof SettingsUpdatedEvent) {
SettingsUpdatedEvent s = (SettingsUpdatedEvent) e; SettingsUpdatedEvent s = (SettingsUpdatedEvent) e;
if (s.getNamespace().equals(TorConstants.ID.getString())) { if (s.getNamespace().equals(TorConstants.ID.getString())) {
boolean enable = boolean enable = s.getSettings().getBoolean(PREF_PLUGIN_ENABLE,
s.getSettings().getBoolean(PREF_PLUGIN_ENABLE, true); TorConstants.DEFAULT_PREF_PLUGIN_ENABLE);
torEnabledSetting.setValue(enable); torEnabledSetting.setValue(enable);
} else if (s.getNamespace() } else if (s.getNamespace().equals(
.equals(LanTcpConstants.ID.getString())) { LanTcpConstants.ID.getString())) {
boolean enable = boolean enable = s.getSettings().getBoolean(PREF_PLUGIN_ENABLE,
s.getSettings().getBoolean(PREF_PLUGIN_ENABLE, false); LanTcpConstants.DEFAULT_PREF_PLUGIN_ENABLE);
wifiEnabledSetting.setValue(enable); wifiEnabledSetting.setValue(enable);
} else if (s.getNamespace().equals( } else if (s.getNamespace().equals(
BluetoothConstants.ID.getString())) { BluetoothConstants.ID.getString())) {
boolean enable = boolean enable = s.getSettings().getBoolean(PREF_PLUGIN_ENABLE,
s.getSettings().getBoolean(PREF_PLUGIN_ENABLE, false); BluetoothConstants.DEFAULT_PREF_PLUGIN_ENABLE);
btEnabledSetting.setValue(enable); btEnabledSetting.setValue(enable);
} }
} else if (e instanceof TransportStateEvent) { } else if (e instanceof TransportStateEvent) {
@@ -176,11 +176,14 @@ public class PluginViewModel extends AndroidViewModel implements EventListener {
private void loadSettings() { private void loadSettings() {
dbExecutor.execute(() -> { dbExecutor.execute(() -> {
try { try {
boolean tor = isPluginEnabled(TorConstants.ID, true); boolean tor = isPluginEnabled(TorConstants.ID,
TorConstants.DEFAULT_PREF_PLUGIN_ENABLE);
torEnabledSetting.postValue(tor); torEnabledSetting.postValue(tor);
boolean wifi = isPluginEnabled(LanTcpConstants.ID, false); boolean wifi = isPluginEnabled(LanTcpConstants.ID,
LanTcpConstants.DEFAULT_PREF_PLUGIN_ENABLE);
wifiEnabledSetting.postValue(wifi); wifiEnabledSetting.postValue(wifi);
boolean bt = isPluginEnabled(BluetoothConstants.ID, false); boolean bt = isPluginEnabled(BluetoothConstants.ID,
BluetoothConstants.DEFAULT_PREF_PLUGIN_ENABLE);
btEnabledSetting.postValue(bt); btEnabledSetting.postValue(bt);
} catch (DbException e) { } catch (DbException e) {
logException(LOG, WARNING, e); logException(LOG, WARNING, e);