From d0931f28a96e5b09eff790237a6238d61ecc216a Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Tue, 12 Sep 2023 05:43:33 +0200 Subject: [PATCH] Split file transfer error notification to a separate channel --- res/values/strings.xml | 1 + src/org/kde/kdeconnect/Helpers/NotificationHelper.java | 8 +++++++- .../Plugins/SharePlugin/ReceiveNotification.java | 4 +++- .../Plugins/SharePlugin/UploadNotification.java | 3 ++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index b39bd8b3..6aca9c66 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -360,6 +360,7 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted Media control Incoming file transfer Outgoing file transfer + File transfer error High priority Stop the current player diff --git a/src/org/kde/kdeconnect/Helpers/NotificationHelper.java b/src/org/kde/kdeconnect/Helpers/NotificationHelper.java index bf6c89a2..5ef6512d 100644 --- a/src/org/kde/kdeconnect/Helpers/NotificationHelper.java +++ b/src/org/kde/kdeconnect/Helpers/NotificationHelper.java @@ -31,6 +31,7 @@ public class NotificationHelper { public final static String FILETRANSFER_DOWNLOAD = "filetransfer"; 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 HIGHPRIORITY = "highpriority"; @@ -77,6 +78,11 @@ public class NotificationHelper { .setName(context.getString(R.string.notification_channel_filetransfer_upload)) .setVibrationEnabled(false) .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 .Builder(Channels.RECEIVENOTIFICATION, NotificationManagerCompat.IMPORTANCE_DEFAULT) .setName(context.getString(R.string.notification_channel_receivenotification)) @@ -88,7 +94,7 @@ public class NotificationHelper { final List channels = Arrays.asList(persistentChannel, defaultChannel, mediaChannel, fileTransferDownloadChannel, fileTransferUploadChannel, - receiveNotificationChannel, highPriorityChannel); + fileTransferErrorChannel, receiveNotificationChannel, highPriorityChannel); NotificationManagerCompat.from(context).createNotificationChannelsCompat(channels); diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java index ec1eb22d..2046b144 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java @@ -101,7 +101,9 @@ class ReceiveNotification { public void setFailed(String 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) { diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/UploadNotification.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/UploadNotification.java index 44e12611..6457c325 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/UploadNotification.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/UploadNotification.java @@ -79,7 +79,8 @@ class UploadNotification { public void setFailed(String 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() {