diff options
author | RafaelBo <77226971+RafaelBod@users.noreply.github.com> | 2021-10-13 22:28:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-13 22:28:46 +0200 |
commit | 66250bebea5e2bef515651d310811ea7682a3c13 (patch) | |
tree | feba12de54176772e0771e770d05d552727d8a6a /core | |
parent | 5d01b80b9d3e8befb386c7ff7ca2e0a179fa3ed1 (diff) | |
download | AntennaPod-66250bebea5e2bef515651d310811ea7682a3c13.zip |
Add prompt logic in mobile feed refresh (#5462)
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/download/AutoUpdateManager.java | 24 | ||||
-rw-r--r-- | core/src/main/res/values/strings.xml | 1 |
2 files changed, 22 insertions, 3 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/download/AutoUpdateManager.java b/core/src/main/java/de/danoeh/antennapod/core/util/download/AutoUpdateManager.java index bb0a71744..dbad1f63e 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/download/AutoUpdateManager.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/download/AutoUpdateManager.java @@ -1,9 +1,10 @@ package de.danoeh.antennapod.core.util.download; import android.content.Context; -import androidx.annotation.NonNull; import android.util.Log; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; import androidx.work.Constraints; import androidx.work.Data; import androidx.work.ExistingPeriodicWorkPolicy; @@ -17,6 +18,7 @@ import java.util.Arrays; import java.util.Calendar; import java.util.concurrent.TimeUnit; +import de.danoeh.antennapod.core.R; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.service.FeedUpdateWorker; import de.danoeh.antennapod.core.storage.DBTasks; @@ -70,7 +72,7 @@ public class AutoUpdateManager { Log.d(TAG, "Restarting update alarm."); Calendar now = Calendar.getInstance(); - Calendar alarm = (Calendar)now.clone(); + Calendar alarm = (Calendar) now.clone(); alarm.set(Calendar.HOUR_OF_DAY, hoursOfDay); alarm.set(Calendar.MINUTE, minute); if (alarm.before(now) || alarm.equals(now)) { @@ -121,8 +123,24 @@ public class AutoUpdateManager { Log.d(TAG, "Run auto update immediately in background."); if (!NetworkUtils.networkAvailable()) { Log.d(TAG, "Ignoring: No network connection."); - return; + } else if (NetworkUtils.isEpisodeDownloadAllowed()) { + startRefreshAllFeeds(context); + } else { + confirmMobileAllFeedsRefresh(context); } + } + + private static void confirmMobileAllFeedsRefresh(final Context context) { + AlertDialog.Builder builder = new AlertDialog.Builder(context) + .setTitle(R.string.feed_refresh_title) + .setMessage(R.string.confirm_mobile_feed_refresh_dialog_message) + .setPositiveButton(R.string.yes, + (dialog, which) -> startRefreshAllFeeds(context)) + .setNegativeButton(R.string.no, null); + builder.show(); + } + + private static void startRefreshAllFeeds(final Context context) { new Thread(() -> DBTasks.refreshAllFeeds( context.getApplicationContext(), true), "ManualRefreshAllFeeds").start(); } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 1376622c5..5d86109c3 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -188,6 +188,7 @@ <item quantity="other">%d subscriptions updated.</item> </plurals> <string name="add_to_folder">Add to folder</string> + <string name="confirm_mobile_feed_refresh_dialog_message">Downloading episodes over mobile data connection is disabled in the settings.\n\nDo you still want to refresh all podcasts over mobile data?</string> <!-- actions on feeditems --> <string name="download_label">Download</string> |