add an option to clean notification channels
This commit is contained in:
parent
c85b411a3e
commit
9c31adf0db
@ -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<NotificationChannel> 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<NotificationChannelGroup> 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;
|
||||
}
|
||||
|
@ -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<String> 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);
|
||||
|
Loading…
Reference in New Issue
Block a user