diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 2b431e70..b2731d19 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -135,6 +135,9 @@ + diff --git a/src/main/java/com/juick/android/service/FCMReceiverService.java b/src/main/java/com/juick/android/service/FCMReceiverService.java index f6f622e1..3e1ee130 100644 --- a/src/main/java/com/juick/android/service/FCMReceiverService.java +++ b/src/main/java/com/juick/android/service/FCMReceiverService.java @@ -24,6 +24,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; +import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Handler; import android.os.Looper; @@ -33,6 +34,7 @@ import android.text.TextUtils; import android.util.Log; +import androidx.annotation.Nullable; import androidx.core.app.NotificationCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; @@ -121,8 +123,7 @@ public static void showNotification(final String msgStr) { PendingIntent contentIntent = PendingIntent.getActivity(App.getInstance(), getId(jmsg), createNewEventIntent(msgStr), PendingIntent.FLAG_UPDATE_CURRENT); - final NotificationCompat.Builder notificationBuilder = Build.VERSION.SDK_INT < 26 ? - new NotificationCompat.Builder(App.getInstance()) : + final NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(App.getInstance(), channelId); notificationBuilder.setSmallIcon(R.drawable.ic_notification) .setContentTitle(title) @@ -130,9 +131,18 @@ public static void showNotification(final String msgStr) { .setAutoCancel(true).setWhen(0) .setContentIntent(contentIntent) .setGroup("messages") + .setColor(App.getInstance().getResources().getColor(R.color.colorAccent)) .setGroupSummary(true); + notificationBuilder.setCategory(NotificationCompat.CATEGORY_MESSAGE); notificationBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(jmsg.getBody())); + if (jmsg.getUser().getUid() > 0) { + notificationBuilder.addAction(Build.VERSION.SDK_INT <= 19 ? + R.drawable.ic_ab_reply2 : R.drawable.ic_ab_reply, + App.getInstance().getString(R.string.reply), PendingIntent.getActivity(App.getInstance(), + getId(jmsg), createNewEventIntent(msgStr), + PendingIntent.FLAG_UPDATE_CURRENT)); + } handler.post(() -> { GlideApp.with(App.getInstance()).asBitmap() .load(jmsg.getUser().getAvatar()) @@ -147,15 +157,12 @@ public void onResourceReady(@NonNull Bitmap resource, Transition } FCMReceiverService.notify(jmsg, notificationBuilder); } + + @Override + public void onLoadFailed(@Nullable Drawable errorDrawable) { + FCMReceiverService.notify(jmsg, notificationBuilder); + } }); - if (jmsg.getUser().getUid() > 0) { - notificationBuilder.addAction(Build.VERSION.SDK_INT <= 19 ? - R.drawable.ic_ab_reply2 : R.drawable.ic_ab_reply, - App.getInstance().getString(R.string.reply), PendingIntent.getActivity(App.getInstance(), - getId(jmsg), createNewEventIntent(msgStr), - PendingIntent.FLAG_UPDATE_CURRENT)); - } - notify(jmsg, notificationBuilder); }); } } catch (Exception e) { diff --git a/src/main/res/drawable-hdpi/ic_notification.png b/src/main/res/drawable-hdpi/ic_notification.png index 0ceb1168..ad0666ec 100644 Binary files a/src/main/res/drawable-hdpi/ic_notification.png and b/src/main/res/drawable-hdpi/ic_notification.png differ diff --git a/src/main/res/drawable-mdpi/ic_notification.png b/src/main/res/drawable-mdpi/ic_notification.png index d7b1836b..7a7955f1 100644 Binary files a/src/main/res/drawable-mdpi/ic_notification.png and b/src/main/res/drawable-mdpi/ic_notification.png differ diff --git a/src/main/res/drawable-xhdpi/ic_notification.png b/src/main/res/drawable-xhdpi/ic_notification.png index 4c8c55e9..a1fbc849 100644 Binary files a/src/main/res/drawable-xhdpi/ic_notification.png and b/src/main/res/drawable-xhdpi/ic_notification.png differ diff --git a/src/main/res/drawable-xxhdpi/ic_notification.png b/src/main/res/drawable-xxhdpi/ic_notification.png index ffa7bfe3..52761c32 100644 Binary files a/src/main/res/drawable-xxhdpi/ic_notification.png and b/src/main/res/drawable-xxhdpi/ic_notification.png differ diff --git a/src/main/res/drawable-xxxhdpi/ic_notification.png b/src/main/res/drawable-xxxhdpi/ic_notification.png new file mode 100644 index 00000000..6d3f128f Binary files /dev/null and b/src/main/res/drawable-xxxhdpi/ic_notification.png differ diff --git a/src/main/res/drawable/ic_notification.png b/src/main/res/drawable/ic_notification.png deleted file mode 100644 index 8f52788e..00000000 Binary files a/src/main/res/drawable/ic_notification.png and /dev/null differ diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml index 61cb406e..e9283e48 100644 --- a/src/main/res/values/colors.xml +++ b/src/main/res/values/colors.xml @@ -1,7 +1,7 @@ #f8f8f8 - #006699 + #3c77aa #fdfdff #222222 #888888