From 2040d885f2549b2a63c1c6784862c7a9aa1ba8c7 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 20 Jul 2018 10:41:27 +0200 Subject: [PATCH] do not show Data/WiFi Settings Toast if device has no internet Before, if the Data/WiFi Settings made it so the update process is not allowed to run and the device was not offline or in Airplane Mode, it would show this Toast then it would show the "your device is offline" Toast. --- app/src/main/java/org/fdroid/fdroid/UpdateService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/UpdateService.java b/app/src/main/java/org/fdroid/fdroid/UpdateService.java index 05f459e11..2e41694fe 100644 --- a/app/src/main/java/org/fdroid/fdroid/UpdateService.java +++ b/app/src/main/java/org/fdroid/fdroid/UpdateService.java @@ -116,12 +116,16 @@ public class UpdateService extends JobIntentService { } /** - * Add work to the queue for processing now + * Add work to the queue for processing now. + *

+ * This also shows a {@link Toast} if the Data/WiFi Settings make it so the + * update process is not allowed to run and the device is attached to a + * network (e.g. is not offline or in Airplane Mode). * * @see JobIntentService#enqueueWork(Context, Class, int, Intent) */ private static void enqueueWork(Context context, @NonNull Intent intent) { - if (!Preferences.get().isOnDemandDownloadAllowed()) { + if (FDroidApp.networkState > 0 && !Preferences.get().isOnDemandDownloadAllowed()) { Toast.makeText(context, R.string.updates_disabled_by_settings, Toast.LENGTH_LONG).show(); }