committed by
Jannis Mattheis
parent
802e30fd36
commit
f5988754fa
@@ -56,16 +56,18 @@ public class PicassoHandler {
|
||||
.build();
|
||||
}
|
||||
|
||||
public Bitmap getImageFromUrl(String url) throws IOException {
|
||||
return picasso.load(url).get();
|
||||
}
|
||||
|
||||
public Bitmap getIcon(Long appId) {
|
||||
if (appId == -1) {
|
||||
return BitmapFactory.decodeResource(context.getResources(), R.drawable.gotify);
|
||||
}
|
||||
|
||||
try {
|
||||
return picasso.load(
|
||||
Utils.resolveAbsoluteUrl(
|
||||
settings.url() + "/", appIdToAppImage.get(appId)))
|
||||
.get();
|
||||
return getImageFromUrl(
|
||||
Utils.resolveAbsoluteUrl(settings.url() + "/", appIdToAppImage.get(appId)));
|
||||
} catch (IOException e) {
|
||||
Log.e("Could not load image for notification", e);
|
||||
}
|
||||
|
||||
@@ -314,6 +314,19 @@ public class WebSocketService extends Service {
|
||||
b.setContentText(message);
|
||||
b.setStyle(new NotificationCompat.BigTextStyle().bigText(formattedMessage));
|
||||
|
||||
String notificationImageUrl =
|
||||
Extras.getNestedValue(String.class, extras, "client::notification", "bigImageUrl");
|
||||
|
||||
if (notificationImageUrl != null) {
|
||||
try {
|
||||
b.setStyle(
|
||||
new NotificationCompat.BigPictureStyle()
|
||||
.bigPicture(picassoHandler.getImageFromUrl(notificationImageUrl)));
|
||||
} catch (Exception e) {
|
||||
Log.e("Error loading bigImageUrl", e);
|
||||
}
|
||||
}
|
||||
|
||||
NotificationManager notificationManager =
|
||||
(NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(Utils.longToInt(id), b.build());
|
||||
|
||||
Reference in New Issue
Block a user