From 1e64f882693a76bd9377236919fc4617aac1a8fe Mon Sep 17 00:00:00 2001 From: Martin Carpella Date: Sat, 14 Nov 2015 23:49:34 +0100 Subject: [PATCH] Fix "Wifi only" / "Charging only" not being applied immediately --- .../nutomic/syncthingandroid/fragments/SettingsFragment.java | 4 +--- .../nutomic/syncthingandroid/syncthing/SyncthingService.java | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java index d1f73610..fe6a8291 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java @@ -227,9 +227,7 @@ public class SettingsFragment extends PreferenceFragment boolean requireRestart = false; - if (preference.equals(mSyncOnlyCharging) || preference.equals(mSyncOnlyWifi)) { - mSyncthingService.updateState(); - } else if (preference.equals(mAlwaysRunInBackground)) { + if (preference.equals(mAlwaysRunInBackground)) { boolean value = (Boolean) o; preference.setSummary((value) ? R.string.always_run_in_background_enabled diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java index c9e23201..fd9e7ee6 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java @@ -268,6 +268,8 @@ public class SyncthingService extends Service implements public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals(PREF_NOTIFICATION_TYPE)) updateNotification(); + else if (key.equals(PREF_SYNC_ONLY_CHARGING) || key.equals(PREF_SYNC_ONLY_WIFI)) + updateState(); } /**