Show the name of failing downloads in the notification
This commit is contained in:
parent
d4141d19a0
commit
4872ea76f4
|
@ -109,6 +109,23 @@ public class DownloadServiceNotification {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String createFailedDownloadNotificationContent(List<DownloadStatus> 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
|
* 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
|
* 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;
|
iconId = R.drawable.ic_notification_sync_error;
|
||||||
intent = ClientConfig.downloadServiceCallbacks.getReportNotificationContentIntent(context);
|
intent = ClientConfig.downloadServiceCallbacks.getReportNotificationContentIntent(context);
|
||||||
id = R.id.notification_download_report;
|
id = R.id.notification_download_report;
|
||||||
content = context.getResources()
|
content = createFailedDownloadNotificationContent(reportQueue);
|
||||||
.getQuantityString(R.plurals.download_report_content,
|
|
||||||
successfulDownloads,
|
|
||||||
successfulDownloads,
|
|
||||||
failedDownloads);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId);
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId);
|
||||||
|
|
|
@ -276,10 +276,6 @@
|
||||||
</plurals>
|
</plurals>
|
||||||
<string name="service_shutting_down">Service shutting down</string>
|
<string name="service_shutting_down">Service shutting down</string>
|
||||||
<string name="download_notification_title">Downloading podcast data</string>
|
<string name="download_notification_title">Downloading podcast data</string>
|
||||||
<plurals name="download_report_content">
|
|
||||||
<item quantity="one">%d download succeeded, %d failed</item>
|
|
||||||
<item quantity="other">%d downloads succeeded, %d failed</item>
|
|
||||||
</plurals>
|
|
||||||
<string name="download_log_title_unknown">Unknown Title</string>
|
<string name="download_log_title_unknown">Unknown Title</string>
|
||||||
<string name="download_type_feed">Feed</string>
|
<string name="download_type_feed">Feed</string>
|
||||||
<string name="download_type_media">Media file</string>
|
<string name="download_type_media">Media file</string>
|
||||||
|
|
Loading…
Reference in New Issue