Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Quote reply with Sticker/Contact/Docs #13924

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
import org.thoughtcrime.securesms.badges.BadgeImageView;
import org.thoughtcrime.securesms.badges.gifts.GiftMessageView;
import org.thoughtcrime.securesms.badges.gifts.OpenableGift;
import org.thoughtcrime.securesms.billing.upgrade.UpgradeToStartMediaBackupSheet;
import org.thoughtcrime.securesms.calls.links.CallLinks;
import org.thoughtcrime.securesms.components.AlertView;
import org.thoughtcrime.securesms.components.AudioView;
Expand Down Expand Up @@ -145,7 +144,6 @@
import org.thoughtcrime.securesms.util.PlaceholderURLSpan;
import org.thoughtcrime.securesms.util.Projection;
import org.thoughtcrime.securesms.util.ProjectionList;
import org.thoughtcrime.securesms.util.RemoteConfig;
import org.thoughtcrime.securesms.util.SearchUtil;
import org.thoughtcrime.securesms.util.ThemeUtil;
import org.thoughtcrime.securesms.util.UrlClickHandler;
Expand Down Expand Up @@ -680,9 +678,15 @@ private int getAvailableMessageBubbleWidth(@NonNull View forView) {
int availableWidth;
if (hasAudio(messageRecord)) {
availableWidth = audioViewStub.get().getMeasuredWidth() + ViewUtil.getLeftMargin(audioViewStub.get()) + ViewUtil.getRightMargin(audioViewStub.get());
} else if((hasSticker(messageRecord) && isCaptionlessMms(messageRecord)) || isBorderless(messageRecord)) {
availableWidth = stickerStub.get().getMeasuredWidth() + ViewUtil.getLeftMargin(stickerStub.get()) + ViewUtil.getRightMargin(stickerStub.get());
} else if(hasSharedContact(messageRecord)) {
availableWidth = sharedContactStub.get().getMeasuredWidth() + ViewUtil.getLeftMargin(sharedContactStub.get()) + ViewUtil.getRightMargin(sharedContactStub.get());
} else if(hasDocument(messageRecord)) {
availableWidth = documentViewStub.get().getMeasuredWidth() + ViewUtil.getLeftMargin(documentViewStub.get()) + ViewUtil.getRightMargin(documentViewStub.get());
} else if (!isViewOnceMessage(messageRecord) && (hasThumbnail(messageRecord) || hasBigImageLinkPreview(messageRecord))) {
availableWidth = mediaThumbnailStub.require().getMeasuredWidth();
} else {
} else {
availableWidth = bodyBubble.getMeasuredWidth() - bodyBubble.getPaddingLeft() - bodyBubble.getPaddingRight();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,7 @@ class ConversationFragment :

override fun onStickerSelected(sticker: StickerRecord) {
sendSticker(
stickerRecord = sticker,
clearCompose = false
stickerRecord = sticker
)
}

Expand Down Expand Up @@ -1521,7 +1520,7 @@ class ConversationFragment :

when (data) {
is ShareOrDraftData.SendKeyboardImage -> sendMessageWithoutComposeInput(slide = data.slide, clearCompose = false)
is ShareOrDraftData.SendSticker -> sendMessageWithoutComposeInput(slide = data.slide, clearCompose = true)
is ShareOrDraftData.SendSticker -> sendMessageWithoutComposeInput(slide = data.slide)
is ShareOrDraftData.SetText -> composeText.setDraftText(data.text)
is ShareOrDraftData.SetLocation -> attachmentManager.setLocation(data.location, MediaConstraints.getPushMediaConstraints())
is ShareOrDraftData.SetEditMessage -> {
Expand Down Expand Up @@ -1809,8 +1808,7 @@ class ConversationFragment :
}

private fun sendSticker(
stickerRecord: StickerRecord,
clearCompose: Boolean
stickerRecord: StickerRecord
) {
val stickerLocator = StickerLocator(stickerRecord.packId, stickerRecord.packKey, stickerRecord.stickerId, stickerRecord.emoji)
val slide = StickerSlide(
Expand All @@ -1821,15 +1819,14 @@ class ConversationFragment :
stickerRecord.contentType
)

sendMessageWithoutComposeInput(slide = slide, clearCompose = clearCompose)
sendMessageWithoutComposeInput(slide = slide)

viewModel.updateStickerLastUsedTime(stickerRecord, System.currentTimeMillis().milliseconds)
}

private fun sendMessageWithoutComposeInput(
slide: Slide? = null,
contacts: List<Contact> = emptyList(),
quote: QuoteModel? = null,
clearCompose: Boolean = true
) {
sendMessage(
Expand All @@ -1840,7 +1837,6 @@ class ConversationFragment :
mentions = emptyList(),
bodyRanges = null,
messageToEdit = null,
quote = quote,
linkPreviews = emptyList(),
bypassPreSendSafetyNumberCheck = true
)
Expand Down Expand Up @@ -1889,12 +1885,12 @@ class ConversationFragment :
if (slideDeck == null) {
val voiceNote: DraftTable.Draft? = draftViewModel.voiceNoteDraft
if (voiceNote != null) {
sendMessageWithoutComposeInput(slide = AudioSlide.createFromVoiceNoteDraft(voiceNote), clearCompose = true)
sendMessageWithoutComposeInput(slide = AudioSlide.createFromVoiceNoteDraft(voiceNote))
return
}
}

if (body.isNullOrBlank() && slideDeck?.containsMediaSlide() != true && preUploadResults.isEmpty() && contacts.isEmpty()) {
if (body.isBlank() && slideDeck?.containsMediaSlide() != true && preUploadResults.isEmpty() && contacts.isEmpty()) {
Log.i(TAG, "Unable to send due to empty message")
toast(R.string.ConversationActivity_message_is_empty_exclamation)
return
Expand Down Expand Up @@ -3677,8 +3673,7 @@ class ConversationFragment :
private inner class ActivityResultCallbacks : ConversationActivityResultContracts.Callbacks {
override fun onSendContacts(contacts: List<Contact>) {
sendMessageWithoutComposeInput(
contacts = contacts,
clearCompose = false
contacts = contacts
)
}

Expand Down Expand Up @@ -4129,8 +4124,7 @@ class ConversationFragment :

override fun onStickerSuggestionSelected(sticker: StickerRecord) {
sendSticker(
stickerRecord = sticker,
clearCompose = true
stickerRecord = sticker
)
}

Expand Down Expand Up @@ -4414,8 +4408,7 @@ class ConversationFragment :
val audioSlide = AudioSlide(draft.uri, draft.size, MediaUtil.AUDIO_AAC, true)

sendMessageWithoutComposeInput(
slide = audioSlide,
quote = inputPanel.quote.orNull()
slide = audioSlide
)
}

Expand Down