mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 20:52:21 -05:00
Merge pull request #912 from SamWhited/update-foreground-notification
Add color / category to foreground notification
This commit is contained in:
commit
7df6ae9ef8
@ -118,7 +118,7 @@ public class NotificationService {
|
|||||||
.getSystemService(Context.POWER_SERVICE);
|
.getSystemService(Context.POWER_SERVICE);
|
||||||
|
|
||||||
final boolean isScreenOn;
|
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();
|
isScreenOn = pm.isScreenOn();
|
||||||
} else {
|
} else {
|
||||||
isScreenOn = pm.isInteractive();
|
isScreenOn = pm.isInteractive();
|
||||||
@ -134,10 +134,10 @@ public class NotificationService {
|
|||||||
|
|
||||||
final boolean isScreenOn = isInteractive();
|
final boolean isScreenOn = isInteractive();
|
||||||
|
|
||||||
if (this.mIsInForeground && isScreenOn
|
if (this.mIsInForeground && isScreenOn && this.mOpenConversation == message.getConversation()) {
|
||||||
&& this.mOpenConversation == message.getConversation()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (notifications) {
|
synchronized (notifications) {
|
||||||
final String conversationUuid = message.getConversationUuid();
|
final String conversationUuid = message.getConversationUuid();
|
||||||
if (notifications.containsKey(conversationUuid)) {
|
if (notifications.containsKey(conversationUuid)) {
|
||||||
@ -156,7 +156,6 @@ public class NotificationService {
|
|||||||
notifyPebble(message);
|
notifyPebble(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
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) {
|
private void updateNotification(final boolean notify) {
|
||||||
final NotificationManager notificationManager = (NotificationManager) mXmppConnectionService
|
final NotificationManager notificationManager = (NotificationManager) mXmppConnectionService
|
||||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
@ -205,8 +208,8 @@ public class NotificationService {
|
|||||||
}
|
}
|
||||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
mBuilder.setCategory(Notification.CATEGORY_MESSAGE);
|
mBuilder.setCategory(Notification.CATEGORY_MESSAGE);
|
||||||
mBuilder.setColor(mXmppConnectionService.getResources().getColor(R.color.primary));
|
|
||||||
}
|
}
|
||||||
|
setNotificationColor(mBuilder);
|
||||||
mBuilder.setSmallIcon(R.drawable.ic_notification);
|
mBuilder.setSmallIcon(R.drawable.ic_notification);
|
||||||
mBuilder.setDeleteIntent(createDeleteIntent());
|
mBuilder.setDeleteIntent(createDeleteIntent());
|
||||||
mBuilder.setLights(0xffffffff, 2000, 4000);
|
mBuilder.setLights(0xffffffff, 2000, 4000);
|
||||||
@ -452,6 +455,10 @@ public class NotificationService {
|
|||||||
mBuilder.setContentIntent(createOpenConversationsIntent());
|
mBuilder.setContentIntent(createOpenConversationsIntent());
|
||||||
mBuilder.setWhen(0);
|
mBuilder.setWhen(0);
|
||||||
mBuilder.setPriority(NotificationCompat.PRIORITY_MIN);
|
mBuilder.setPriority(NotificationCompat.PRIORITY_MIN);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
mBuilder.setCategory(Notification.CATEGORY_SERVICE);
|
||||||
|
}
|
||||||
|
setNotificationColor(mBuilder);
|
||||||
return mBuilder.build();
|
return mBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user