From a3c30f4ac6c49e651d0be1bae8cf4fd0bcd583bc Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 10 Nov 2016 23:39:24 +0900 Subject: [PATCH] Fixed settings not being enabled after restart --- .../fragments/SettingsFragment.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java index 26f2c5bf..e524a741 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java @@ -157,16 +157,17 @@ public class SettingsFragment extends PreferenceFragment @Override public void onApiChange(SyncthingService.State currentState) { - boolean enabled = currentState == SyncthingService.State.ACTIVE; - if (!enabled || !mSyncthingService.getApi().isConfigLoaded()) { - PreferenceScreen ps = getPreferenceScreen(); - for (int i = 0; i < ps.getPreferenceCount(); i++) { - Preference p = ps.getPreference(i); - p.setEnabled("category_run_conditions".equals(p.getKey())); - } - return; + boolean syncthingActive = currentState == SyncthingService.State.ACTIVE; + boolean enableAllPrefs = syncthingActive && mSyncthingService.getApi().isConfigLoaded(); + PreferenceScreen ps = getPreferenceScreen(); + for (int i = 0; i < ps.getPreferenceCount(); i++) { + Preference p = ps.getPreference(i); + p.setEnabled(enableAllPrefs || "category_run_conditions".equals(p.getKey())); } + if (!enableAllPrefs) + return; + mApi = mSyncthingService.getApi(); mSyncthingVersion.setSummary(mApi.getVersion()); mOptions = mApi.getOptions();