Allow to disable auto updates

This commit is contained in:
ByteHamster 2019-05-28 18:11:12 +02:00
parent 4443d629fc
commit f05132a716
3 changed files with 12 additions and 1 deletions

View File

@ -1190,7 +1190,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
timePickerDialog.show(); timePickerDialog.show();
}); });
builder.onNeutral((dialog, which) -> { builder.onNeutral((dialog, which) -> {
UserPreferences.setUpdateInterval(0); UserPreferences.disableAutoUpdate();
setUpdateIntervalText(); setUpdateIntervalText();
}); });
builder.show(); builder.show();

View File

@ -575,6 +575,13 @@ public class UserPreferences {
restartUpdateAlarm(); restartUpdateAlarm();
} }
public static void disableAutoUpdate() {
prefs.edit()
.putString(PREF_UPDATE_INTERVAL, "0")
.apply();
AutoUpdateManager.disableAutoUpdate();
}
/** /**
* Change the auto-flattr settings * Change the auto-flattr settings
* *

View File

@ -60,6 +60,10 @@ public class AutoUpdateManager {
WorkManager.getInstance().enqueueUniqueWork(WORK_ID_FEED_UPDATE, ExistingWorkPolicy.REPLACE, workRequest); WorkManager.getInstance().enqueueUniqueWork(WORK_ID_FEED_UPDATE, ExistingWorkPolicy.REPLACE, workRequest);
} }
public static void disableAutoUpdate() {
WorkManager.getInstance().cancelUniqueWork(WORK_ID_FEED_UPDATE);
}
private static Constraints getConstraints() { private static Constraints getConstraints() {
Constraints.Builder constraints = new Constraints.Builder(); Constraints.Builder constraints = new Constraints.Builder();