mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Add support filter after backup export failure.
This commit is contained in:
committed by
Cody Henthorne
parent
eeae9579d9
commit
18f7a88d66
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2025 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.components.contactsupport
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import org.thoughtcrime.securesms.compose.ComposeDialogFragment
|
||||
import org.thoughtcrime.securesms.util.viewModel
|
||||
|
||||
/**
|
||||
* Three-option contact support dialog fragment.
|
||||
*/
|
||||
class ContactSupportDialogFragment : ComposeDialogFragment() {
|
||||
|
||||
companion object {
|
||||
private const val SUBJECT = "subject"
|
||||
private const val FILTER = "filter"
|
||||
|
||||
fun create(
|
||||
@StringRes subject: Int,
|
||||
@StringRes filter: Int
|
||||
): ContactSupportDialogFragment {
|
||||
return ContactSupportDialogFragment().apply {
|
||||
arguments = bundleOf(
|
||||
SUBJECT to subject,
|
||||
FILTER to filter
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val contactSupportViewModel: ContactSupportViewModel by viewModel {
|
||||
ContactSupportViewModel(
|
||||
showInitially = true
|
||||
)
|
||||
}
|
||||
|
||||
private val subject: Int by lazy { requireArguments().getInt(SUBJECT) }
|
||||
private val filter: Int by lazy { requireArguments().getInt(FILTER) }
|
||||
|
||||
@Composable
|
||||
override fun DialogContent() {
|
||||
val contactSupportState by contactSupportViewModel.state.collectAsStateWithLifecycle()
|
||||
|
||||
SendSupportEmailEffect(
|
||||
contactSupportState = contactSupportState,
|
||||
subjectRes = subject,
|
||||
filterRes = filter
|
||||
) {
|
||||
contactSupportViewModel.hideContactSupport()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
if (contactSupportState.show) {
|
||||
ContactSupportDialog(
|
||||
showInProgress = contactSupportState.showAsProgress,
|
||||
callbacks = contactSupportViewModel
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,12 @@ import org.thoughtcrime.securesms.logsubmit.SubmitDebugLogRepository
|
||||
/**
|
||||
* Intended to be used to drive [ContactSupportDialog].
|
||||
*/
|
||||
class ContactSupportViewModel : ViewModel(), ContactSupportCallbacks {
|
||||
class ContactSupportViewModel(
|
||||
val showInitially: Boolean = false
|
||||
) : ViewModel(), ContactSupportCallbacks {
|
||||
private val submitDebugLogRepository: SubmitDebugLogRepository = SubmitDebugLogRepository()
|
||||
|
||||
private val store: MutableStateFlow<ContactSupportState> = MutableStateFlow(ContactSupportState())
|
||||
private val store: MutableStateFlow<ContactSupportState> = MutableStateFlow(ContactSupportState(show = showInitially))
|
||||
|
||||
val state: StateFlow<ContactSupportState> = store.asStateFlow()
|
||||
|
||||
|
||||
@@ -72,6 +72,8 @@ import org.signal.core.util.getLength
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.backup.v2.BackupRepository
|
||||
import org.thoughtcrime.securesms.backup.v2.MessageBackupTier
|
||||
import org.thoughtcrime.securesms.backup.v2.ui.BackupAlert
|
||||
import org.thoughtcrime.securesms.backup.v2.ui.BackupAlertBottomSheet
|
||||
import org.thoughtcrime.securesms.components.settings.app.internal.backup.InternalBackupPlaygroundViewModel.DialogState
|
||||
import org.thoughtcrime.securesms.components.settings.app.internal.backup.InternalBackupPlaygroundViewModel.ScreenState
|
||||
import org.thoughtcrime.securesms.compose.ComposeFragment
|
||||
@@ -231,6 +233,12 @@ class InternalBackupPlaygroundFragment : ComposeFragment() {
|
||||
}
|
||||
.setNegativeButton("Cancel", null)
|
||||
.show()
|
||||
},
|
||||
onDisplayInitialBackupFailureSheet = {
|
||||
BackupRepository.displayInitialBackupFailureNotification()
|
||||
BackupAlertBottomSheet
|
||||
.create(BackupAlert.BackupFailed)
|
||||
.show(parentFragmentManager, null)
|
||||
}
|
||||
)
|
||||
},
|
||||
@@ -314,7 +322,8 @@ fun Screen(
|
||||
onImportEncryptedBackupFromDiskClicked: () -> Unit = {},
|
||||
onImportEncryptedBackupFromDiskDismissed: () -> Unit = {},
|
||||
onImportEncryptedBackupFromDiskConfirmed: (aci: String, backupKey: String) -> Unit = { _, _ -> },
|
||||
onDeleteRemoteBackup: () -> Unit = {}
|
||||
onDeleteRemoteBackup: () -> Unit = {},
|
||||
onDisplayInitialBackupFailureSheet: () -> Unit = {}
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val scrollState = rememberScrollState()
|
||||
@@ -506,11 +515,17 @@ fun Screen(
|
||||
|
||||
Dividers.Default()
|
||||
|
||||
Rows.TextRow(
|
||||
text = "Display initial backup failure sheet",
|
||||
label = "This will display the error sheet immediately and force the notification to display.",
|
||||
onClick = onDisplayInitialBackupFailureSheet
|
||||
)
|
||||
|
||||
Rows.TextRow(
|
||||
text = "Mark backup failure",
|
||||
label = "This will display the error sheet when returning to the chats list.",
|
||||
onClick = {
|
||||
SignalStore.backup.internalSetBackupFailedErrorState()
|
||||
BackupRepository.markBackupFailure()
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user