summaryrefslogtreecommitdiff
path: root/core/src/main/java/de/danoeh
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2022-03-22 19:52:16 +0100
committerGitHub <noreply@github.com>2022-03-22 19:52:16 +0100
commitf6a79859015d4db8b77c95c7b98967fadd96f0cc (patch)
treea1c2b8ee3c2610433c065ad80521680a88819e96 /core/src/main/java/de/danoeh
parent66da9dad70a2e1b2f56bab5158f5f34ee9cfdd7d (diff)
parent33e9e57d6edaa371e0cac422be4223e0ac3c576c (diff)
downloadAntennaPod-f6a79859015d4db8b77c95c7b98967fadd96f0cc.zip
Merge pull request #5793 from ByteHamster/better-download-notification
Simplify download notification title
Diffstat (limited to 'core/src/main/java/de/danoeh')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java29
1 files changed, 26 insertions, 3 deletions
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 2bdd922f5..f5677433f 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
@@ -52,18 +52,41 @@ public class DownloadServiceNotification {
return null;
}
- String contentTitle = context.getString(R.string.download_notification_title);
- String downloadsLeft = (downloads.size() > 0)
+ String contentTitle;
+ if (typeIsOnly(downloads, Feed.FEEDFILETYPE_FEED)) {
+ contentTitle = context.getString(R.string.download_notification_title_feeds);
+ } else if (typeIsOnly(downloads, FeedMedia.FEEDFILETYPE_FEEDMEDIA)) {
+ contentTitle = context.getString(R.string.download_notification_title_episodes);
+ } else {
+ contentTitle = context.getString(R.string.download_notification_title);
+ }
+ String contentText = (downloads.size() > 0)
? context.getResources().getQuantityString(R.plurals.downloads_left, downloads.size(), downloads.size())
: context.getString(R.string.completing);
String bigText = compileNotificationString(downloads);
+ if (!bigText.contains("\n")) {
+ contentText = bigText;
+ }
notificationCompatBuilder.setContentTitle(contentTitle);
- notificationCompatBuilder.setContentText(downloadsLeft);
+ notificationCompatBuilder.setContentText(contentText);
notificationCompatBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(bigText));
return notificationCompatBuilder.build();
}
+ private boolean typeIsOnly(List<Downloader> downloads, int feedFileType) {
+ for (Downloader downloader : downloads) {
+ if (downloader.cancelled) {
+ continue;
+ }
+ DownloadRequest request = downloader.getDownloadRequest();
+ if (request.getFeedfileType() != feedFileType) {
+ return false;
+ }
+ }
+ return true;
+ }
+
private static String compileNotificationString(List<Downloader> downloads) {
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < downloads.size(); i++) {