aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/services
diff options
context:
space:
mode:
authorSam Whited <sam@samwhited.com>2015-01-20 18:24:48 -0500
committerSam Whited <sam@samwhited.com>2015-01-20 20:32:27 -0500
commite42e0f88e131e904d248583156dd09aebb8c24c6 (patch)
tree9f2fa3dd51c34c9f9010afe50002bb1e3f1a5eba /src/main/java/eu/siacs/conversations/services
parent7839438f513c101f831ec47b3d0224df07835e51 (diff)
Add color / category to foreground notification
Diffstat (limited to 'src/main/java/eu/siacs/conversations/services')
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java21
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();
}