From 708889eed754b6ad965ba831ef1bdc549af33b3d Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Tue, 12 Sep 2023 05:06:30 +0200 Subject: [PATCH] Use setFailed for errors when sending/receiving files --- .../Plugins/SharePlugin/CompositeReceiveFileJob.java | 2 +- .../Plugins/SharePlugin/CompositeUploadFileJob.java | 4 ++-- .../kdeconnect/Plugins/SharePlugin/ReceiveNotification.java | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeReceiveFileJob.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeReceiveFileJob.java index 3b068036..974723f1 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeReceiveFileJob.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeReceiveFileJob.java @@ -241,7 +241,7 @@ public class CompositeReceiveFileJob extends BackgroundJob { failedFiles = (totalNumFiles - currentFileNum + 1); } - receiveNotification.setFinished(getDevice().getContext().getResources().getQuantityString(R.plurals.received_files_fail_title, failedFiles, getDevice().getName(), failedFiles, totalNumFiles)); + receiveNotification.setFailed(getDevice().getContext().getResources().getQuantityString(R.plurals.received_files_fail_title, failedFiles, getDevice().getName(), failedFiles, totalNumFiles)); receiveNotification.show(); reportError(e); } finally { diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeUploadFileJob.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeUploadFileJob.java index ef4a9389..15572a9f 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeUploadFileJob.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeUploadFileJob.java @@ -127,7 +127,7 @@ public class CompositeUploadFileJob extends BackgroundJob { int failedFiles; synchronized (lock) { failedFiles = (totalNumFiles - currentFileNum + 1); - uploadNotification.setFinished(getDevice().getContext().getResources() + uploadNotification.setFailed(getDevice().getContext().getResources() .getQuantityString(R.plurals.send_files_fail_title, failedFiles, getDevice().getName(), failedFiles, totalNumFiles)); } @@ -229,7 +229,7 @@ public class CompositeUploadFileJob extends BackgroundJob { @Override public void onFailure(Throwable e) { - //Ignored + // Handled in the run() function when sendPacketBlocking returns false } } } diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java index 9c89e6c8..aa7fe737 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/ReceiveNotification.java @@ -99,6 +99,11 @@ class ReceiveNotification { } } + public void setFailed(String message) { + setFinished(message); + builder.setSmallIcon(android.R.drawable.stat_notify_error); + } + public void setURI(Uri destinationUri, String mimeType, String filename) { /* * We only support file URIs (because sending a content uri to another app does not work for security reasons).