Add logging when we display different alert sheets via the delegate.

This commit is contained in:
Alex Hart
2025-08-11 13:34:17 -03:00
committed by Greyson Parrelli
parent be41c2e8cb
commit 2988e22612

View File

@@ -12,6 +12,7 @@ import androidx.lifecycle.repeatOnLifecycle
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.signal.core.util.concurrent.SignalDispatchers
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.backup.v2.BackupRepository
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.keyvalue.protos.BackupDownloadNotifierState
@@ -22,21 +23,28 @@ import org.thoughtcrime.securesms.keyvalue.protos.BackupDownloadNotifierState
object BackupAlertDelegate {
private const val FRAGMENT_TAG = "BackupAlertFragmentTag"
private val TAG = Log.tag(BackupAlertDelegate::class)
@JvmStatic
fun delegate(fragmentManager: FragmentManager, lifecycle: Lifecycle) {
lifecycle.coroutineScope.launch {
lifecycle.repeatOnLifecycle(Lifecycle.State.RESUMED) {
if (BackupRepository.shouldDisplayBackupFailedSheet()) {
Log.d(TAG, "Displaying BackupFailed sheet.")
BackupAlertBottomSheet.create(BackupAlert.BackupFailed).show(fragmentManager, FRAGMENT_TAG)
} else if (BackupRepository.shouldDisplayCouldNotCompleteBackupSheet()) {
Log.d(TAG, "Displaying CouldNotCompleteBackup sheet.")
BackupAlertBottomSheet.create(BackupAlert.CouldNotCompleteBackup(daysSinceLastBackup = SignalStore.backup.daysSinceLastBackup)).show(fragmentManager, FRAGMENT_TAG)
} else if (BackupRepository.shouldDisplayBackupExpiredAndDowngradedSheet()) {
Log.d(TAG, "Displaying ExpiredAndDowngraded sheet.")
BackupAlertBottomSheet.create(BackupAlert.ExpiredAndDowngraded).show(fragmentManager, FRAGMENT_TAG)
} else if (BackupRepository.shouldDisplayNoManualBackupForTimeoutSheet()) {
Log.d(TAG, "Displaying NoManualBackupBottomSheet.")
NoManualBackupBottomSheet().show(fragmentManager, FRAGMENT_TAG)
BackupRepository.displayManualBackupNotCreatedInThresholdNotification()
} else if (BackupRepository.shouldDisplayOutOfRemoteStorageSpaceSheet()) {
Log.d(TAG, "Displaying NoRemoteStorageSpaceAvailableBottomSheet.")
NoRemoteStorageSpaceAvailableBottomSheet().show(fragmentManager, FRAGMENT_TAG)
}
displayBackupDownloadNotifier(fragmentManager)
@@ -48,9 +56,11 @@ object BackupAlertDelegate {
val downloadYourBackupToday = withContext(SignalDispatchers.IO) { BackupRepository.getDownloadYourBackupData() }
when (downloadYourBackupToday?.type) {
BackupDownloadNotifierState.Type.SHEET -> {
Log.d(TAG, "Displaying 'Download your backup today' sheet.")
BackupAlertBottomSheet.create(downloadYourBackupToday).show(fragmentManager, FRAGMENT_TAG)
}
BackupDownloadNotifierState.Type.DIALOG -> {
Log.d(TAG, "Displaying 'Download your backup today' dialog.")
DownloadYourBackupTodayDialog.create(downloadYourBackupToday).show(fragmentManager, FRAGMENT_TAG)
}
null -> Unit