Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/Plugins/SharePlugin/ShareNotification.java
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
43 | import java.io.InputStream; | 43 | import java.io.InputStream; | ||
44 | 44 | | |||
45 | //TODO: Starting API 24 notification title and text are both displayed on 1 line above the progress bar. Because title can be long, the text is often not displayed | 45 | //TODO: Starting API 24 notification title and text are both displayed on 1 line above the progress bar. Because title can be long, the text is often not displayed | ||
46 | class ShareNotification { | 46 | class ShareNotification { | ||
47 | private final NotificationManager notificationManager; | 47 | private final NotificationManager notificationManager; | ||
48 | private final int notificationId; | 48 | private final int notificationId; | ||
49 | private NotificationCompat.Builder builder; | 49 | private NotificationCompat.Builder builder; | ||
50 | private final Device device; | 50 | private final Device device; | ||
51 | private long currentJobId; | ||||
51 | 52 | | |||
52 | //https://documentation.onesignal.com/docs/android-customizations#section-big-picture | 53 | //https://documentation.onesignal.com/docs/android-customizations#section-big-picture | ||
53 | private static final int bigImageWidth = 1440; | 54 | private static final int bigImageWidth = 1440; | ||
54 | private static final int bigImageHeight = 720; | 55 | private static final int bigImageHeight = 720; | ||
55 | 56 | | |||
56 | public ShareNotification(Device device) { | 57 | public ShareNotification(Device device) { | ||
57 | this.device = device; | 58 | this.device = device; | ||
58 | 59 | | |||
Show All 9 Lines | |||||
68 | public void show() { | 69 | public void show() { | ||
69 | NotificationHelper.notifyCompat(notificationManager, notificationId, builder.build()); | 70 | NotificationHelper.notifyCompat(notificationManager, notificationId, builder.build()); | ||
70 | } | 71 | } | ||
71 | 72 | | |||
72 | public void cancel() { | 73 | public void cancel() { | ||
73 | notificationManager.cancel(notificationId); | 74 | notificationManager.cancel(notificationId); | ||
74 | } | 75 | } | ||
75 | 76 | | |||
76 | public int getId() { | 77 | public void setJobId(long jobId) { | ||
78 | builder.mActions.clear(); | ||||
79 | | ||||
80 | currentJobId = jobId; | ||||
81 | Intent cancelIntent = new Intent(device.getContext(), ShareBroadcastReceiver.class); | ||||
82 | cancelIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); | ||||
83 | cancelIntent.setAction(SharePlugin.ACTION_CANCEL_SHARE); | ||||
84 | cancelIntent.putExtra(SharePlugin.CANCEL_SHARE_BACKGROUND_JOB_ID_EXTRA, jobId); | ||||
85 | cancelIntent.putExtra(SharePlugin.CANCEL_SHARE_DEVICE_ID_EXTRA, device.getDeviceId()); | ||||
86 | PendingIntent cancelPendingIntent = PendingIntent.getBroadcast(device.getContext(), 0, cancelIntent, PendingIntent.FLAG_UPDATE_CURRENT); | ||||
87 | | ||||
88 | builder.addAction(R.drawable.ic_reject_pairing, device.getContext().getString(R.string.cancel), cancelPendingIntent); | ||||
89 | } | ||||
90 | | ||||
91 | public long getCurrentJobId() { return currentJobId; } | ||||
92 | | ||||
93 | public int getNotificationId() { | ||||
albertvaka: Rename to addCancelButton or something like that? It does more than setting an id. | |||||
77 | return notificationId; | 94 | return notificationId; | ||
78 | } | 95 | } | ||
79 | 96 | | |||
80 | public void setTitle(String title) { | 97 | public void setTitle(String title) { | ||
81 | builder.setContentTitle(title); | 98 | builder.setContentTitle(title); | ||
82 | builder.setTicker(title); | 99 | builder.setTicker(title); | ||
83 | } | 100 | } | ||
84 | 101 | | |||
▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines |
Rename to addCancelButton or something like that? It does more than setting an id.