From 6579e2ea9499519059dbb37462f1062ab4cab82d Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Thu, 26 Jul 2018 12:35:03 +0200 Subject: [PATCH] Added SyncthingService#reEvaluateRunConditions --- .../service/RunConditionMonitor.java | 10 ---------- .../syncthingandroid/service/SyncthingService.java | 12 ++++++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/service/RunConditionMonitor.java b/app/src/main/java/com/nutomic/syncthingandroid/service/RunConditionMonitor.java index f72de469..6eb89d7f 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/service/RunConditionMonitor.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/service/RunConditionMonitor.java @@ -73,7 +73,6 @@ public class RunConditionMonitor { Log.v(TAG, "Created new instance"); ((SyncthingApp) context.getApplicationContext()).component().inject(this); mContext = context; - // ToDo mPreferences.registerOnSharedPreferenceChangeListener(this); mOnRunConditionChangedListener = listener; /** @@ -109,15 +108,6 @@ public class RunConditionMonitor { mReceiverManager.unregisterAllReceivers(mContext); } -/* -// ToDo - @Override - public void onRunConditionPreferencesChanged() { - // Force a re-evaluation of which run conditions apply according to the changed prefs. - updateShouldRunDecision(); - } -*/ - private class BatteryReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { diff --git a/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java b/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java index 12100335..537efdc2 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java @@ -519,6 +519,18 @@ public class SyncthingService extends Service { return mApi; } + /** + * Force re-evaluating run conditions immediately e.g. after + * preferences were modified by {@link SettingsActivity}. + */ + public void reEvaluateRunConditions() { + if (mRunConditionMonitor == null) { + return; + } + Log.v(TAG, "Forced re-evaluating run conditions ..."); + mRunConditionMonitor.updateShouldRunDecision(); + } + /** * Register a listener for the syncthing API state changing. *