2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 13:47:41 +00:00

Split file transfer error notification to a separate channel

This commit is contained in:
Albert Vaca Cintora 2023-09-12 05:43:33 +02:00
parent 2ba79a2f58
commit d0931f28a9
4 changed files with 13 additions and 3 deletions

View File

@ -360,6 +360,7 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted
<string name="notification_channel_media_control">Media control</string> <string name="notification_channel_media_control">Media control</string>
<string name="notification_channel_filetransfer">Incoming file transfer</string> <string name="notification_channel_filetransfer">Incoming file transfer</string>
<string name="notification_channel_filetransfer_upload">Outgoing file transfer</string> <string name="notification_channel_filetransfer_upload">Outgoing file transfer</string>
<string name="notification_channel_filetransfer_error">File transfer error</string>
<string name="notification_channel_high_priority">High priority</string> <string name="notification_channel_high_priority">High priority</string>
<string name="mpris_stop">Stop the current player</string> <string name="mpris_stop">Stop the current player</string>

View File

@ -31,6 +31,7 @@ public class NotificationHelper {
public final static String FILETRANSFER_DOWNLOAD = "filetransfer"; public final static String FILETRANSFER_DOWNLOAD = "filetransfer";
public final static String FILETRANSFER_UPLOAD = "filetransfer_upload"; public final static String FILETRANSFER_UPLOAD = "filetransfer_upload";
public final static String FILETRANSFER_ERROR = "filetransfer_error";
public final static String RECEIVENOTIFICATION = "receive"; public final static String RECEIVENOTIFICATION = "receive";
public final static String HIGHPRIORITY = "highpriority"; public final static String HIGHPRIORITY = "highpriority";
@ -77,6 +78,11 @@ public class NotificationHelper {
.setName(context.getString(R.string.notification_channel_filetransfer_upload)) .setName(context.getString(R.string.notification_channel_filetransfer_upload))
.setVibrationEnabled(false) .setVibrationEnabled(false)
.build(); .build();
final NotificationChannelCompat fileTransferErrorChannel = new NotificationChannelCompat
.Builder(Channels.FILETRANSFER_ERROR, NotificationManagerCompat.IMPORTANCE_HIGH)
.setName(context.getString(R.string.notification_channel_filetransfer_error))
.setVibrationEnabled(false)
.build();
final NotificationChannelCompat receiveNotificationChannel = new NotificationChannelCompat final NotificationChannelCompat receiveNotificationChannel = new NotificationChannelCompat
.Builder(Channels.RECEIVENOTIFICATION, NotificationManagerCompat.IMPORTANCE_DEFAULT) .Builder(Channels.RECEIVENOTIFICATION, NotificationManagerCompat.IMPORTANCE_DEFAULT)
.setName(context.getString(R.string.notification_channel_receivenotification)) .setName(context.getString(R.string.notification_channel_receivenotification))
@ -88,7 +94,7 @@ public class NotificationHelper {
final List<NotificationChannelCompat> channels = Arrays.asList(persistentChannel, final List<NotificationChannelCompat> channels = Arrays.asList(persistentChannel,
defaultChannel, mediaChannel, fileTransferDownloadChannel, fileTransferUploadChannel, defaultChannel, mediaChannel, fileTransferDownloadChannel, fileTransferUploadChannel,
receiveNotificationChannel, highPriorityChannel); fileTransferErrorChannel, receiveNotificationChannel, highPriorityChannel);
NotificationManagerCompat.from(context).createNotificationChannelsCompat(channels); NotificationManagerCompat.from(context).createNotificationChannelsCompat(channels);

View File

@ -101,7 +101,9 @@ class ReceiveNotification {
public void setFailed(String message) { public void setFailed(String message) {
setFinished(message); setFinished(message);
builder.setSmallIcon(android.R.drawable.stat_notify_error); builder.setSmallIcon(android.R.drawable.stat_notify_error)
.setChannelId(NotificationHelper.Channels.FILETRANSFER_ERROR);
} }
public void setURI(Uri destinationUri, String mimeType, String filename) { public void setURI(Uri destinationUri, String mimeType, String filename) {

View File

@ -79,7 +79,8 @@ class UploadNotification {
public void setFailed(String message) { public void setFailed(String message) {
setFinished(message); setFinished(message);
builder.setSmallIcon(android.R.drawable.stat_notify_error); builder.setSmallIcon(android.R.drawable.stat_notify_error)
.setChannelId(NotificationHelper.Channels.FILETRANSFER_ERROR);
} }
public void cancel() { public void cancel() {