1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-09 09:16:02 -08:00

Enable providing icons for Android desktop notifications

* doc/lispref/os.texi (Desktop Notifications)
<android-notifications-notify>: Mention the :icon parameter.

* java/org/gnu/emacs/EmacsDesktopNotification.java
(EmacsDesktopNotification) <icon>: New field.
(<init>): New argument ICON.  Set this.icon to its value.
(display1): Use provided icon and always supply a pending intent
to open Emacs once the notification is clicked.

* java/res/layout/sdk8_notifications_view.xml
(sdk8_notifications_title, sdk8_notifications_content): Set
foreground color to #000000.

* src/androidselect.c (android_init_emacs_desktop_notification):
Update signature of <init>.
(android_locate_icon): New function.
(android_notifications_notify_1): New arg ICON.
(Fandroid_notifications_notify): New parameter icon.
(syms_of_androidselect): <QCicon>: New symbol.
This commit is contained in:
Po Lu 2023-08-21 09:36:52 +08:00
parent 652e45b70d
commit b1e498ac8c
4 changed files with 99 additions and 21 deletions

View file

@ -60,17 +60,22 @@ public final class EmacsDesktopNotification
function. */
public final String tag;
/* The identifier of this notification's icon. */
public final int icon;
/* The importance of this notification's group. */
public final int importance;
public
EmacsDesktopNotification (String title, String content,
String group, String tag, int importance)
String group, String tag, int icon,
int importance)
{
this.content = content;
this.title = title;
this.group = group;
this.tag = tag;
this.icon = icon;
this.importance = importance;
}
@ -107,19 +112,19 @@ public final class EmacsDesktopNotification
notification = (new Notification.Builder (context, group)
.setContentTitle (title)
.setContentText (content)
.setSmallIcon (R.drawable.emacs)
.setSmallIcon (icon)
.build ());
}
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
notification = (new Notification.Builder (context)
.setContentTitle (title)
.setContentText (content)
.setSmallIcon (R.drawable.emacs)
.setSmallIcon (icon)
.build ());
else
{
notification = new Notification ();
notification.icon = R.drawable.emacs;
notification.icon = icon;
/* This remote widget tree is defined in
java/res/layout/sdk8_notifications_view.xml. */
@ -131,16 +136,22 @@ public final class EmacsDesktopNotification
title);
contentView.setTextViewText (R.id.sdk8_notifications_content,
content);
/* A content intent must be provided on these old versions of
Android. */
intent = new Intent (context, EmacsActivity.class);
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
pending = PendingIntent.getActivity (context, 0, intent, 0);
notification.contentIntent = pending;
}
/* Provide a content intent which starts Emacs when the
notification is clicked. */
intent = new Intent (context, EmacsActivity.class);
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S)
pending = PendingIntent.getActivity (context, 0, intent,
PendingIntent.FLAG_IMMUTABLE);
else
pending = PendingIntent.getActivity (context, 0, intent, 0);
notification.contentIntent = pending;
manager.notify (tag, 2, notification);
}