mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-15 07:28:30 +00:00
Prevent users from continuing while issue is not specified.
This commit is contained in:
@@ -99,5 +99,9 @@ class CallQualityBottomSheetFragment : ComposeBottomSheetDialogFragment() {
|
||||
dismiss()
|
||||
setFragmentResult(REQUEST_KEY, bundleOf(REQUEST_KEY to true))
|
||||
}
|
||||
|
||||
override fun tryAgain() {
|
||||
viewModel.clearFailedDueToNetworkAvailability()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import kotlinx.coroutines.flow.update
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.storageservice.protos.calls.quality.SubmitCallQualitySurveyRequest
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||
import org.thoughtcrime.securesms.jobs.CallQualitySurveySubmissionJob
|
||||
|
||||
class CallQualityScreenViewModel(
|
||||
@@ -41,7 +42,17 @@ class CallQualityScreenViewModel(
|
||||
internalState.update { it.copy(isShareDebugLogSelected = shareDebugLog) }
|
||||
}
|
||||
|
||||
fun clearFailedDueToNetworkAvailability() {
|
||||
internalState.update { it.copy(failedDueToNetworkAvailability = false) }
|
||||
}
|
||||
|
||||
fun submit() {
|
||||
if (!NetworkConstraint.isMet(AppDependencies.application)) {
|
||||
Log.w(TAG, "User does not have a network connection. Failing immediately with retry dialog.")
|
||||
internalState.update { it.copy(failedDueToNetworkAvailability = true) }
|
||||
return
|
||||
}
|
||||
|
||||
if (initialRequest.call_type.isEmpty()) {
|
||||
Log.i(TAG, "Ignoring survey submission for blank call_type.")
|
||||
return
|
||||
|
||||
@@ -66,6 +66,7 @@ import androidx.compose.ui.text.withLink
|
||||
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.signal.core.ui.compose.Buttons
|
||||
import org.signal.core.ui.compose.Dialogs
|
||||
import org.signal.core.ui.compose.IconButtons
|
||||
import org.signal.core.ui.compose.Previews
|
||||
import org.signal.core.ui.compose.Rows
|
||||
@@ -80,6 +81,19 @@ fun CallQualitySheet(
|
||||
) {
|
||||
var navEntry: CallQualitySheetNavEntry by remember { mutableStateOf(CallQualitySheetNavEntry.HowWasYourCall) }
|
||||
|
||||
if (state.failedDueToNetworkAvailability) {
|
||||
Dialogs.SimpleAlertDialog(
|
||||
title = "",
|
||||
body = stringResource(R.string.CallQualitySheet__your_feedback_failed_to_send),
|
||||
confirm = stringResource(R.string.CallQualitySheet__try_again),
|
||||
onConfirm = callback::tryAgain,
|
||||
dismiss = stringResource(android.R.string.cancel),
|
||||
onDeny = callback::dismiss
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Sheet(onDismissRequest = callback::dismiss) {
|
||||
AnimatedContent(
|
||||
targetState = navEntry,
|
||||
@@ -106,7 +120,7 @@ fun CallQualitySheet(
|
||||
navEntry = CallQualitySheetNavEntry.HelpUsImprove
|
||||
},
|
||||
onHadIssuesClick = {
|
||||
callback.onUserSatisfiedWithCall(true)
|
||||
callback.onUserSatisfiedWithCall(false)
|
||||
navEntry = CallQualitySheetNavEntry.WhatIssuesDidYouHave
|
||||
},
|
||||
onCancelClick = callback::dismiss
|
||||
@@ -115,6 +129,7 @@ fun CallQualitySheet(
|
||||
CallQualitySheetNavEntry.WhatIssuesDidYouHave -> WhatIssuesDidYouHave(
|
||||
selectedQualityIssues = state.selectedQualityIssues,
|
||||
somethingElseDescription = state.somethingElseDescription,
|
||||
isContinueEnabled = state.canContinueAfterIssueSelection(),
|
||||
onCallQualityIssueSelectionChanged = callback::onCallQualityIssueSelectionChanged,
|
||||
onContinueClick = {
|
||||
navEntry = CallQualitySheetNavEntry.HelpUsImprove
|
||||
@@ -169,6 +184,7 @@ private fun ColumnScope.HowWasYourCall(
|
||||
private fun WhatIssuesDidYouHave(
|
||||
selectedQualityIssues: Set<CallQualityIssue>,
|
||||
somethingElseDescription: String,
|
||||
isContinueEnabled: Boolean,
|
||||
onCallQualityIssueSelectionChanged: (Set<CallQualityIssue>) -> Unit,
|
||||
onCancelClick: () -> Unit,
|
||||
onContinueClick: () -> Unit,
|
||||
@@ -352,7 +368,8 @@ private fun WhatIssuesDidYouHave(
|
||||
)
|
||||
|
||||
Buttons.LargeTonal(
|
||||
onClick = onContinueClick
|
||||
onClick = onContinueClick,
|
||||
enabled = isContinueEnabled
|
||||
) {
|
||||
Text(text = stringResource(R.string.CallQualitySheet__continue))
|
||||
}
|
||||
@@ -665,6 +682,7 @@ private fun WhatIssuesDidYouHavePreview() {
|
||||
WhatIssuesDidYouHave(
|
||||
selectedQualityIssues = userSelection,
|
||||
somethingElseDescription = "",
|
||||
isContinueEnabled = false,
|
||||
onCallQualityIssueSelectionChanged = {
|
||||
userSelection = it
|
||||
},
|
||||
@@ -708,8 +726,17 @@ data class CallQualitySheetState(
|
||||
val isUserSatisfiedWithCall: Boolean = false,
|
||||
val selectedQualityIssues: Set<CallQualityIssue> = emptySet(),
|
||||
val somethingElseDescription: String = "",
|
||||
val isShareDebugLogSelected: Boolean = false
|
||||
)
|
||||
val isShareDebugLogSelected: Boolean = false,
|
||||
val failedDueToNetworkAvailability: Boolean = false
|
||||
) {
|
||||
fun canContinueAfterIssueSelection(): Boolean {
|
||||
val isSomethingElseSelected = selectedQualityIssues.contains(CallQualityIssue.SOMETHING_ELSE)
|
||||
val isSomethingElseFieldComplete = somethingElseDescription.isNotEmpty()
|
||||
val isSomethingElseValid = isSomethingElseSelected && isSomethingElseFieldComplete || !isSomethingElseSelected
|
||||
|
||||
return selectedQualityIssues.isNotEmpty() && isSomethingElseValid
|
||||
}
|
||||
}
|
||||
|
||||
interface CallQualitySheetCallback {
|
||||
fun dismiss()
|
||||
@@ -719,6 +746,7 @@ interface CallQualitySheetCallback {
|
||||
fun onCallQualityIssueSelectionChanged(selection: Set<CallQualityIssue>)
|
||||
fun onShareDebugLogChanged(shareDebugLog: Boolean)
|
||||
fun submit()
|
||||
fun tryAgain()
|
||||
|
||||
object Empty : CallQualitySheetCallback {
|
||||
override fun dismiss() = Unit
|
||||
@@ -728,6 +756,7 @@ interface CallQualitySheetCallback {
|
||||
override fun onCallQualityIssueSelectionChanged(selection: Set<CallQualityIssue>) = Unit
|
||||
override fun onShareDebugLogChanged(shareDebugLog: Boolean) = Unit
|
||||
override fun submit() = Unit
|
||||
override fun tryAgain() = Unit
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9033,6 +9033,10 @@
|
||||
<string name="CallQualitySheet__had_issues_content_description">I had issues with the call</string>
|
||||
<!-- Content description for the thumbs up button indicating the call was great -->
|
||||
<string name="CallQualitySheet__great_content_description">The call was great</string>
|
||||
<!-- Dialog body shown when feedback submission fails due to network issues -->
|
||||
<string name="CallQualitySheet__your_feedback_failed_to_send">Your feedback failed to send.</string>
|
||||
<!-- Dialog button to retry sending feedback after a failure -->
|
||||
<string name="CallQualitySheet__try_again">Try again</string>
|
||||
|
||||
<!-- Message body when someone pins a message where %1$s is the name of the person -->
|
||||
<string name="PinnedMessage__s_pinned_a_message">%1$s pinned a message</string>
|
||||
|
||||
Reference in New Issue
Block a user