Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 22e7b91b authored by Nicolas Fella's avatar Nicolas Fella

Cleanup ReceiveNotification

parent 4aa365e4
......@@ -66,8 +66,7 @@ public class CompositeReceiveFileJob extends BackgroundJob<Device, Void> {
lock = new Object();
networkPacketList = new ArrayList<>();
receiveNotification = new ReceiveNotification(device);
receiveNotification.addCancelAction(getId());
receiveNotification = new ReceiveNotification(device, getId());
currentFileNum = 0;
totalNumFiles = 0;
totalPayloadSize = 0;
......
......@@ -48,15 +48,16 @@ class ReceiveNotification {
private final int notificationId;
private NotificationCompat.Builder builder;
private final Device device;
private long currentJobId;
private long jobId;
//https://documentation.onesignal.com/docs/android-customizations#section-big-picture
private static final int bigImageWidth = 1440;
private static final int bigImageHeight = 720;
public ReceiveNotification(Device device) {
public ReceiveNotification(Device device, long jobId) {
this.device = device;
this.jobId = jobId;
notificationId = (int) System.currentTimeMillis();
notificationManager = (NotificationManager) device.getContext().getSystemService(Context.NOTIFICATION_SERVICE);
builder = new NotificationCompat.Builder(device.getContext(), NotificationHelper.Channels.FILETRANSFER)
......@@ -64,6 +65,7 @@ class ReceiveNotification {
.setAutoCancel(true)
.setOngoing(true)
.setProgress(100, 0, true);
addCancelAction();
}
public void show() {
......@@ -74,10 +76,8 @@ class ReceiveNotification {
notificationManager.cancel(notificationId);
}
public void addCancelAction(long jobId) {
builder.mActions.clear();
public void addCancelAction() {
currentJobId = jobId;
Intent cancelIntent = new Intent(device.getContext(), ShareBroadcastReceiver.class);
cancelIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
cancelIntent.setAction(SharePlugin.ACTION_CANCEL_SHARE);
......@@ -88,12 +88,6 @@ class ReceiveNotification {
builder.addAction(R.drawable.ic_reject_pairing, device.getContext().getString(R.string.cancel), cancelPendingIntent);
}
public long getCurrentJobId() { return currentJobId; }
public int getNotificationId() {
return notificationId;
}
public void setTitle(String title) {
builder.setContentTitle(title);
builder.setTicker(title);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment