Differential D9514 Diff 30362 src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java
Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/Plugins/ReceiveNotificationsPlugin/ReceiveNotificationsPlugin.java
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 87 | if (np.hasPayload()) { | |||
---|---|---|---|---|---|
100 | if (largeIcon != null) { | 100 | if (largeIcon != null) { | ||
101 | //Log.i("NotificationsPlugin", "hasPayload: size=" + largeIcon.getWidth() + "/" + largeIcon.getHeight() + " opti=" + width + "/" + height); | 101 | //Log.i("NotificationsPlugin", "hasPayload: size=" + largeIcon.getWidth() + "/" + largeIcon.getHeight() + " opti=" + width + "/" + height); | ||
102 | if (largeIcon.getWidth() > width || largeIcon.getHeight() > height) { | 102 | if (largeIcon.getWidth() > width || largeIcon.getHeight() > height) { | ||
103 | // older API levels don't scale notification icons automatically, therefore: | 103 | // older API levels don't scale notification icons automatically, therefore: | ||
104 | largeIcon = Bitmap.createScaledBitmap(largeIcon, width, height, false); | 104 | largeIcon = Bitmap.createScaledBitmap(largeIcon, width, height, false); | ||
105 | } | 105 | } | ||
106 | } | 106 | } | ||
107 | } | 107 | } | ||
108 | Notification noti = new NotificationCompat.Builder(context) | 108 | | ||
109 | NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); | ||||
110 | | ||||
111 | Notification noti = new NotificationCompat.Builder(context, NotificationHelper.getDefaultChannelId(notificationManager)) | ||||
109 | .setContentTitle(np.getString("appName")) | 112 | .setContentTitle(np.getString("appName")) | ||
110 | .setContentText(np.getString("ticker")) | 113 | .setContentText(np.getString("ticker")) | ||
111 | .setContentIntent(resultPendingIntent) | 114 | .setContentIntent(resultPendingIntent) | ||
112 | .setTicker(np.getString("ticker")) | 115 | .setTicker(np.getString("ticker")) | ||
113 | .setSmallIcon(R.drawable.ic_notification) | 116 | .setSmallIcon(R.drawable.ic_notification) | ||
114 | .setLargeIcon(largeIcon) | 117 | .setLargeIcon(largeIcon) | ||
115 | .setAutoCancel(true) | 118 | .setAutoCancel(true) | ||
116 | .setLocalOnly(true) // to avoid bouncing the notification back to other kdeconnect nodes | 119 | .setLocalOnly(true) // to avoid bouncing the notification back to other kdeconnect nodes | ||
117 | .setDefaults(Notification.DEFAULT_ALL) | 120 | .setDefaults(Notification.DEFAULT_ALL) | ||
118 | .build(); | 121 | .build(); | ||
119 | 122 | | |||
120 | NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); | | |||
121 | NotificationHelper.notifyCompat(notificationManager, "kdeconnectId:" + np.getString("id", "0"), np.getInt("id", 0), noti); | 123 | NotificationHelper.notifyCompat(notificationManager, "kdeconnectId:" + np.getString("id", "0"), np.getInt("id", 0), noti); | ||
122 | 124 | | |||
123 | } | 125 | } | ||
124 | 126 | | |||
125 | return true; | 127 | return true; | ||
126 | } | 128 | } | ||
127 | 129 | | |||
128 | @Override | 130 | @Override | ||
Show All 10 Lines |