Do not display stories as valid selections when sending view-once media.

This commit is contained in:
Alex Hart 2022-10-07 14:42:49 -03:00 committed by Greyson Parrelli
parent 5c77c33dff
commit 9aa7543f2f
5 changed files with 11 additions and 4 deletions

View file

@ -10,7 +10,6 @@ import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.color.ViewColorSet
import org.thoughtcrime.securesms.components.FragmentWrapperActivity
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
import org.thoughtcrime.securesms.conversation.mutiselect.forward.MultiselectForwardFragment.Companion.RESULT_SELECTION

View file

@ -459,7 +459,7 @@ class MultiselectForwardFragment :
}
private fun isSelectedMediaValidForStories(): Boolean {
return args.multiShareArgs.all { it.isValidForStories }
return !args.isViewOnce && args.multiShareArgs.all { it.isValidForStories }
}
private fun isSelectedMediaValidForNonStories(): Boolean {

View file

@ -46,7 +46,8 @@ data class MultiselectForwardFragmentArgs @JvmOverloads constructor(
val selectSingleRecipient: Boolean = false,
val sendButtonColors: ViewColorSet = ViewColorSet.PRIMARY,
val storySendRequirements: Stories.MediaTransform.SendRequirements = Stories.MediaTransform.SendRequirements.CAN_NOT_SEND,
val isSearchEnabled: Boolean = true
val isSearchEnabled: Boolean = true,
val isViewOnce: Boolean = false
) : Parcelable {
fun withSendButtonTint(@ColorInt sendButtonTint: Int) = copy(sendButtonColors = ViewColorSet.forCustomColor(sendButtonTint))

View file

@ -160,12 +160,15 @@ class MediaReviewFragment : Fragment(R.layout.v2_media_review_fragment) {
}
sendButton.setOnClickListener {
val viewOnce: Boolean = sharedViewModel.state.value?.viewOnceToggleState == MediaSelectionState.ViewOnceToggleState.ONCE
if (sharedViewModel.isContactSelectionRequired) {
val args = MultiselectForwardFragmentArgs(
false,
title = R.string.MediaReviewFragment__send_to,
storySendRequirements = sharedViewModel.getStorySendRequirements(),
isSearchEnabled = !sharedViewModel.isStory()
isSearchEnabled = !sharedViewModel.isStory(),
isViewOnce = viewOnce
)
if (sharedViewModel.isStory()) {

View file

@ -149,6 +149,10 @@ public final class MultiShareArgs implements Parcelable {
}
public boolean isValidForStories() {
if (isViewOnce()) {
return false;
}
return isTextStory ||
(!media.isEmpty() && media.stream().allMatch(m -> MediaUtil.isStorySupportedType(m.getMimeType()))) ||
MediaUtil.isStorySupportedType(dataType) ||