diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-01-21 11:48:36 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-01-21 11:48:36 +0100 |
commit | 7df6ae9ef88428c367f882433cf77b589e8e4c1e (patch) | |
tree | 9f2fa3dd51c34c9f9010afe50002bb1e3f1a5eba /src/main/java/eu | |
parent | 7839438f513c101f831ec47b3d0224df07835e51 (diff) | |
parent | e42e0f88e131e904d248583156dd09aebb8c24c6 (diff) |
Merge pull request #912 from SamWhited/update-foreground-notification
Add color / category to foreground notification
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/NotificationService.java | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 4f502102..894af421 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -118,7 +118,7 @@ public class NotificationService { .getSystemService(Context.POWER_SERVICE); final boolean isScreenOn; - if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { isScreenOn = pm.isScreenOn(); } else { isScreenOn = pm.isInteractive(); @@ -134,10 +134,10 @@ public class NotificationService { final boolean isScreenOn = isInteractive(); - if (this.mIsInForeground && isScreenOn - && this.mOpenConversation == message.getConversation()) { + if (this.mIsInForeground && isScreenOn && this.mOpenConversation == message.getConversation()) { return; - } + } + synchronized (notifications) { final String conversationUuid = message.getConversationUuid(); if (notifications.containsKey(conversationUuid)) { @@ -156,7 +156,6 @@ public class NotificationService { notifyPebble(message); } } - } public void clear() { @@ -173,6 +172,10 @@ public class NotificationService { } } + private void setNotificationColor(final Builder mBuilder) { + mBuilder.setColor(mXmppConnectionService.getResources().getColor(R.color.primary)); + } + private void updateNotification(final boolean notify) { final NotificationManager notificationManager = (NotificationManager) mXmppConnectionService .getSystemService(Context.NOTIFICATION_SERVICE); @@ -205,8 +208,8 @@ public class NotificationService { } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mBuilder.setCategory(Notification.CATEGORY_MESSAGE); - mBuilder.setColor(mXmppConnectionService.getResources().getColor(R.color.primary)); } + setNotificationColor(mBuilder); mBuilder.setSmallIcon(R.drawable.ic_notification); mBuilder.setDeleteIntent(createDeleteIntent()); mBuilder.setLights(0xffffffff, 2000, 4000); @@ -331,7 +334,7 @@ public class NotificationService { if ((message.getType() == Message.TYPE_FILE || message.getType() == Message.TYPE_IMAGE) && message.getDownloadable() != null) { return message; - } + } } return null; } @@ -452,6 +455,10 @@ public class NotificationService { mBuilder.setContentIntent(createOpenConversationsIntent()); mBuilder.setWhen(0); mBuilder.setPriority(NotificationCompat.PRIORITY_MIN); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + mBuilder.setCategory(Notification.CATEGORY_SERVICE); + } + setNotificationColor(mBuilder); return mBuilder.build(); } |