NotificationManager: add support for icons

This commit is contained in:
Julian Winkler
2024-03-18 14:37:56 +01:00
parent 45de09a191
commit acb00a8beb
5 changed files with 27 additions and 6 deletions

View File

@@ -51,6 +51,7 @@ public class Notification {
String title;
List<Action> actions = new ArrayList<Action>();
PendingIntent intent;
String iconPath;
public String toString() {
return "Notification [" + title + ", " + text + ", " + actions + "]";
@@ -65,7 +66,10 @@ public class Notification {
public Builder setWhen(long when) {return this;}
public Builder setSmallIcon(int icon, int level) {return this;}
public Builder setSmallIcon(int icon, int level) {
notification.iconPath = Context.this_application.getString(icon);
return this;
}
public Builder setContent(RemoteViews contentView) {return this;}

View File

@@ -29,7 +29,7 @@ public class NotificationManager {
actionName = notification.intent.intent.getAction();
className = notification.intent.intent.getComponent() != null ? notification.intent.intent.getComponent().getClassName() : null;
}
nativeShowNotification(builder, id, notification.title, notification.text, intentType, actionName, className);
nativeShowNotification(builder, id, notification.title, notification.text, notification.iconPath, intentType, actionName, className);
}
public void notify(int id, Notification notification) {
@@ -55,5 +55,5 @@ public class NotificationManager {
protected native long nativeInitBuilder();
protected native void nativeAddAction(long builder, String title, int intentType, String action, String className);
protected native void nativeShowNotification(long builder, int id, String title, String text, int intentType, String action, String className);
protected native void nativeShowNotification(long builder, int id, String title, String text, String iconPath, int intentType, String action, String className);
}