diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java index d54c4b998..f6e17b896 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java @@ -324,6 +324,47 @@ public class NotificationsController extends BaseController { }); } + public void cleanupNotificationChannels() { + notificationsQueue.postRunnable(() -> { + if (Build.VERSION.SDK_INT >= 26) { + try { + String keyStart = currentAccount + "channel"; + List list = systemNotificationManager.getNotificationChannels(); + int count = list.size(); + for (int a = 0; a < count; a++) { + NotificationChannel channel = list.get(a); + String id = channel.getId(); + if (id.startsWith(keyStart)) { + try { + systemNotificationManager.deleteNotificationChannel(id); + } catch (Exception e) { + FileLog.e(e); + } + if (BuildVars.LOGS_ENABLED) { + FileLog.d("delete channel cleanup " + id); + } + } + } + } catch (Throwable e) { + FileLog.e(e); + } + // Remove shits from 0552bcdc + try { + String keyGroup = currentAccount + "group"; + List list = systemNotificationManager.getNotificationChannelGroups(); + for (NotificationChannelGroup group : list) { + String id = group.getId(); + if (id.equals(keyGroup)) { + systemNotificationManager.deleteNotificationChannelGroup(id); + } + } + } catch (Throwable e) { + FileLog.e(e); + } + } + }); + } + public void setInChatSoundEnabled(boolean value) { inChatSoundEnabled = value; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index fe0218ac8..c747feae5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -3061,6 +3061,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. "Scan accounts", BuildVars.DEBUG_PRIVATE_VERSION ? "Clean app update" : null, BuildVars.DEBUG_PRIVATE_VERSION ? "Reset suggestions" : null, + "Reset all notification channels", }; builder.setItems(items, (dialog, which) -> { if (which == 0) { @@ -3151,11 +3152,13 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. SharedConfig.pendingAppUpdate = null; SharedConfig.saveConfig(); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.appUpdateAvailable); - } else if (which == 16) { + } else if (which == 17) { Set suggestions = getMessagesController().pendingSuggestions; suggestions.add("VALIDATE_PHONE_NUMBER"); suggestions.add("VALIDATE_PASSWORD"); getNotificationCenter().postNotificationName(NotificationCenter.newSuggestionsAvailable); + } else if (which == 18) { + getNotificationsController().cleanupNotificationChannels(); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);