Skip to content

Commit

Permalink
Merge pull request #3513 from nextcloud/wrongPush
Browse files Browse the repository at this point in the history
use correct color of account for push notification
  • Loading branch information
AndyScherzinger authored Jan 29, 2019
2 parents 8dce690 + ffb61f3 commit 95628f4
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/main/java/com/owncloud/android/jobs/NotificationJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
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;
Expand Down Expand Up @@ -88,7 +89,7 @@ protected Result onRunJob(@NonNull Params params) {
DecryptedPushMessage.class);

// We ignore Spreed messages for now
if (!decryptedPushMessage.getApp().equals("spreed")) {
if (!"spreed".equals(decryptedPushMessage.getApp())) {
sendNotification(decryptedPushMessage.getSubject(), signatureVerification.getAccount());
}
}
Expand All @@ -112,23 +113,27 @@ private void sendNotification(String contentTitle, Account account) {


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");
}
}
}

0 comments on commit 95628f4

Please sign in to comment.