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

Cleanup upload notification

This commit is contained in:
Nicolas Fella
2019-06-04 12:50:35 +00:00
parent c50642e587
commit 4aa365e4ff
2 changed files with 6 additions and 6 deletions

View File

@@ -65,8 +65,7 @@ public class CompositeUploadFileJob extends BackgroundJob<Device, Void> {
totalPayloadSize = 0; totalPayloadSize = 0;
totalSend = 0; totalSend = 0;
prevProgressPercentage = 0; prevProgressPercentage = 0;
uploadNotification = new UploadNotification(getDevice()); uploadNotification = new UploadNotification(getDevice(), getId());
uploadNotification.addCancelAction(getId());
sendPacketStatusCallback = new SendPacketStatusCallback(); sendPacketStatusCallback = new SendPacketStatusCallback();
} }

View File

@@ -39,9 +39,11 @@ class UploadNotification {
private NotificationCompat.Builder builder; private NotificationCompat.Builder builder;
private final int notificationId; private final int notificationId;
private final Device device; private final Device device;
private long jobId;
UploadNotification(Device device) { UploadNotification(Device device, long jobId) {
this.device = device; this.device = device;
this.jobId = jobId;
notificationId = (int) System.currentTimeMillis(); notificationId = (int) System.currentTimeMillis();
notificationManager = (NotificationManager) device.getContext().getSystemService(Context.NOTIFICATION_SERVICE); notificationManager = (NotificationManager) device.getContext().getSystemService(Context.NOTIFICATION_SERVICE);
@@ -50,11 +52,10 @@ class UploadNotification {
.setAutoCancel(true) .setAutoCancel(true)
.setOngoing(true) .setOngoing(true)
.setProgress(100, 0, true); .setProgress(100, 0, true);
addCancelAction();
} }
void addCancelAction(long jobId) { void addCancelAction() {
builder.mActions.clear();
Intent cancelIntent = new Intent(device.getContext(), ShareBroadcastReceiver.class); Intent cancelIntent = new Intent(device.getContext(), ShareBroadcastReceiver.class);
cancelIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); cancelIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
cancelIntent.setAction(SharePlugin.ACTION_CANCEL_SHARE); cancelIntent.setAction(SharePlugin.ACTION_CANCEL_SHARE);