Add new notification channel
This commit is contained in:
parent
052c86f43b
commit
7a93f1e513
|
@ -116,20 +116,19 @@ public class DownloadServiceNotification {
|
||||||
|
|
||||||
if (createReport) {
|
if (createReport) {
|
||||||
Log.d(TAG, "Creating report");
|
Log.d(TAG, "Creating report");
|
||||||
|
|
||||||
// create notification object
|
// create notification object
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context,
|
boolean autoDownloadReport = failedDownloads == 0;
|
||||||
NotificationUtils.CHANNEL_ID_ERROR)
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(
|
||||||
.setTicker(context.getString(R.string.download_report_title))
|
context,
|
||||||
.setContentTitle(context.getString(R.string.download_report_content_title))
|
autoDownloadReport ? NotificationUtils.CHANNEL_ID_AUTO_DOWNLOAD : NotificationUtils.CHANNEL_ID_ERROR);
|
||||||
.setContentText(
|
builder.setTicker(context.getString(R.string.download_report_title))
|
||||||
String.format(
|
.setContentTitle(context.getString(R.string.download_report_content_title))
|
||||||
|
.setContentText(String.format(
|
||||||
context.getString(R.string.download_report_content),
|
context.getString(R.string.download_report_content),
|
||||||
successfulDownloads, failedDownloads)
|
successfulDownloads, failedDownloads))
|
||||||
)
|
.setSmallIcon(autoDownloadReport ? R.drawable.stat_notify_sync : R.drawable.stat_notify_sync_error)
|
||||||
.setSmallIcon(R.drawable.stat_notify_sync_error)
|
.setContentIntent(ClientConfig.downloadServiceCallbacks.getReportNotificationContentIntent(context))
|
||||||
.setContentIntent(
|
|
||||||
ClientConfig.downloadServiceCallbacks.getReportNotificationContentIntent(context)
|
|
||||||
)
|
|
||||||
.setAutoCancel(true);
|
.setAutoCancel(true);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
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_DOWNLOADING = "downloading";
|
||||||
public static final String CHANNEL_ID_PLAYING = "playing";
|
public static final String CHANNEL_ID_PLAYING = "playing";
|
||||||
public static final String CHANNEL_ID_ERROR = "error";
|
public static final String CHANNEL_ID_ERROR = "error";
|
||||||
|
public static final String CHANNEL_ID_AUTO_DOWNLOAD = "auto_download";
|
||||||
|
|
||||||
public static void createChannels(Context context) {
|
public static void createChannels(Context context) {
|
||||||
if (android.os.Build.VERSION.SDK_INT < 26) {
|
if (android.os.Build.VERSION.SDK_INT < 26) {
|
||||||
|
@ -26,6 +27,7 @@ public class NotificationUtils {
|
||||||
mNotificationManager.createNotificationChannel(createChannelDownloading(context));
|
mNotificationManager.createNotificationChannel(createChannelDownloading(context));
|
||||||
mNotificationManager.createNotificationChannel(createChannelPlaying(context));
|
mNotificationManager.createNotificationChannel(createChannelPlaying(context));
|
||||||
mNotificationManager.createNotificationChannel(createChannelError(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));
|
mChannel.setDescription(c.getString(R.string.notification_channel_error_description));
|
||||||
return mChannel;
|
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_error_forbidden">Forbidden</string>
|
||||||
<string name="download_canceled_msg">Download canceled</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_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_report_content_title">Download Report</string>
|
||||||
<string name="download_error_malformed_url">Malformed URL</string>
|
<string name="download_error_malformed_url">Malformed URL</string>
|
||||||
<string name="download_error_io_error">IO Error</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_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">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_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 -->
|
<!-- Widget settings -->
|
||||||
<string name="widget_settings">Widget settings</string>
|
<string name="widget_settings">Widget settings</string>
|
||||||
|
|
Loading…
Reference in New Issue