Add new notification channel
This commit is contained in:
parent
052c86f43b
commit
7a93f1e513
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue