mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-27 17:08:34 +03:00
preoperly theme quoted messages for Material 3 including alignment
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
3d88392930
commit
d27f0e2222
4 changed files with 24 additions and 18 deletions
|
@ -48,6 +48,8 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA
|
|||
import com.nextcloud.talk.databinding.ItemCustomIncomingTextMessageBinding
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.ui.recyclerview.MessageSwipeCallback
|
||||
import com.nextcloud.talk.ui.theme.ServerTheme
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.DisplayUtils
|
||||
import com.nextcloud.talk.utils.TextMatchers
|
||||
|
@ -64,6 +66,9 @@ class MagicIncomingTextMessageViewHolder(itemView: View, payload: Any) : Message
|
|||
@Inject
|
||||
lateinit var context: Context
|
||||
|
||||
@Inject
|
||||
lateinit var viewThemeUtils: ViewThemeUtils
|
||||
|
||||
@Inject
|
||||
lateinit var appPreferences: AppPreferences
|
||||
|
||||
|
@ -181,13 +186,12 @@ class MagicIncomingTextMessageViewHolder(itemView: View, payload: Any) : Message
|
|||
context!!.getText(R.string.nc_nick_guest) else parentChatMessage.actorDisplayName
|
||||
binding.messageQuote.quotedMessage.text = parentChatMessage.text
|
||||
|
||||
binding.messageQuote.quotedMessageAuthor
|
||||
.setTextColor(ContextCompat.getColor(context!!, R.color.textColorMaxContrast))
|
||||
|
||||
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
|
||||
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.colorPrimary)
|
||||
viewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView)
|
||||
} else {
|
||||
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.textColorMaxContrast)
|
||||
binding.messageQuote.quoteColoredView.setBackgroundColor(
|
||||
ContextCompat.getColor(binding.messageQuote.quoteColoredView.context, R.color.high_emphasis_text)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ import android.text.Spannable
|
|||
import android.text.SpannableString
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import autodagger.AutoInjector
|
||||
import coil.load
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
|
@ -150,16 +150,10 @@ class MagicOutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessage
|
|||
binding.messageQuote.quotedMessageAuthor.text = parentChatMessage.actorDisplayName
|
||||
?: context!!.getText(R.string.nc_nick_guest)
|
||||
binding.messageQuote.quotedMessage.text = parentChatMessage.text
|
||||
binding.messageQuote.quotedMessage.setTextColor(serverTheme.colorText)
|
||||
|
||||
binding.messageQuote.quotedMessageAuthor.setTextColor(
|
||||
ColorUtils.setAlphaComponent(
|
||||
serverTheme.colorText,
|
||||
ALPHA_80_INT
|
||||
)
|
||||
binding.messageQuote.quoteColoredView.setBackgroundColor(
|
||||
ContextCompat.getColor(binding.messageQuote.quoteColoredView.context, R.color.high_emphasis_text)
|
||||
)
|
||||
|
||||
binding.messageQuote.quoteColoredView.setBackgroundColor(serverTheme.colorText)
|
||||
}
|
||||
|
||||
private fun setBubbleOnChatMessage(message: ChatMessage) {
|
||||
|
|
|
@ -195,6 +195,12 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||
}
|
||||
}
|
||||
|
||||
fun colorPrimaryView(view: View) {
|
||||
withScheme(view) { scheme ->
|
||||
view.setBackgroundColor(scheme.primary)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Colors the background as element color and the foreground as text color.
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Nextcloud Talk application
|
||||
~
|
||||
~ @author Mario Danic
|
||||
|
@ -34,8 +35,8 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_alignBottom="@id/flexboxQuoted"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:background="@color/colorPrimary" />
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@color/high_emphasis_text" />
|
||||
|
||||
<androidx.emoji.widget.EmojiTextView
|
||||
android:id="@+id/quotedMessageAuthor"
|
||||
|
@ -46,7 +47,7 @@
|
|||
android:layout_toEndOf="@id/quoteColoredView"
|
||||
android:ellipsize="end"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="@color/textColorMaxContrast"
|
||||
android:textColor="@color/medium_emphasis_text"
|
||||
android:textIsSelectable="false"
|
||||
android:textSize="12sp"
|
||||
tools:text="Jane Doe" />
|
||||
|
@ -85,6 +86,7 @@
|
|||
android:layout_alignStart="@id/quotedMessageAuthor"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="@color/high_emphasis_text"
|
||||
android:textIsSelectable="false"
|
||||
android:textSize="14sp"
|
||||
app:layout_alignSelf="flex_start"
|
||||
|
|
Loading…
Reference in a new issue