From 3781e1dd603f6c753be3e09fc6ee27e47d06f796 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Mon, 3 Jan 2022 16:34:08 -0500 Subject: [PATCH] Add notification profile information to debug log. --- .../LogSectionNotificationProfiles.kt | 38 +++++++++++++++++++ .../logsubmit/SubmitDebugLogRepository.java | 1 + 2 files changed, 39 insertions(+) create mode 100644 app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionNotificationProfiles.kt diff --git a/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionNotificationProfiles.kt b/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionNotificationProfiles.kt new file mode 100644 index 000000000..4175069b4 --- /dev/null +++ b/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionNotificationProfiles.kt @@ -0,0 +1,38 @@ +package org.thoughtcrime.securesms.logsubmit + +import android.content.Context +import org.thoughtcrime.securesms.database.SignalDatabase +import org.thoughtcrime.securesms.keyvalue.SignalStore +import org.thoughtcrime.securesms.notifications.profiles.NotificationProfile + +class LogSectionNotificationProfiles : LogSection { + override fun getTitle(): String = "NOTIFICATION PROFILES" + + override fun getContent(context: Context): CharSequence { + val profiles: List = SignalDatabase.notificationProfiles.getProfiles() + + val output = StringBuilder() + + output.append("Manually enabled profile: ${SignalStore.notificationProfileValues().manuallyEnabledProfile}\n") + output.append("Manually enabled until : ${SignalStore.notificationProfileValues().manuallyEnabledUntil}\n") + output.append("Manually disabled at : ${SignalStore.notificationProfileValues().manuallyDisabledAt}\n") + output.append("Now : ${System.currentTimeMillis()}\n\n") + + output.append("Profiles:\n") + if (profiles.isEmpty()) { + output.append(" No notification profiles") + } else { + profiles.forEach { profile -> + output.append(" Profile ${profile.id}\n") + output.append(" allowMentions : ${profile.allowAllMentions}\n") + output.append(" allowCalls : ${profile.allowAllCalls}\n") + output.append(" schedule enabled: ${profile.schedule.enabled}\n") + output.append(" schedule start : ${profile.schedule.start}\n") + output.append(" schedule end : ${profile.schedule.end}\n") + output.append(" schedule days : ${profile.schedule.daysEnabled.sorted()}\n") + } + } + + return output.toString() + } +} diff --git a/app/src/main/java/org/thoughtcrime/securesms/logsubmit/SubmitDebugLogRepository.java b/app/src/main/java/org/thoughtcrime/securesms/logsubmit/SubmitDebugLogRepository.java index 2a7392217..c20b5cda2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/logsubmit/SubmitDebugLogRepository.java +++ b/app/src/main/java/org/thoughtcrime/securesms/logsubmit/SubmitDebugLogRepository.java @@ -82,6 +82,7 @@ public class SubmitDebugLogRepository { add(new LogSectionPower()); } add(new LogSectionNotifications()); + add(new LogSectionNotificationProfiles()); add(new LogSectionKeyPreferences()); add(new LogSectionBadges()); add(new LogSectionPermissions());