mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 16:22:49 +00:00
Add error content to Localazy
This commit is contained in:
committed by
Benoit Marty
parent
babed8eb1f
commit
25989135a8
+8
-4
@@ -258,25 +258,29 @@ class TimelinePresenter(
|
||||
is LocalEventSendState.Failed.InvalidMimeType -> {
|
||||
sendFailureDialogState = SendFailureDialogState.Show(
|
||||
event = event.event,
|
||||
message = "Invalid mime type: ${sendStateFailure.mimeType}",
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.InvalidMimeType(sendStateFailure.mimeType),
|
||||
)
|
||||
}
|
||||
LocalEventSendState.Failed.MissingMediaContent -> {
|
||||
sendFailureDialogState = SendFailureDialogState.Show(
|
||||
event = event.event,
|
||||
message = "Missing media content",
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.MissingMediaContent,
|
||||
)
|
||||
}
|
||||
LocalEventSendState.Failed.SendingFromUnverifiedDevice -> {
|
||||
sendFailureDialogState = SendFailureDialogState.Show(
|
||||
event = event.event,
|
||||
message = "Sending from unverified device",
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.SendingFromUnverifiedDevice,
|
||||
)
|
||||
}
|
||||
is LocalEventSendState.Failed.Unknown -> {
|
||||
sendFailureDialogState = SendFailureDialogState.Show(
|
||||
event = event.event,
|
||||
message = sendStateFailure.error.takeIf { it.isNotBlank() } ?: "Unknown error",
|
||||
sendFailureType = if (sendStateFailure.error.isNotBlank()) {
|
||||
SendFailureDialogState.SendFailureType.Error(sendStateFailure.error)
|
||||
} else {
|
||||
SendFailureDialogState.SendFailureType.Unknown
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+10
-1
@@ -16,6 +16,15 @@ sealed interface SendFailureDialogState {
|
||||
|
||||
data class Show(
|
||||
val event: TimelineItem.Event,
|
||||
val message: String,
|
||||
val sendFailureType: SendFailureType,
|
||||
) : SendFailureDialogState
|
||||
|
||||
@Immutable
|
||||
sealed interface SendFailureType {
|
||||
data class InvalidMimeType(val mimeType: String) : SendFailureType
|
||||
data object MissingMediaContent : SendFailureType
|
||||
data object SendingFromUnverifiedDevice : SendFailureType
|
||||
data class Error(val message: String) : SendFailureType
|
||||
data object Unknown : SendFailureType
|
||||
}
|
||||
}
|
||||
|
||||
+17
-1
@@ -16,7 +16,23 @@ class SendFailureDialogStateProvider : PreviewParameterProvider<SendFailureDialo
|
||||
SendFailureDialogState.Hidden,
|
||||
SendFailureDialogState.Show(
|
||||
event = aTimelineItemEvent(),
|
||||
message = "Failed to send message",
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.InvalidMimeType("image/invalid")
|
||||
),
|
||||
SendFailureDialogState.Show(
|
||||
event = aTimelineItemEvent(),
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.MissingMediaContent,
|
||||
),
|
||||
SendFailureDialogState.Show(
|
||||
event = aTimelineItemEvent(),
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.SendingFromUnverifiedDevice,
|
||||
),
|
||||
SendFailureDialogState.Show(
|
||||
event = aTimelineItemEvent(),
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.Error("Message error from server"),
|
||||
),
|
||||
SendFailureDialogState.Show(
|
||||
event = aTimelineItemEvent(),
|
||||
sendFailureType = SendFailureDialogState.SendFailureType.Unknown,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+22
-1
@@ -11,6 +11,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import io.element.android.features.messages.impl.R
|
||||
import io.element.android.features.messages.impl.timeline.model.TimelineItem
|
||||
import io.element.android.libraries.designsystem.components.dialogs.ConfirmationDialog
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
@@ -29,10 +30,30 @@ fun SendFailureDialogView(
|
||||
is SendFailureDialogState.Hidden -> Unit
|
||||
is SendFailureDialogState.Show -> {
|
||||
// Show the dialog with the message and actions
|
||||
val content = when (sendFailureDialogState.sendFailureType) {
|
||||
is SendFailureDialogState.SendFailureType.InvalidMimeType -> stringResource(
|
||||
id = R.string.error_sending_failure_invalid_mime_type,
|
||||
sendFailureDialogState.sendFailureType.mimeType,
|
||||
)
|
||||
is SendFailureDialogState.SendFailureType.MissingMediaContent -> stringResource(
|
||||
id = R.string.error_sending_failure_missing_media_content,
|
||||
)
|
||||
is SendFailureDialogState.SendFailureType.SendingFromUnverifiedDevice -> stringResource(
|
||||
id = R.string.error_sending_failure_sending_from_unverified_device,
|
||||
)
|
||||
is SendFailureDialogState.SendFailureType.Error -> stringResource(
|
||||
id = R.string.error_sending_failure_other,
|
||||
sendFailureDialogState.sendFailureType.message
|
||||
)
|
||||
is SendFailureDialogState.SendFailureType.Unknown -> stringResource(
|
||||
id = R.string.error_sending_failure_unknown,
|
||||
)
|
||||
}
|
||||
|
||||
ConfirmationDialog(
|
||||
modifier = modifier,
|
||||
title = stringResource(id = CommonStrings.common_sending_failed),
|
||||
content = sendFailureDialogState.message,
|
||||
content = content,
|
||||
onDismiss = onDismiss,
|
||||
submitText = stringResource(id = CommonStrings.action_retry),
|
||||
onSubmitClick = { onRetry(sendFailureDialogState.event) },
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
<string name="crypto_event_authenticity_unknown_device">"Encrypted by an unknown or deleted device."</string>
|
||||
<string name="crypto_event_authenticity_unsigned_device">"Encrypted by a device not verified by its owner."</string>
|
||||
<string name="crypto_event_authenticity_unverified_identity">"Encrypted by an unverified user."</string>
|
||||
<string name="error_sending_failure_invalid_mime_type">"Invalid mime type: %s"</string>
|
||||
<string name="error_sending_failure_missing_media_content">"Missing media content"</string>
|
||||
<string name="error_sending_failure_other">"Error details: %s"</string>
|
||||
<string name="error_sending_failure_sending_from_unverified_device">"Sending from unverified device"</string>
|
||||
<string name="error_sending_failure_unknown">"Unknown error"</string>
|
||||
<string name="screen_image_edition_a11y_flip_image_horizontally">"Flip image horizontally"</string>
|
||||
<string name="screen_image_edition_a11y_flip_image_horizontally_state_flipped">"Flipped horizontally"</string>
|
||||
<string name="screen_image_edition_a11y_flip_image_horizontally_state_original">"Original"</string>
|
||||
|
||||
@@ -271,6 +271,7 @@
|
||||
"screen_room_retry.*",
|
||||
"screen_room_timeline.*",
|
||||
"screen\\.room\\.timeline.*",
|
||||
"error\\.sending_failure\\..*",
|
||||
"screen\\.room_timeline.*",
|
||||
"screen_room_typing.*",
|
||||
"screen\\.image_edition\\..*",
|
||||
|
||||
Reference in New Issue
Block a user