Bubbles : fix background colors

This commit is contained in:
ganfra 2022-01-13 12:33:36 +01:00
parent 37af93fba4
commit b9cc795996
5 changed files with 8 additions and 16 deletions

View file

@ -13,9 +13,6 @@
<color name="button_bot_background_color">#14368BD6</color>
<color name="button_bot_enabled_text_color">@color/palette_azure</color>
<color name="bubble_background_outgoing">#0F0DBD8B</color>
<color name="bubble_background_incoming">@color/element_system_light</color>
<!-- Notification (do not depends on theme) -->
<color name="notification_accent_color">@color/palette_azure</color>
<color name="key_share_req_accent_color">@color/palette_melon</color>

View file

@ -17,6 +17,7 @@
package im.vector.app.features.home.room.detail.timeline.view
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.View
@ -26,12 +27,14 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.content.ContextCompat
import androidx.core.content.withStyledAttributes
import androidx.core.graphics.ColorUtils
import androidx.core.view.updateLayoutParams
import com.google.android.material.shape.CornerFamily
import com.google.android.material.shape.MaterialShapeDrawable
import com.google.android.material.shape.ShapeAppearanceModel
import im.vector.app.R
import im.vector.app.core.utils.DimensionConverter
import im.vector.app.features.themes.ThemeUtils
class MessageBubbleView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null,
defStyleAttr: Int = 0)
@ -116,7 +119,6 @@ class MessageBubbleView @JvmOverloads constructor(context: Context, attrs: Attri
}
applyTo(bubbleView)
}
}
private fun createBackgroundDrawable(): Drawable {
@ -133,14 +135,16 @@ class MessageBubbleView @JvmOverloads constructor(context: Context, attrs: Attri
val shapeAppearanceModelBuilder = ShapeAppearanceModel().toBuilder()
val backgroundColor: Int
if (isIncoming) {
backgroundColor = R.color.bubble_background_incoming
backgroundColor = ThemeUtils.getColor(context, R.attr.vctr_system)
shapeAppearanceModelBuilder
.setTopRightCorner(CornerFamily.ROUNDED, cornerRadius)
.setBottomRightCorner(CornerFamily.ROUNDED, cornerRadius)
.setTopLeftCorner(topCornerFamily, topRadius)
.setBottomLeftCorner(bottomCornerFamily, bottomRadius)
} else {
backgroundColor = R.color.bubble_background_outgoing
val resolvedColor = ContextCompat.getColor(context, R.color.palette_element_green)
val alpha = if (ThemeUtils.isLightTheme(context)) 0x0E else 0x26
backgroundColor = ColorUtils.setAlphaComponent(resolvedColor, alpha)
shapeAppearanceModelBuilder
.setTopLeftCorner(CornerFamily.ROUNDED, cornerRadius)
.setBottomLeftCorner(CornerFamily.ROUNDED, cornerRadius)
@ -149,7 +153,7 @@ class MessageBubbleView @JvmOverloads constructor(context: Context, attrs: Attri
}
val shapeAppearanceModel = shapeAppearanceModelBuilder.build()
return MaterialShapeDrawable(shapeAppearanceModel).apply {
fillColor = ContextCompat.getColorStateList(context, backgroundColor)
fillColor = ColorStateList.valueOf(backgroundColor)
}
}
}

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?attr/vctr_system" />
</shape>

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#0F0DBD8B" />
</shape>

View file

@ -91,7 +91,6 @@
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:addStatesFromChildren="true"
android:background="@drawable/bg_timeline_incoming_message"
android:paddingStart="4dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">