From 5761ce959b2b196bcc644045e92f951f5c389270 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Mon, 7 Jun 2021 16:36:05 +1000 Subject: [PATCH] Fix layout issue --- .../conversation/v2/ConversationActivityV2.kt | 4 +--- .../securesms/conversation/v2/ConversationAdapter.kt | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index e9326925d4..df30ae6c96 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -63,9 +63,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity() { private fun setUpRecyclerView() { conversationRecyclerView.adapter = adapter - val layoutManager = LinearLayoutManager(this) - layoutManager.reverseLayout = true - layoutManager.stackFromEnd = true + val layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, true) conversationRecyclerView.layoutManager = layoutManager // Workaround for the fact that CursorRecyclerViewAdapter doesn't auto-update automatically (even though it says it will) LoaderManager.getInstance(this).restartLoader(0, null, object : LoaderManager.LoaderCallbacks { diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt index 77f0d7ca24..63c3f733c7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt @@ -63,7 +63,7 @@ class ConversationAdapter(context: Context, cursor: Cursor, private val onItemPr is VisibleMessageViewHolder -> { val view = viewHolder.view view.background = if (selectedItems.contains(message)) { - ColorDrawable(context.resources.getColorWithID(R.color.red, context.theme)) + ColorDrawable(context.resources.getColorWithID(R.color.accent, context.theme)) } else { null } @@ -92,12 +92,16 @@ class ConversationAdapter(context: Context, cursor: Cursor, private val onItemPr } private fun getMessageBefore(position: Int, cursor: Cursor): MessageRecord? { - if (!cursor.moveToPosition(position - 1)) { return null } + // The message that's visually before the current one is actually after the current + // one for the cursor because the layout is reversed + if (!cursor.moveToPosition(position + 1)) { return null } return messageDB.readerFor(cursor).current } private fun getMessageAfter(position: Int, cursor: Cursor): MessageRecord? { - if (!cursor.moveToPosition(position + 1)) { return null } + // The message that's visually after the current one is actually before the current + // one for the cursor because the layout is reversed + if (!cursor.moveToPosition(position - 1)) { return null } return messageDB.readerFor(cursor).current }