mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-01 14:45:08 +00:00
Notifications plugin now uses payloads to send app icons (untested)
This commit is contained in:
@@ -172,10 +172,10 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotificationPosted(StatusBarNotification statusBarNotification) {
|
public void onNotificationPosted(StatusBarNotification statusBarNotification) {
|
||||||
onNotificationPosted(statusBarNotification, false);
|
sendNotification(statusBarNotification, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNotificationPosted(StatusBarNotification statusBarNotification, boolean requestAnswer) {
|
public void sendNotification(StatusBarNotification statusBarNotification, boolean requestAnswer) {
|
||||||
|
|
||||||
Notification notification = statusBarNotification.getNotification();
|
Notification notification = statusBarNotification.getNotification();
|
||||||
NotificationId id = NotificationId.fromNotification(statusBarNotification);
|
NotificationId id = NotificationId.fromNotification(statusBarNotification);
|
||||||
@@ -191,10 +191,11 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
|||||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||||
appIcon.compress(Bitmap.CompressFormat.PNG, 90, outStream);
|
appIcon.compress(Bitmap.CompressFormat.PNG, 90, outStream);
|
||||||
byte[] bitmapData = outStream.toByteArray();
|
byte[] bitmapData = outStream.toByteArray();
|
||||||
byte[] serializedBitmapData = Base64.encode(bitmapData, Base64.NO_WRAP);
|
//byte[] serializedBitmapData = Base64.encode(bitmapData, Base64.NO_WRAP);
|
||||||
String stringBitmapData = new String(serializedBitmapData, Charset.defaultCharset());
|
//String stringBitmapData = new String(serializedBitmapData, Charset.defaultCharset());
|
||||||
//The icon is super big, better sending it as a file transfer when we support that
|
//The icon is super big, better sending it as a file transfer when we support that
|
||||||
//np.set("base64icon", stringBitmapData);
|
//np.set("base64icon", stringBitmapData);
|
||||||
|
np.setPayload(bitmapData);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Log.e("NotificationsPlugin","Error retrieving icon");
|
Log.e("NotificationsPlugin","Error retrieving icon");
|
||||||
@@ -224,7 +225,7 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
|||||||
private void sendCurrentNotifications(NotificationReceiver service) {
|
private void sendCurrentNotifications(NotificationReceiver service) {
|
||||||
StatusBarNotification[] notifications = service.getActiveNotifications();
|
StatusBarNotification[] notifications = service.getActiveNotifications();
|
||||||
for (StatusBarNotification notification : notifications) {
|
for (StatusBarNotification notification : notifications) {
|
||||||
onNotificationPosted(notification, true);
|
sendNotification(notification, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user