summaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorNathan Mascitelli <mascitelli.nathan@gmail.com>2020-02-13 08:40:47 -0500
committerNathan Mascitelli <mascitelli.nathan@gmail.com>2020-03-22 16:25:57 -0400
commit7a93f1e513c3616cebd88567fc701578cef357f1 (patch)
tree2d46a4b7051538baae083b1169c7793015617e8a /core/src/main
parent052c86f43b8646cda322ae592cdf0cce6f186340 (diff)
downloadAntennaPod-7a93f1e513c3616cebd88567fc701578cef357f1.zip
Add new notification channel
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java23
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java12
-rw-r--r--core/src/main/res/values/strings.xml4
3 files changed, 26 insertions, 13 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 811b2374e..153effb57 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
@@ -116,20 +116,19 @@ public class DownloadServiceNotification {
if (createReport) {
Log.d(TAG, "Creating report");
+
// create notification object
- NotificationCompat.Builder builder = new NotificationCompat.Builder(context,
- NotificationUtils.CHANNEL_ID_ERROR)
- .setTicker(context.getString(R.string.download_report_title))
- .setContentTitle(context.getString(R.string.download_report_content_title))
- .setContentText(
- String.format(
+ boolean autoDownloadReport = failedDownloads == 0;
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(
+ context,
+ autoDownloadReport ? NotificationUtils.CHANNEL_ID_AUTO_DOWNLOAD : NotificationUtils.CHANNEL_ID_ERROR);
+ builder.setTicker(context.getString(R.string.download_report_title))
+ .setContentTitle(context.getString(R.string.download_report_content_title))
+ .setContentText(String.format(
context.getString(R.string.download_report_content),
- successfulDownloads, failedDownloads)
- )
- .setSmallIcon(R.drawable.stat_notify_sync_error)
- .setContentIntent(
- ClientConfig.downloadServiceCallbacks.getReportNotificationContentIntent(context)
- )
+ successfulDownloads, failedDownloads))
+ .setSmallIcon(autoDownloadReport ? R.drawable.stat_notify_sync : R.drawable.stat_notify_sync_error)
+ .setContentIntent(ClientConfig.downloadServiceCallbacks.getReportNotificationContentIntent(context))
.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java
index 02e98ba84..665d0fe79 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java
@@ -14,6 +14,7 @@ public class NotificationUtils {
public static final String CHANNEL_ID_DOWNLOADING = "downloading";
public static final String CHANNEL_ID_PLAYING = "playing";
public static final String CHANNEL_ID_ERROR = "error";
+ public static final String CHANNEL_ID_AUTO_DOWNLOAD = "auto_download";
public static void createChannels(Context context) {
if (android.os.Build.VERSION.SDK_INT < 26) {
@@ -26,6 +27,7 @@ public class NotificationUtils {
mNotificationManager.createNotificationChannel(createChannelDownloading(context));
mNotificationManager.createNotificationChannel(createChannelPlaying(context));
mNotificationManager.createNotificationChannel(createChannelError(context));
+ mNotificationManager.createNotificationChannel(createChannelAutoDownload(context));
}
}
@@ -62,4 +64,14 @@ public class NotificationUtils {
mChannel.setDescription(c.getString(R.string.notification_channel_error_description));
return mChannel;
}
+
+ @RequiresApi(api = Build.VERSION_CODES.O)
+ private static NotificationChannel createChannelAutoDownload(Context c) {
+ NotificationChannel mChannel = new NotificationChannel(
+ CHANNEL_ID_AUTO_DOWNLOAD,
+ c.getString(R.string.notification_channel_auto_download),
+ NotificationManager.IMPORTANCE_DEFAULT);
+ mChannel.setDescription(c.getString(R.string.notification_channel_downloading_description));
+ return mChannel;
+ }
}
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 54b6a9f4d..023bf0310 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -236,7 +236,7 @@
<string name="download_error_forbidden">Forbidden</string>
<string name="download_canceled_msg">Download canceled</string>
<string name="download_canceled_autodownload_enabled_msg">Download canceled\nDisabled <i>Auto Download</i> for this item</string>
- <string name="download_report_title">Downloads completed with error(s)</string>
+ <string name="download_report_title">Downloads completed</string>
<string name="download_report_content_title">Download Report</string>
<string name="download_error_malformed_url">Malformed URL</string>
<string name="download_error_io_error">IO Error</string>
@@ -783,6 +783,8 @@
<string name="notification_channel_playing_description">Allows to control playback. This is the main notification you see while playing a podcast.</string>
<string name="notification_channel_error">Errors</string>
<string name="notification_channel_error_description">Shown if something went wrong, for example if download or gpodder sync fails.</string>
+ <string name="notification_channel_auto_download">Auto Downloads</string>
+ <string name="notification_channel_error_auto_download">Shown when episodes are automatically downloaded.</string>
<!-- Widget settings -->
<string name="widget_settings">Widget settings</string>