1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-26 20:06:02 +00:00

Remove SharedPreferences.OnSharedPreferenceChangeListener

This commit is contained in:
Catfriend1 2018-07-26 12:21:29 +02:00
parent 50ea1e47de
commit a1e0b10e7b

View file

@ -36,7 +36,7 @@ import javax.inject.Inject;
* This information is actively read on instance creation, and then updated from intents * This information is actively read on instance creation, and then updated from intents
* that are passed with {@link #ACTION_DEVICE_STATE_CHANGED}. * that are passed with {@link #ACTION_DEVICE_STATE_CHANGED}.
*/ */
public class RunConditionMonitor implements SharedPreferences.OnSharedPreferenceChangeListener { public class RunConditionMonitor {
private static final String TAG = "RunConditionMonitor"; private static final String TAG = "RunConditionMonitor";
@ -73,7 +73,7 @@ public class RunConditionMonitor implements SharedPreferences.OnSharedPreference
Log.v(TAG, "Created new instance"); Log.v(TAG, "Created new instance");
((SyncthingApp) context.getApplicationContext()).component().inject(this); ((SyncthingApp) context.getApplicationContext()).component().inject(this);
mContext = context; mContext = context;
mPreferences.registerOnSharedPreferenceChangeListener(this); // ToDo mPreferences.registerOnSharedPreferenceChangeListener(this);
mOnRunConditionChangedListener = listener; mOnRunConditionChangedListener = listener;
/** /**
@ -105,28 +105,18 @@ public class RunConditionMonitor implements SharedPreferences.OnSharedPreference
public void shutdown() { public void shutdown() {
Log.v(TAG, "Shutting down"); Log.v(TAG, "Shutting down");
mPreferences.unregisterOnSharedPreferenceChangeListener(this);
ContentResolver.removeStatusChangeListener(mSyncStatusObserver); ContentResolver.removeStatusChangeListener(mSyncStatusObserver);
mReceiverManager.unregisterAllReceivers(mContext); mReceiverManager.unregisterAllReceivers(mContext);
} }
/*
// ToDo
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onRunConditionPreferencesChanged() {
List<String> watched = Lists.newArrayList( // Force a re-evaluation of which run conditions apply according to the changed prefs.
Constants.PREF_RUN_ON_MOBILE_DATA, updateShouldRunDecision();
Constants.PREF_RUN_ON_WIFI,
Constants.PREF_RUN_ON_METERED_WIFI,
Constants.PREF_WIFI_SSID_WHITELIST,
Constants.PREF_POWER_SOURCE,
Constants.PREF_RUN_IN_FLIGHT_MODE,
Constants.PREF_RESPECT_BATTERY_SAVING,
Constants.PREF_RESPECT_MASTER_SYNC
);
if (watched.contains(key)) {
// Force a re-evaluation of which run conditions apply according to the changed prefs.
updateShouldRunDecision();
}
} }
*/
private class BatteryReceiver extends BroadcastReceiver { private class BatteryReceiver extends BroadcastReceiver {
@Override @Override