diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/QuoteView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/QuoteView.kt index afa27898ca..2b1a5cc7e2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/QuoteView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/QuoteView.kt @@ -72,9 +72,9 @@ class QuoteView : LinearLayout { val bodyTextViewIntrinsicHeight = TextUtilities.getIntrinsicHeight(body, quoteViewBodyTextView.paint, maxContentWidth) result += bodyTextViewIntrinsicHeight if (!quoteViewAuthorTextView.isVisible) { - return min(max(result, toPx(32, resources)), toPx(60, resources)) + return min(max(result, toPx(32, resources)), toPx(56, resources)) } else { - return min(result, toPx(60, resources) + authorTextViewIntrinsicHeight) + return min(result, toPx(56, resources)) } } @@ -89,12 +89,14 @@ class QuoteView : LinearLayout { fun bind(authorPublicKey: String, body: String?, attachments: SlideDeck?, thread: Recipient, isOutgoingMessage: Boolean, maxContentWidth: Int, isOpenGroupInvitation: Boolean) { val contactDB = DatabaseFactory.getSessionContactDatabase(context) + quoteViewBodyTextView.maxLines = 3 // Author if (thread.isGroupRecipient) { val author = contactDB.getContactWithSessionID(authorPublicKey) val authorDisplayName = author?.displayName(Contact.contextForRecipient(thread)) ?: authorPublicKey quoteViewAuthorTextView.text = authorDisplayName quoteViewAuthorTextView.setTextColor(getTextColor(isOutgoingMessage)) + quoteViewBodyTextView.maxLines = 2 } quoteViewAuthorTextView.isVisible = thread.isGroupRecipient // Body diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt index fb4b6e6b3c..cbf9844bcf 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt @@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.conversation.v2.messages import android.content.Context import android.graphics.drawable.Drawable import android.util.AttributeSet +import android.util.Log import android.util.TypedValue import android.view.LayoutInflater import android.widget.LinearLayout @@ -18,6 +19,7 @@ import org.session.libsession.messaging.utilities.UpdateMessageData import org.session.libsession.messaging.utilities.UpdateMessageData.Companion.fromJSON import org.session.libsession.utilities.ThemeUtil import org.session.libsession.utilities.ViewUtil +import org.session.libsession.utilities.recipients.Recipient import org.thoughtcrime.securesms.database.model.MessageRecord import org.thoughtcrime.securesms.database.model.MmsMessageRecord import org.thoughtcrime.securesms.loki.utilities.UiMode @@ -43,7 +45,8 @@ class VisibleMessageContentView : LinearLayout { // endregion // region Updating - fun bind(message: MessageRecord, isStartOfMessageCluster: Boolean, isEndOfMessageCluster: Boolean, glide: GlideRequests, maxWidth: Int) { + fun bind(message: MessageRecord, isStartOfMessageCluster: Boolean, isEndOfMessageCluster: Boolean, + glide: GlideRequests, maxWidth: Int, thread: Recipient) { // Background val background = getBackground(message.isOutgoing, isStartOfMessageCluster, isEndOfMessageCluster) val colorID = if (message.isOutgoing) R.attr.message_sent_background_color else R.attr.message_received_background_color @@ -63,7 +66,7 @@ class VisibleMessageContentView : LinearLayout { val quote = message.quote!! val quoteView = QuoteView(context, QuoteView.Mode.Regular) val maxContentWidth = (maxWidth - 2 * resources.getDimension(R.dimen.medium_spacing) - toPx(16, resources)).roundToInt() - quoteView.bind(quote.author.toString(), quote.text, quote.attachment, message.recipient, + quoteView.bind(quote.author.toString(), quote.text, quote.attachment, thread, message.isOutgoing, maxContentWidth, message.isOpenGroupInvitation) mainContainer.addView(quoteView) val bodyTextView = VisibleMessageContentView.getBodyTextView(context, message) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt index 4b5be84221..669716240a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt @@ -79,7 +79,7 @@ class VisibleMessageView : LinearLayout { val senderSessionID = sender.address.serialize() val threadID = message.threadId val threadDB = DatabaseFactory.getThreadDatabase(context) - val thread = threadDB.getRecipientForThreadId(threadID) + val thread = threadDB.getRecipientForThreadId(threadID)!! val contactDB = DatabaseFactory.getSessionContactDatabase(context) val isGroupThread = (thread?.isGroupRecipient == true) val isStartOfMessageCluster = isStartOfMessageCluster(message, previous, isGroupThread) @@ -87,7 +87,6 @@ class VisibleMessageView : LinearLayout { // Show profile picture and sender name if this is a group thread AND // the message is incoming if (isGroupThread && !message.isOutgoing) { - thread!! profilePictureContainer.visibility = if (isEndOfMessageCluster) View.VISIBLE else View.INVISIBLE profilePictureView.publicKey = senderSessionID profilePictureView.glide = glide @@ -141,10 +140,8 @@ class VisibleMessageView : LinearLayout { } // Populate content view var maxWidth = screenWidth - messageContentContainerLayoutParams.leftMargin - messageContentContainerLayoutParams.rightMargin - if (profilePictureContainer.visibility != View.GONE) { - maxWidth -= profilePictureContainer.width - } - messageContentView.bind(message, isStartOfMessageCluster, isEndOfMessageCluster, glide, maxWidth) + if (profilePictureContainer.visibility != View.GONE) { maxWidth -= profilePictureContainer.width } + messageContentView.bind(message, isStartOfMessageCluster, isEndOfMessageCluster, glide, maxWidth, thread) } private fun setMessageSpacing(isStartOfMessageCluster: Boolean, isEndOfMessageCluster: Boolean) {