Added a couple of minor UI optimisations

This commit is contained in:
Morgan Pretty 2023-01-10 17:33:50 +11:00
parent 3e68bdc2f8
commit afdf730eaa
3 changed files with 54 additions and 57 deletions

View File

@ -80,7 +80,7 @@ class LinkPreviewView : LinearLayout {
val rawYInt = event.rawY.toInt()
val hitRect = Rect(rawXInt, rawYInt, rawXInt, rawYInt)
val previewRect = Rect()
binding.mainLinkPreviewParent.getGlobalVisibleRect(previewRect)
binding.mainLinkPreviewContainer.getGlobalVisibleRect(previewRect)
if (previewRect.contains(hitRect)) {
openURL()
return

View File

@ -192,15 +192,16 @@ class VisibleMessageView : LinearLayout {
binding.dateBreakTextView.text = if (showDateBreak) DateUtils.getDisplayFormattedTimeSpanString(context, Locale.getDefault(), message.timestamp) else null
binding.dateBreakTextView.isVisible = showDateBreak
// Message status indicator
val (iconID, iconColor) = getMessageStatusImage(message)
if (iconID != null) {
val drawable = ContextCompat.getDrawable(context, iconID)?.mutate()
if (iconColor != null) {
drawable?.setTint(iconColor)
}
binding.messageStatusImageView.setImageDrawable(drawable)
}
if (message.isOutgoing) {
val (iconID, iconColor) = getMessageStatusImage(message)
if (iconID != null) {
val drawable = ContextCompat.getDrawable(context, iconID)?.mutate()
if (iconColor != null) {
drawable?.setTint(iconColor)
}
binding.messageStatusImageView.setImageDrawable(drawable)
}
val lastMessageID = mmsSmsDb.getLastMessageID(message.threadId)
binding.messageStatusImageView.isVisible =
!message.isSent || message.id == lastMessageID
@ -213,13 +214,17 @@ class VisibleMessageView : LinearLayout {
val emojiLayoutParams = binding.emojiReactionsView.layoutParams as ConstraintLayout.LayoutParams
emojiLayoutParams.horizontalBias = if (message.isOutgoing) 1f else 0f
binding.emojiReactionsView.layoutParams = emojiLayoutParams
val capabilities = lokiThreadDb.getOpenGroupChat(threadID)?.server?.let { lokiApiDb.getServerCapabilities(it) }
if (message.reactions.isNotEmpty() &&
(capabilities.isNullOrEmpty() || capabilities.contains(OpenGroupApi.Capability.REACTIONS.name.lowercase()))
) {
binding.emojiReactionsView.setReactions(message.id, message.reactions, message.isOutgoing, delegate)
binding.emojiReactionsView.isVisible = true
} else {
if (message.reactions.isNotEmpty()) {
val capabilities = lokiThreadDb.getOpenGroupChat(threadID)?.server?.let { lokiApiDb.getServerCapabilities(it) }
if (capabilities.isNullOrEmpty() || capabilities.contains(OpenGroupApi.Capability.REACTIONS.name.lowercase())) {
binding.emojiReactionsView.setReactions(message.id, message.reactions, message.isOutgoing, delegate)
binding.emojiReactionsView.isVisible = true
} else {
binding.emojiReactionsView.isVisible = false
}
}
else {
binding.emojiReactionsView.isVisible = false
}

View File

@ -1,54 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/mainLinkPreviewContainer"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/transparent_black_6"
android:layout_width="300dp"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:orientation="horizontal"
android:gravity="center">
<LinearLayout
android:background="@color/transparent_black_6"
android:id="@+id/mainLinkPreviewParent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<RelativeLayout
android:layout_width="96dp"
android:layout_height="96dp">
<RelativeLayout
android:layout_width="96dp"
android:layout_height="96dp">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_link"
app:tint="?android:textColorPrimary" />
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_link"
app:tint="?android:textColorPrimary" />
<org.thoughtcrime.securesms.conversation.v2.utilities.KThumbnailView
android:background="@color/transparent_black_6"
android:id="@+id/thumbnailImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
</RelativeLayout>
<TextView
android:id="@+id/titleTextView"
<org.thoughtcrime.securesms.conversation.v2.utilities.KThumbnailView
android:background="@color/transparent_black_6"
android:id="@+id/thumbnailImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingHorizontal="12dp"
android:gravity="center_vertical"
android:textSize="@dimen/small_font_size"
android:textStyle="bold"
tools:text="Some Text here"
android:minWidth="@dimen/media_bubble_min_width"
android:maxLines="3"
android:ellipsize="end"
android:textColor="?android:textColorPrimary"/>
android:scaleType="centerCrop" />
</LinearLayout>
</RelativeLayout>
<TextView
android:id="@+id/titleTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingHorizontal="12dp"
android:gravity="center_vertical"
android:textSize="@dimen/small_font_size"
android:textStyle="bold"
tools:text="Some Text here"
android:minWidth="@dimen/media_bubble_min_width"
android:maxLines="3"
android:ellipsize="end"
android:textColor="?android:textColorPrimary"/>
</LinearLayout>