mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Merge pull request #1569 from alabiaga/patch-2
Notification shortcut update
This commit is contained in:
commit
c0125f27ea
1 changed files with 12 additions and 5 deletions
|
@ -2374,9 +2374,13 @@ public class NotificationsController extends BaseController {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean unsupportedNotificationShortcut() {
|
||||||
|
return Build.VERSION.SDK_INT < 29 || !SharedConfig.chatBubbles;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
private void createNotificationShortcut(NotificationCompat.Builder builder, int did, String name, TLRPC.User user, TLRPC.Chat chat, Person person) {
|
private void createNotificationShortcut(NotificationCompat.Builder builder, int did, String name, TLRPC.User user, TLRPC.Chat chat, Person person) {
|
||||||
if (Build.VERSION.SDK_INT < 29 || ChatObject.isChannel(chat) && !chat.megagroup || !SharedConfig.chatBubbles) {
|
if (unsupportedNotificationShortcut() || ChatObject.isChannel(chat) && !chat.megagroup) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -2397,10 +2401,7 @@ public class NotificationsController extends BaseController {
|
||||||
}
|
}
|
||||||
ArrayList<ShortcutInfoCompat> arrayList = new ArrayList<>(1);
|
ArrayList<ShortcutInfoCompat> arrayList = new ArrayList<>(1);
|
||||||
arrayList.add(shortcutBuilder.build());
|
arrayList.add(shortcutBuilder.build());
|
||||||
ArrayList<String> ids = new ArrayList<>(1);
|
|
||||||
ids.add(id);
|
|
||||||
ShortcutManagerCompat.addDynamicShortcuts(ApplicationLoader.applicationContext, arrayList);
|
ShortcutManagerCompat.addDynamicShortcuts(ApplicationLoader.applicationContext, arrayList);
|
||||||
ShortcutManagerCompat.removeDynamicShortcuts(ApplicationLoader.applicationContext, ids);
|
|
||||||
builder.setShortcutId(id);
|
builder.setShortcutId(id);
|
||||||
NotificationCompat.BubbleMetadata.Builder bubbleBuilder = new NotificationCompat.BubbleMetadata.Builder();
|
NotificationCompat.BubbleMetadata.Builder bubbleBuilder = new NotificationCompat.BubbleMetadata.Builder();
|
||||||
Intent intent = new Intent(ApplicationLoader.applicationContext, BubbleActivity.class);
|
Intent intent = new Intent(ApplicationLoader.applicationContext, BubbleActivity.class);
|
||||||
|
@ -3737,8 +3738,14 @@ public class NotificationsController extends BaseController {
|
||||||
notificationManager.cancel(notificationId);
|
notificationManager.cancel(notificationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ArrayList<String> ids = new ArrayList<>(holders.size());
|
||||||
for (int a = 0, size = holders.size(); a < size; a++) {
|
for (int a = 0, size = holders.size(); a < size; a++) {
|
||||||
holders.get(a).call();
|
NotificationHolder holder = holders.get(a);
|
||||||
|
holder.call();
|
||||||
|
ids.add(holder.notification.getShortcutId());
|
||||||
|
}
|
||||||
|
if (!unsupportedNotificationShortcut()) {
|
||||||
|
ShortcutManagerCompat.removeDynamicShortcuts(ApplicationLoader.applicationContext, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int a = 0; a < oldIdsWear.size(); a++) {
|
for (int a = 0; a < oldIdsWear.size(); a++) {
|
||||||
|
|
Loading…
Reference in a new issue