Move to quoted message on quote preview click.

This commit is contained in:
Sagar
2025-04-22 21:21:54 +05:30
committed by Cody Henthorne
parent 3fc386d4a3
commit 2bb94089f7
4 changed files with 24 additions and 14 deletions

View File

@@ -220,6 +220,9 @@ public class InputPanel extends ConstraintLayout
@NonNull QuoteModel.Type quoteType)
{
this.quoteView.setQuote(requestManager, id, author, body, false, attachments, null, quoteType);
if (listener != null) {
this.quoteView.setOnClickListener(v -> listener.onQuoteClicked(id, author.getId()));
}
int originalHeight = this.quoteView.getVisibility() == VISIBLE ? this.quoteView.getMeasuredHeight()
: 0;
@@ -817,6 +820,7 @@ public class InputPanel extends ConstraintLayout
void onStickerSuggestionSelected(@NonNull StickerRecord sticker);
void onQuoteChanged(long id, @NonNull RecipientId author);
void onQuoteCleared();
void onQuoteClicked(long quoteId, RecipientId authorId);
void onEnterEditMode();
void onExitEditMode();
void onQuickCameraToggleClicked();

View File

@@ -2755,6 +2755,17 @@ class ConversationFragment :
}
}
fun handleMoveToQuotePosition(quoteId: Long, authorId: RecipientId) {
disposables += viewModel.getQuotedMessagePosition(quoteId, authorId)
.subscribeBy {
if (it >= 0) {
moveToPosition(it)
} else {
toast(R.string.ConversationFragment_quoted_message_no_longer_available)
}
}
}
//endregion Scroll Handling
// region Conversation Callbacks
@@ -2788,14 +2799,7 @@ class ConversationFragment :
return
}
disposables += viewModel.getQuotedMessagePosition(quote)
.subscribeBy {
if (it >= 0) {
moveToPosition(it)
} else {
toast(R.string.ConversationFragment_quoted_message_no_longer_available)
}
}
handleMoveToQuotePosition(quote.id, quote.author)
}
override fun onLinkPreviewClicked(linkPreview: LinkPreview) {
@@ -4219,6 +4223,10 @@ class ConversationFragment :
draftViewModel.clearQuoteDraft()
}
override fun onQuoteClicked(quoteId: Long, authorId: RecipientId) {
handleMoveToQuotePosition(quoteId = quoteId, authorId = authorId)
}
override fun onEnterEditMode() {
updateToggleButtonState()
previousPage = keyboardPagerViewModel.page().value

View File

@@ -58,7 +58,6 @@ import org.thoughtcrime.securesms.database.model.Mention
import org.thoughtcrime.securesms.database.model.MessageId
import org.thoughtcrime.securesms.database.model.MessageRecord
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
import org.thoughtcrime.securesms.database.model.Quote
import org.thoughtcrime.securesms.database.model.ReactionRecord
import org.thoughtcrime.securesms.database.model.StickerRecord
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList
@@ -249,9 +248,9 @@ class ConversationRepository(
oldConversationRepository.markGiftBadgeRevealed(messageId)
}
fun getQuotedMessagePosition(threadId: Long, quote: Quote): Single<Int> {
fun getQuotedMessagePosition(threadId: Long, quoteId: Long, authorId: RecipientId): Single<Int> {
return Single.fromCallable {
SignalDatabase.messages.getQuotedMessagePosition(threadId, quote.id, quote.author)
SignalDatabase.messages.getQuotedMessagePosition(threadId, quoteId, authorId)
}.subscribeOn(Schedulers.io())
}

View File

@@ -67,7 +67,6 @@ import org.thoughtcrime.securesms.database.model.Mention
import org.thoughtcrime.securesms.database.model.MessageId
import org.thoughtcrime.securesms.database.model.MessageRecord
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
import org.thoughtcrime.securesms.database.model.Quote
import org.thoughtcrime.securesms.database.model.ReactionRecord
import org.thoughtcrime.securesms.database.model.StickerRecord
import org.thoughtcrime.securesms.database.model.StoryViewState
@@ -404,8 +403,8 @@ class ConversationViewModel(
}
}
fun getQuotedMessagePosition(quote: Quote): Single<Int> {
return repository.getQuotedMessagePosition(threadId, quote)
fun getQuotedMessagePosition(quoteId: Long, authorId: RecipientId): Single<Int> {
return repository.getQuotedMessagePosition(threadId, quoteId, authorId)
}
fun moveToDate(receivedTimestamp: Long): Single<Int> {