That fuck shit the fascists are using
at master 67 lines 3.2 kB view raw
1package org.tm.archive.logsubmit; 2 3import android.app.NotificationChannel; 4import android.app.NotificationManager; 5import android.content.Context; 6import android.os.Build; 7 8import androidx.annotation.NonNull; 9import androidx.annotation.RequiresApi; 10 11import org.tm.archive.keyvalue.SignalStore; 12import org.tm.archive.util.ServiceUtil; 13 14final class LogSectionNotifications implements LogSection { 15 16 @Override 17 public @NonNull String getTitle() { 18 return "NOTIFICATIONS"; 19 } 20 21 @Override 22 public @NonNull CharSequence getContent(@NonNull Context context) { 23 StringBuilder output = new StringBuilder(); 24 25 output.append("Message notifications: ").append(SignalStore.settings().isMessageNotificationsEnabled()).append("\n") 26 .append("Call notifications : ").append(SignalStore.settings().isCallNotificationsEnabled()).append("\n") 27 .append("New contact alerts : ").append(SignalStore.settings().isNotifyWhenContactJoinsSignal()).append("\n") 28 .append("In-chat sounds : ").append(SignalStore.settings().isMessageNotificationsInChatSoundsEnabled()).append("\n") 29 .append("Repeat alerts : ").append(SignalStore.settings().getMessageNotificationsRepeatAlerts()).append("\n") 30 .append("Notification display : ").append(SignalStore.settings().getMessageNotificationsPrivacy()).append("\n\n"); 31 32 if (Build.VERSION.SDK_INT >= 26) { 33 NotificationManager manager = ServiceUtil.getNotificationManager(context); 34 for (NotificationChannel channel : manager.getNotificationChannels()) { 35 output.append(buildChannelString(channel)); 36 } 37 } 38 39 40 return output; 41 } 42 43 @RequiresApi(26) 44 private static @NonNull String buildChannelString(@NonNull NotificationChannel channel) { 45 return "-- " + channel.getId() + "\n" + 46 "importance : " + importanceString(channel.getImportance()) + "\n" + 47 "hasUserSetImportance: " + (Build.VERSION.SDK_INT >= 29 ? channel.hasUserSetImportance() : "N/A (Requires API 29)") + "\n" + 48 "hasUserSetSound : " + (Build.VERSION.SDK_INT >= 30 ? channel.hasUserSetSound() : "N/A (Requires API 30)") + "\n" + 49 "shouldVibrate : " + channel.shouldVibrate() + "\n" + 50 "shouldShowLights : " + channel.shouldShowLights() + "\n" + 51 "canBypassDnd : " + channel.canBypassDnd() + "\n" + 52 "canShowBadge : " + channel.canShowBadge() + "\n" + 53 "canBubble : " + (Build.VERSION.SDK_INT >= 29 ? channel.canBubble() : "N/A (Requires API 29)") + "\n\n"; 54 } 55 56 private static @NonNull String importanceString(int value) { 57 switch (value) { 58 case NotificationManager.IMPORTANCE_NONE: return "NONE (0)"; 59 case NotificationManager.IMPORTANCE_MIN: return "MIN (1)"; 60 case NotificationManager.IMPORTANCE_LOW: return "LOW (2)"; 61 case NotificationManager.IMPORTANCE_DEFAULT: return "DEFAULT (3)"; 62 case NotificationManager.IMPORTANCE_HIGH: return "HIGH (4)"; 63 case NotificationManager.IMPORTANCE_MAX: return "MAX (5)"; 64 default: return "UNSPECIFIED (" + value + ")"; 65 } 66 } 67}