2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-29 13:17:43 +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;
totalSend = 0;
prevProgressPercentage = 0;
uploadNotification = new UploadNotification(getDevice());
uploadNotification.addCancelAction(getId());
uploadNotification = new UploadNotification(getDevice(), getId());
sendPacketStatusCallback = new SendPacketStatusCallback();
}

View File

@ -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);