Handle open group invitation weirdness & fix quote view sizing

This commit is contained in:
Niels Andriesse 2021-06-22 15:55:32 +10:00
parent b2a66e9293
commit 1c92b17ecc
3 changed files with 11 additions and 9 deletions

View File

@ -22,7 +22,7 @@ class OpenGroupInvitationView : LinearLayout {
}
fun bind(message: MessageRecord, @ColorInt textColor: Int) {
// FIXME: This is a really weird approach
// FIXME: This is a really weird approach...
val umd = UpdateMessageData.fromJSON(message.body)!!
val data = umd.kind as UpdateMessageData.Kind.OpenGroupInvitation
val iconID = if (message.isOutgoing) R.drawable.ic_globe else R.drawable.ic_plus

View File

@ -15,6 +15,7 @@ import androidx.core.view.marginStart
import kotlinx.android.synthetic.main.view_quote.view.*
import network.loki.messenger.R
import org.session.libsession.messaging.contacts.Contact
import org.session.libsession.messaging.utilities.UpdateMessageData
import org.session.libsession.utilities.recipients.Recipient
import org.thoughtcrime.securesms.conversation.v2.utilities.TextUtilities
import org.thoughtcrime.securesms.database.DatabaseFactory
@ -29,7 +30,6 @@ import kotlin.math.roundToInt
class QuoteView : LinearLayout {
private lateinit var mode: Mode
private val screenWidth by lazy { Resources.getSystem().displayMetrics.widthPixels }
private val vPadding by lazy { toPx(6, resources) }
var delegate: QuoteViewDelegate? = null
@ -61,16 +61,16 @@ class QuoteView : LinearLayout {
// region General
fun getIntrinsicContentHeight(): Int {
if (quoteViewAttachmentPreviewContainer.isVisible) { return toPx(40, resources) }
val maxContentWidth = quoteViewMainContentContainer.width
var result = 0
val width = screenWidth
var authorTextViewIntrinsicHeight = 0
if (quoteViewAuthorTextView.isVisible) {
val author = quoteViewAuthorTextView.text
authorTextViewIntrinsicHeight = TextUtilities.getIntrinsicHeight(author, quoteViewAuthorTextView.paint, width)
authorTextViewIntrinsicHeight = TextUtilities.getIntrinsicHeight(author, quoteViewAuthorTextView.paint, maxContentWidth)
result += authorTextViewIntrinsicHeight
}
val body = quoteViewBodyTextView.text
val bodyTextViewIntrinsicHeight = TextUtilities.getIntrinsicHeight(body, quoteViewBodyTextView.paint, width)
val bodyTextViewIntrinsicHeight = TextUtilities.getIntrinsicHeight(body, quoteViewBodyTextView.paint, maxContentWidth)
result += bodyTextViewIntrinsicHeight
if (!quoteViewAuthorTextView.isVisible) {
return min(max(result, toPx(32, resources)), toPx(54, resources))
@ -96,7 +96,8 @@ class QuoteView : LinearLayout {
}
quoteViewAuthorTextView.isVisible = thread.isGroupRecipient
// Body
quoteViewBodyTextView.text = body
val isOpenGroupInvitation = (body?.let { UpdateMessageData.fromJSON(it) } != null)
quoteViewBodyTextView.text = if (isOpenGroupInvitation) resources.getString(R.string.open_group_invitation_view__open_group_invitation) else body
quoteViewBodyTextView.setTextColor(getTextColor(isOutgoingMessage))
// Accent line / attachment preview
val hasAttachments = (attachments != null && attachments.asAttachments().isNotEmpty())

View File

@ -10,16 +10,17 @@
<ImageView
android:id="@+id/iconImageView"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginBottom="@dimen/small_spacing" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/medium_font_size"
android:textSize="@dimen/very_small_font_size"
android:textColor="@color/text"
android:textStyle="bold"
android:gravity="center" />
</LinearLayout>