2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 06:05:12 +00:00

Use setFailed for errors when sending/receiving files

This commit is contained in:
Albert Vaca Cintora
2023-09-12 05:06:30 +02:00
parent 1096ace12c
commit 708889eed7
3 changed files with 8 additions and 3 deletions

View File

@@ -241,7 +241,7 @@ public class CompositeReceiveFileJob extends BackgroundJob<Device, Void> {
failedFiles = (totalNumFiles - currentFileNum + 1); 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(); receiveNotification.show();
reportError(e); reportError(e);
} finally { } finally {

View File

@@ -127,7 +127,7 @@ public class CompositeUploadFileJob extends BackgroundJob<Device, Void> {
int failedFiles; int failedFiles;
synchronized (lock) { synchronized (lock) {
failedFiles = (totalNumFiles - currentFileNum + 1); failedFiles = (totalNumFiles - currentFileNum + 1);
uploadNotification.setFinished(getDevice().getContext().getResources() uploadNotification.setFailed(getDevice().getContext().getResources()
.getQuantityString(R.plurals.send_files_fail_title, failedFiles, getDevice().getName(), .getQuantityString(R.plurals.send_files_fail_title, failedFiles, getDevice().getName(),
failedFiles, totalNumFiles)); failedFiles, totalNumFiles));
} }
@@ -229,7 +229,7 @@ public class CompositeUploadFileJob extends BackgroundJob<Device, Void> {
@Override @Override
public void onFailure(Throwable e) { public void onFailure(Throwable e) {
//Ignored // Handled in the run() function when sendPacketBlocking returns false
} }
} }
} }

View File

@@ -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) { 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). * We only support file URIs (because sending a content uri to another app does not work for security reasons).