aboutsummaryrefslogtreecommitdiffstats
path: root/java/org/gnu
diff options
context:
space:
mode:
Diffstat (limited to 'java/org/gnu')
-rw-r--r--java/org/gnu/emacs/EmacsDesktopNotification.java33
1 files changed, 22 insertions, 11 deletions
diff --git a/java/org/gnu/emacs/EmacsDesktopNotification.java b/java/org/gnu/emacs/EmacsDesktopNotification.java
index b73ef1022fa..c6ebbc6ae48 100644
--- a/java/org/gnu/emacs/EmacsDesktopNotification.java
+++ b/java/org/gnu/emacs/EmacsDesktopNotification.java
@@ -60,17 +60,22 @@ public final class EmacsDesktopNotification
60 function. */ 60 function. */
61 public final String tag; 61 public final String tag;
62 62
63 /* The identifier of this notification's icon. */
64 public final int icon;
65
63 /* The importance of this notification's group. */ 66 /* The importance of this notification's group. */
64 public final int importance; 67 public final int importance;
65 68
66 public 69 public
67 EmacsDesktopNotification (String title, String content, 70 EmacsDesktopNotification (String title, String content,
68 String group, String tag, int importance) 71 String group, String tag, int icon,
72 int importance)
69 { 73 {
70 this.content = content; 74 this.content = content;
71 this.title = title; 75 this.title = title;
72 this.group = group; 76 this.group = group;
73 this.tag = tag; 77 this.tag = tag;
78 this.icon = icon;
74 this.importance = importance; 79 this.importance = importance;
75 } 80 }
76 81
@@ -107,19 +112,19 @@ public final class EmacsDesktopNotification
107 notification = (new Notification.Builder (context, group) 112 notification = (new Notification.Builder (context, group)
108 .setContentTitle (title) 113 .setContentTitle (title)
109 .setContentText (content) 114 .setContentText (content)
110 .setSmallIcon (R.drawable.emacs) 115 .setSmallIcon (icon)
111 .build ()); 116 .build ());
112 } 117 }
113 else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) 118 else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
114 notification = (new Notification.Builder (context) 119 notification = (new Notification.Builder (context)
115 .setContentTitle (title) 120 .setContentTitle (title)
116 .setContentText (content) 121 .setContentText (content)
117 .setSmallIcon (R.drawable.emacs) 122 .setSmallIcon (icon)
118 .build ()); 123 .build ());
119 else 124 else
120 { 125 {
121 notification = new Notification (); 126 notification = new Notification ();
122 notification.icon = R.drawable.emacs; 127 notification.icon = icon;
123 128
124 /* This remote widget tree is defined in 129 /* This remote widget tree is defined in
125 java/res/layout/sdk8_notifications_view.xml. */ 130 java/res/layout/sdk8_notifications_view.xml. */
@@ -131,15 +136,21 @@ public final class EmacsDesktopNotification
131 title); 136 title);
132 contentView.setTextViewText (R.id.sdk8_notifications_content, 137 contentView.setTextViewText (R.id.sdk8_notifications_content,
133 content); 138 content);
139 }
134 140
135 /* A content intent must be provided on these old versions of 141 /* Provide a content intent which starts Emacs when the
136 Android. */ 142 notification is clicked. */
137 143
138 intent = new Intent (context, EmacsActivity.class); 144 intent = new Intent (context, EmacsActivity.class);
139 intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK); 145 intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
140 pending = PendingIntent.getActivity (context, 0, intent, 0); 146
141 notification.contentIntent = pending; 147 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S)
142 } 148 pending = PendingIntent.getActivity (context, 0, intent,
149 PendingIntent.FLAG_IMMUTABLE);
150 else
151 pending = PendingIntent.getActivity (context, 0, intent, 0);
152
153 notification.contentIntent = pending;
143 154
144 manager.notify (tag, 2, notification); 155 manager.notify (tag, 2, notification);
145 } 156 }