Skip to content

Commit

Permalink
WIP: modify notification style on Xiaomi devices
Browse files Browse the repository at this point in the history
[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 <[email protected]>
  • Loading branch information
NextAlone committed Oct 19, 2024
1 parent 8be5521 commit b3ad002
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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());
Expand All @@ -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)) {
Expand Down

0 comments on commit b3ad002

Please sign in to comment.