From 4aa365e4ff4c72ea5e70a1c8e11299f4fb56821a Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Tue, 4 Jun 2019 12:50:35 +0000 Subject: [PATCH] Cleanup upload notification --- .../Plugins/SharePlugin/CompositeUploadFileJob.java | 3 +-- .../Plugins/SharePlugin/UploadNotification.java | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeUploadFileJob.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeUploadFileJob.java index a3d1b1e1..a9e22827 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeUploadFileJob.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/CompositeUploadFileJob.java @@ -65,8 +65,7 @@ public class CompositeUploadFileJob extends BackgroundJob { totalPayloadSize = 0; totalSend = 0; prevProgressPercentage = 0; - uploadNotification = new UploadNotification(getDevice()); - uploadNotification.addCancelAction(getId()); + uploadNotification = new UploadNotification(getDevice(), getId()); sendPacketStatusCallback = new SendPacketStatusCallback(); } diff --git a/src/org/kde/kdeconnect/Plugins/SharePlugin/UploadNotification.java b/src/org/kde/kdeconnect/Plugins/SharePlugin/UploadNotification.java index 14854318..37fc8f79 100644 --- a/src/org/kde/kdeconnect/Plugins/SharePlugin/UploadNotification.java +++ b/src/org/kde/kdeconnect/Plugins/SharePlugin/UploadNotification.java @@ -39,9 +39,11 @@ class UploadNotification { private NotificationCompat.Builder builder; private final int notificationId; private final Device device; + private long jobId; - UploadNotification(Device device) { + UploadNotification(Device device, long jobId) { this.device = device; + this.jobId = jobId; notificationId = (int) System.currentTimeMillis(); notificationManager = (NotificationManager) device.getContext().getSystemService(Context.NOTIFICATION_SERVICE); @@ -50,11 +52,10 @@ class UploadNotification { .setAutoCancel(true) .setOngoing(true) .setProgress(100, 0, true); + addCancelAction(); } - void addCancelAction(long jobId) { - builder.mActions.clear(); - + void addCancelAction() { Intent cancelIntent = new Intent(device.getContext(), ShareBroadcastReceiver.class); cancelIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); cancelIntent.setAction(SharePlugin.ACTION_CANCEL_SHARE);