mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-08-05 21:07:49 +01:00
Add the group story confirmation dialog to the V3 media send flow.
This commit is contained in:
committed by
Alex Hart
parent
c3277fd2b1
commit
7e0bb9c5cb
@@ -10,12 +10,14 @@ import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import androidx.navigationevent.NavigationEventDispatcherOwner
|
||||
import androidx.navigationevent.compose.LocalNavigationEventDispatcherOwner
|
||||
import org.signal.core.ui.compose.Dialogs
|
||||
import org.signal.core.ui.compose.LocalDisplayNameProvider
|
||||
import org.signal.core.ui.compose.theme.SignalTheme
|
||||
import org.signal.mediasend.edit.MediaEditScreenDialogs
|
||||
|
||||
@@ -71,6 +73,17 @@ fun MediaSendScreen(
|
||||
)
|
||||
}
|
||||
|
||||
viewModel.addToGroupStoryDialog.Content { recipientId, onDismissRequest, onConfirm, _, onDeny ->
|
||||
val groupName: String by LocalDisplayNameProvider.current(recipientId.id)
|
||||
|
||||
MediaEditScreenDialogs.AddToGroupStoryConfirmationDialog(
|
||||
groupName = groupName,
|
||||
onAddToStory = onConfirm,
|
||||
onDeny = onDeny,
|
||||
onDismissRequest = onDismissRequest
|
||||
)
|
||||
}
|
||||
|
||||
viewModel.writeStoragePermission.Content()
|
||||
|
||||
MediaSendNavDisplay(
|
||||
|
||||
@@ -124,6 +124,7 @@ class MediaSendViewModel(
|
||||
internal val usernameScannedDialog = DialogController<String>()
|
||||
internal val linkedDeviceScannedDialog = DialogController<Unit>()
|
||||
internal val saveToStorageDialog = DialogController<Unit>()
|
||||
internal val addToGroupStoryDialog = DialogController<MediaRecipientId>()
|
||||
|
||||
internal val writeStoragePermission = PermissionController(
|
||||
permission = Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
@@ -1108,11 +1109,26 @@ class MediaSendViewModel(
|
||||
//region Send
|
||||
|
||||
/**
|
||||
* Leaves the editor, either on to destination selection or straight into the send.
|
||||
* Advances out of the editor: either on to contact selection, or into the send itself.
|
||||
*
|
||||
* The add-to-group-story flow has no review step of its own, so the send is gated behind a confirmation naming the
|
||||
* group. Denying it leaves the editor exactly as it was — nothing is marked as sending until the user confirms.
|
||||
*/
|
||||
private fun onNextClick() {
|
||||
if (state.value.isContactSelectionRequired) {
|
||||
val snapshot = state.value
|
||||
|
||||
if (snapshot.isContactSelectionRequired) {
|
||||
backStack.goToSend()
|
||||
return
|
||||
}
|
||||
|
||||
val recipientId = snapshot.recipientId
|
||||
if (snapshot.isAddToGroupStoryFlow && recipientId != null) {
|
||||
viewModelScope.launch {
|
||||
if (addToGroupStoryDialog.show(recipientId) == DialogResult.POSITIVE) {
|
||||
performSend()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
performSend()
|
||||
}
|
||||
|
||||
@@ -46,6 +46,27 @@ object MediaEditScreenDialogs {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Last chance to back out before the media is posted to [groupName]'s story.
|
||||
*/
|
||||
@Composable
|
||||
fun AddToGroupStoryConfirmationDialog(
|
||||
groupName: String,
|
||||
onAddToStory: () -> Unit,
|
||||
onDeny: () -> Unit,
|
||||
onDismissRequest: () -> Unit
|
||||
) {
|
||||
Dialogs.SimpleAlertDialog(
|
||||
title = "",
|
||||
body = stringResource(R.string.MediaSendDialogs__add_to_the_group_story, groupName),
|
||||
confirm = stringResource(R.string.MediaSendDialogs__add_to_story),
|
||||
onConfirm = onAddToStory,
|
||||
dismiss = stringResource(android.R.string.cancel),
|
||||
onDeny = onDeny,
|
||||
onDismissRequest = onDismissRequest
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SaveToStorageConfirmationDialog(
|
||||
onSave: (doNotShowAgain: Boolean) -> Unit,
|
||||
@@ -113,6 +134,19 @@ private fun DiscardEditsConfirmationDialogPreview() {
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun AddToGroupStoryConfirmationDialogPreview() {
|
||||
Previews.Preview {
|
||||
MediaEditScreenDialogs.AddToGroupStoryConfirmationDialog(
|
||||
groupName = "Signal Android",
|
||||
onAddToStory = {},
|
||||
onDeny = {},
|
||||
onDismissRequest = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun SaveToStorageConfirmationDialogPreview() {
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
<string name="MediaSendDialogs__dont_show_again">Don\'t show again</string>
|
||||
<!-- Progress dialog message shown while the media being edited is written out to the phone\'s storage. -->
|
||||
<string name="MediaSendDialogs__saving_media">Saving attachment to storage…</string>
|
||||
<!-- Dialog message asking the user to confirm that the media should be added to a group\'s story. The placeholder is the group\'s name. -->
|
||||
<string name="MediaSendDialogs__add_to_the_group_story">Add to the group story \"%1$s\"</string>
|
||||
<!-- Confirmation button that adds the media to the group\'s story. -->
|
||||
<string name="MediaSendDialogs__add_to_story">Add to story</string>
|
||||
<!-- Accessibility label for the row that lets the user add a text message to accompany the media being sent. -->
|
||||
<string name="AddAMessageRow__add_a_message">Add a message</string>
|
||||
<!-- Accessibility description for the button that opens the emoji keyboard. -->
|
||||
|
||||
Reference in New Issue
Block a user