use correct color of account for push notification

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2019-01-29 13:33:06 +01:00
parent 4b9985303b
commit ffb61f3e72
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7

View file

@ -37,6 +37,7 @@ import com.google.gson.Gson;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.DecryptedPushMessage;
import com.owncloud.android.datamodel.SignatureVerification;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.activity.NotificationsActivity;
import com.owncloud.android.ui.notifications.NotificationUtils;
import com.owncloud.android.utils.PushUtils;
@ -88,7 +89,7 @@ public class NotificationJob extends Job {
DecryptedPushMessage.class);
// We ignore Spreed messages for now
if (!decryptedPushMessage.getApp().equals("spreed")) {
if (!"spreed".equals(decryptedPushMessage.getApp())) {
sendNotification(decryptedPushMessage.getSubject(), signatureVerification.getAccount());
}
}
@ -112,23 +113,27 @@ public class NotificationJob extends Job {
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.notification_icon))
.setColor(ThemeUtils.primaryColor(context))
.setShowWhen(true)
.setSubText(account.name)
.setContentTitle(contentTitle)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setAutoCancel(true)
.setContentIntent(pendingIntent);
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.notification_icon))
.setColor(ThemeUtils.primaryColor(account, false, context))
.setShowWhen(true)
.setSubText(account.name)
.setContentTitle(contentTitle)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setAutoCancel(true)
.setContentIntent(pendingIntent);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
notificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_PUSH);
}
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
if (notificationManager != null) {
notificationManager.notify(0, notificationBuilder.build());
} else {
Log_OC.e(this, "Cannot notify about received push notification: NotificationManager is null");
}
}
}