From 4872ea76f49321e35f740602783f655da428a4a1 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Thu, 4 Mar 2021 11:23:08 +0100 Subject: Show the name of failing downloads in the notification --- .../download/DownloadServiceNotification.java | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'core/src/main/java/de') diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java index 7c8fe9452..7b7879409 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java @@ -109,6 +109,23 @@ public class DownloadServiceNotification { return sb.toString(); } + private String createFailedDownloadNotificationContent(List statuses) { + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < statuses.size(); i++) { + if (statuses.get(i).isSuccessful()) { + continue; + } + sb.append("• ").append(statuses.get(i).getTitle()); + sb.append(": ").append(statuses.get(i).getReason().getErrorString(context)); + if (i != statuses.size() - 1) { + sb.append("\n"); + } + } + + return sb.toString(); + } + /** * Creates a notification at the end of the service lifecycle to notify the * user about the number of completed downloads. A report will only be @@ -156,11 +173,7 @@ public class DownloadServiceNotification { iconId = R.drawable.ic_notification_sync_error; intent = ClientConfig.downloadServiceCallbacks.getReportNotificationContentIntent(context); id = R.id.notification_download_report; - content = context.getResources() - .getQuantityString(R.plurals.download_report_content, - successfulDownloads, - successfulDownloads, - failedDownloads); + content = createFailedDownloadNotificationContent(reportQueue); } NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId); -- cgit v1.2.3