From b3ad002eccbd972c24588447e79a28cacadaa61a Mon Sep 17 00:00:00 2001 From: Next Alone <12210746+NextAlone@users.noreply.github.com> Date: Sun, 20 Oct 2024 02:46:35 +0800 Subject: [PATCH] WIP: modify notification style on Xiaomi devices [WARNING] This update affects MIUI and Hyper OS users. Please note that it may impact the way multi-line notifications are expanded. If you encounter any issues, feel free to reach out to me. Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com> --- .../messenger/NotificationsController.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java index 7e3ccde97d..3d4abb97de 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java @@ -3373,6 +3373,19 @@ private boolean unsupportedNotificationShortcut() { @SuppressLint("RestrictedApi") private String createNotificationShortcut(NotificationCompat.Builder builder, long did, String name, TLRPC.User user, TLRPC.Chat chat, Person person, boolean supportsBubble) { + Bitmap avatar = null; + if (person != null) { + if (person.getIcon() != null) { + avatar = person.getIcon().getBitmap(); + } + } + if (avatar != null) { + builder.setLargeIcon(avatar); + } else if (user != null) { + builder.setLargeIcon(IconCompat.createWithResource(ApplicationLoader.applicationContext, user.bot ? R.drawable.book_bot : R.drawable.book_user).getBitmap()); + } else { + builder.setLargeIcon(IconCompat.createWithResource(ApplicationLoader.applicationContext, R.drawable.book_group).getBitmap()); + } if (unsupportedNotificationShortcut() || ChatObject.isChannel(chat) && !chat.megagroup) { return null; } @@ -3395,7 +3408,7 @@ private String createNotificationShortcut(NotificationCompat.Builder builder, lo .setLongLived(true) .setLocusId(new LocusIdCompat(id)); - Bitmap avatar = null; +// Bitmap avatar = null; if (person != null) { shortcutBuilder.setPerson(person); shortcutBuilder.setIcon(person.getIcon()); @@ -3405,7 +3418,9 @@ private String createNotificationShortcut(NotificationCompat.Builder builder, lo } ShortcutInfoCompat shortcut = shortcutBuilder.build(); ShortcutManagerCompat.pushDynamicShortcut(ApplicationLoader.applicationContext, shortcut); - builder.setShortcutInfo(shortcut); + if (!"xiaomi".equalsIgnoreCase(Build.MANUFACTURER)) { + builder.setShortcutInfo(shortcut); + } Intent intent = new Intent(ApplicationLoader.applicationContext, BubbleActivity.class); intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE); if (DialogObject.isUserDialog(did)) {