mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Show smaller quote chains within larger quote chains.
This commit is contained in:
committed by
Alex Hart
parent
56f6888d49
commit
f207a82d2f
@@ -482,7 +482,7 @@ public class ConversationAdapter
|
||||
/**
|
||||
* Momentarily highlights a mention at the requested position.
|
||||
*/
|
||||
void pulseAtPosition(int position) {
|
||||
public void pulseAtPosition(int position) {
|
||||
if (position >= 0 && position < getItemCount()) {
|
||||
int correctedPosition = isHeaderPosition(position) ? position + 1 : position;
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.FixedRoundedCornerBottomSheetDialogFragment
|
||||
import org.thoughtcrime.securesms.components.recyclerview.SmoothScrollingLinearLayoutManager
|
||||
@@ -93,7 +95,16 @@ class MessageQuotesBottomSheet : FixedRoundedCornerBottomSheetDialogFragment() {
|
||||
|
||||
messageAdapter.submitList(messages) {
|
||||
if (firstRender) {
|
||||
(list.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(messages.size - 1, 100)
|
||||
val targetMessageId = MessageId.deserialize(arguments?.getString(KEY_MESSAGE_ID, null) ?: throw IllegalArgumentException())
|
||||
val targetMessagePosition = messages.indexOfFirst { it.messageRecord.id == targetMessageId.id && it.messageRecord.isMms == targetMessageId.mms }
|
||||
|
||||
(list.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(targetMessagePosition, 100)
|
||||
|
||||
if (targetMessagePosition != messages.size - 1) {
|
||||
(dialog as BottomSheetDialog).behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
messageAdapter.pulseAtPosition(targetMessagePosition)
|
||||
}
|
||||
|
||||
firstRender = false
|
||||
} else if (!list.canScrollVertically(1)) {
|
||||
list.layoutManager?.scrollToPosition(0)
|
||||
|
||||
@@ -35,28 +35,30 @@ class MessageQuotesRepository {
|
||||
}
|
||||
|
||||
val databaseObserver: DatabaseObserver = ApplicationDependencies.getDatabaseObserver()
|
||||
val observer = DatabaseObserver.Observer { emitter.onNext(getMessageInQuoteChainSync(application, messageId)) }
|
||||
val observer = DatabaseObserver.Observer { emitter.onNext(getMessagesInQuoteChainSync(application, messageId)) }
|
||||
|
||||
databaseObserver.registerConversationObserver(threadId, observer)
|
||||
|
||||
emitter.setCancellable { databaseObserver.unregisterObserver(observer) }
|
||||
emitter.onNext(getMessageInQuoteChainSync(application, messageId))
|
||||
emitter.onNext(getMessagesInQuoteChainSync(application, messageId))
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun getMessageInQuoteChainSync(application: Application, messageId: MessageId): List<ConversationMessage> {
|
||||
var originalRecord: MessageRecord? = if (messageId.mms) {
|
||||
SignalDatabase.mms.getMessageRecordOrNull(messageId.id)
|
||||
private fun getMessagesInQuoteChainSync(application: Application, messageId: MessageId): List<ConversationMessage> {
|
||||
val rootMessageId: MessageId = SignalDatabase.mmsSms.getRootOfQuoteChain(messageId)
|
||||
|
||||
var originalRecord: MessageRecord? = if (rootMessageId.mms) {
|
||||
SignalDatabase.mms.getMessageRecordOrNull(rootMessageId.id)
|
||||
} else {
|
||||
SignalDatabase.sms.getMessageRecordOrNull(messageId.id)
|
||||
SignalDatabase.sms.getMessageRecordOrNull(rootMessageId.id)
|
||||
}
|
||||
|
||||
if (originalRecord == null) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
val replyRecords: List<MessageRecord> = SignalDatabase.mmsSms.getAllMessagesThatQuote(messageId)
|
||||
val replyRecords: List<MessageRecord> = SignalDatabase.mmsSms.getAllMessagesThatQuote(rootMessageId)
|
||||
|
||||
val replies: List<ConversationMessage> = ConversationDataSource.ReactionHelper()
|
||||
.apply {
|
||||
|
||||
Reference in New Issue
Block a user