From 429283273699675693dc16c896a3c131ed514d3b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 21 Jun 2018 10:09:03 +0200 Subject: [PATCH] show Updating progress notification based on "available updates" pref The notification that shows the download/parse progress of the index update is now controled by the "Show available updates" preference. That means it will not be shown at all in the notifications bar if that preference is disabled. There will still be the header inside of F-Droid. Ideally, the Updating process would be shown in the Updates tab. --- .../java/org/fdroid/fdroid/UpdateService.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/UpdateService.java b/app/src/main/java/org/fdroid/fdroid/UpdateService.java index 7e431430e..3598aa186 100644 --- a/app/src/main/java/org/fdroid/fdroid/UpdateService.java +++ b/app/src/main/java/org/fdroid/fdroid/UpdateService.java @@ -319,14 +319,14 @@ public class UpdateService extends JobIntentService { } else { notificationBuilder.setProgress(100, 0, true); } - notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); + setNotification(); break; case STATUS_ERROR_GLOBAL: text = context.getString(R.string.global_error_updating_repos, message); notificationBuilder.setContentText(text) .setCategory(NotificationCompat.CATEGORY_ERROR) .setSmallIcon(android.R.drawable.ic_dialog_alert); - notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); + setNotification(); Toast.makeText(context, text, Toast.LENGTH_LONG).show(); break; case STATUS_ERROR_LOCAL: @@ -344,7 +344,7 @@ public class UpdateService extends JobIntentService { notificationBuilder.setContentText(text) .setCategory(NotificationCompat.CATEGORY_ERROR) .setSmallIcon(android.R.drawable.ic_dialog_info); - notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); + setNotification(); Toast.makeText(context, text, Toast.LENGTH_LONG).show(); break; case STATUS_COMPLETE_WITH_CHANGES: @@ -353,12 +353,18 @@ public class UpdateService extends JobIntentService { text = context.getString(R.string.repos_unchanged); notificationBuilder.setContentText(text) .setCategory(NotificationCompat.CATEGORY_SERVICE); - notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); + setNotification(); break; } } }; + private void setNotification() { + if (Preferences.get().isUpdateNotificationEnabled()) { + notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); + } + } + /** * In order to send a {@link Toast} from a {@link IntentService}, we have to do these tricks. */ @@ -404,7 +410,7 @@ public class UpdateService extends JobIntentService { } updating = true; - notificationManager.notify(NOTIFY_ID_UPDATING, notificationBuilder.build()); + setNotification(); LocalBroadcastManager.getInstance(this).registerReceiver(updateStatusReceiver, new IntentFilter(LOCAL_ACTION_STATUS));