diff options
author | ByteHamster <info@bytehamster.com> | 2022-03-17 00:12:29 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-03-17 00:12:29 +0100 |
commit | 33e9e57d6edaa371e0cac422be4223e0ac3c576c (patch) | |
tree | 892abd71c7e42d7c1c9f7f726e7b4b3f8e0e3e88 | |
parent | 3b47deb7052aee1036416401eada6b680fd8c713 (diff) | |
download | AntennaPod-33e9e57d6edaa371e0cac422be4223e0ac3c576c.zip |
Simplify download notification title
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java | 29 | ||||
-rw-r--r-- | ui/i18n/src/main/res/values/strings.xml | 2 |
2 files changed, 28 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 a33409323..9255ab765 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++) { diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index b29728d16..ef07e0000 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -279,6 +279,8 @@ </plurals> <string name="completing">Completing…</string> <string name="download_notification_title">Downloading podcast data</string> + <string name="download_notification_title_feeds">Refreshing podcasts</string> + <string name="download_notification_title_episodes">Downloading episodes</string> <string name="download_log_title_unknown">Unknown Title</string> <string name="download_type_feed">Feed</string> <string name="download_type_media">Media file</string> |