Эх сурвалжийг харах

preoperly theme quoted messages for Material 3 including alignment

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 жил өмнө
parent
commit
d27f0e2222

+ 9 - 5
app/src/main/java/com/nextcloud/talk/adapters/messages/MagicIncomingTextMessageViewHolder.kt

@@ -48,6 +48,8 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA
 import com.nextcloud.talk.databinding.ItemCustomIncomingTextMessageBinding
 import com.nextcloud.talk.databinding.ItemCustomIncomingTextMessageBinding
 import com.nextcloud.talk.models.json.chat.ChatMessage
 import com.nextcloud.talk.models.json.chat.ChatMessage
 import com.nextcloud.talk.ui.recyclerview.MessageSwipeCallback
 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.ApiUtils
 import com.nextcloud.talk.utils.DisplayUtils
 import com.nextcloud.talk.utils.DisplayUtils
 import com.nextcloud.talk.utils.TextMatchers
 import com.nextcloud.talk.utils.TextMatchers
@@ -64,6 +66,9 @@ class MagicIncomingTextMessageViewHolder(itemView: View, payload: Any) : Message
     @Inject
     @Inject
     lateinit var context: Context
     lateinit var context: Context
 
 
+    @Inject
+    lateinit var viewThemeUtils: ViewThemeUtils
+
     @Inject
     @Inject
     lateinit var appPreferences: AppPreferences
     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
             context!!.getText(R.string.nc_nick_guest) else parentChatMessage.actorDisplayName
         binding.messageQuote.quotedMessage.text = parentChatMessage.text
         binding.messageQuote.quotedMessage.text = parentChatMessage.text
 
 
-        binding.messageQuote.quotedMessageAuthor
-            .setTextColor(ContextCompat.getColor(context!!, R.color.textColorMaxContrast))
-
         if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
         if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
-            binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.colorPrimary)
+            viewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView)
         } else {
         } else {
-            binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.textColorMaxContrast)
+            binding.messageQuote.quoteColoredView.setBackgroundColor(
+                ContextCompat.getColor(binding.messageQuote.quoteColoredView.context, R.color.high_emphasis_text)
+            )
         }
         }
     }
     }
 
 

+ 3 - 9
app/src/main/java/com/nextcloud/talk/adapters/messages/MagicOutcomingTextMessageViewHolder.kt

@@ -30,8 +30,8 @@ import android.text.Spannable
 import android.text.SpannableString
 import android.text.SpannableString
 import android.util.TypedValue
 import android.util.TypedValue
 import android.view.View
 import android.view.View
+import androidx.core.content.ContextCompat
 import androidx.core.content.res.ResourcesCompat
 import androidx.core.content.res.ResourcesCompat
-import androidx.core.graphics.ColorUtils
 import autodagger.AutoInjector
 import autodagger.AutoInjector
 import coil.load
 import coil.load
 import com.google.android.flexbox.FlexboxLayout
 import com.google.android.flexbox.FlexboxLayout
@@ -150,16 +150,10 @@ class MagicOutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessage
         binding.messageQuote.quotedMessageAuthor.text = parentChatMessage.actorDisplayName
         binding.messageQuote.quotedMessageAuthor.text = parentChatMessage.actorDisplayName
             ?: context!!.getText(R.string.nc_nick_guest)
             ?: context!!.getText(R.string.nc_nick_guest)
         binding.messageQuote.quotedMessage.text = parentChatMessage.text
         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) {
     private fun setBubbleOnChatMessage(message: ChatMessage) {

+ 6 - 0
app/src/main/java/com/nextcloud/talk/ui/theme/ViewThemeUtils.kt

@@ -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.
      * Colors the background as element color and the foreground as text color.
      */
      */

+ 6 - 4
app/src/main/res/layout/item_message_quote.xml

@@ -1,4 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?><!--
+<?xml version="1.0" encoding="utf-8"?>
+<!--
   ~ Nextcloud Talk application
   ~ Nextcloud Talk application
   ~
   ~
   ~ @author Mario Danic
   ~ @author Mario Danic
@@ -34,8 +35,8 @@
         android:layout_height="match_parent"
         android:layout_height="match_parent"
         android:layout_alignBottom="@id/flexboxQuoted"
         android:layout_alignBottom="@id/flexboxQuoted"
         android:layout_alignParentStart="true"
         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
     <androidx.emoji.widget.EmojiTextView
         android:id="@+id/quotedMessageAuthor"
         android:id="@+id/quotedMessageAuthor"
@@ -46,7 +47,7 @@
         android:layout_toEndOf="@id/quoteColoredView"
         android:layout_toEndOf="@id/quoteColoredView"
         android:ellipsize="end"
         android:ellipsize="end"
         android:textAlignment="viewStart"
         android:textAlignment="viewStart"
-        android:textColor="@color/textColorMaxContrast"
+        android:textColor="@color/medium_emphasis_text"
         android:textIsSelectable="false"
         android:textIsSelectable="false"
         android:textSize="12sp"
         android:textSize="12sp"
         tools:text="Jane Doe" />
         tools:text="Jane Doe" />
@@ -85,6 +86,7 @@
             android:layout_alignStart="@id/quotedMessageAuthor"
             android:layout_alignStart="@id/quotedMessageAuthor"
             android:lineSpacingMultiplier="1.2"
             android:lineSpacingMultiplier="1.2"
             android:textAlignment="viewStart"
             android:textAlignment="viewStart"
+            android:textColor="@color/high_emphasis_text"
             android:textIsSelectable="false"
             android:textIsSelectable="false"
             android:textSize="14sp"
             android:textSize="14sp"
             app:layout_alignSelf="flex_start"
             app:layout_alignSelf="flex_start"