From 7d77690245b27e67b76882f2fe02952328c88ddc Mon Sep 17 00:00:00 2001 From: gavine99 Date: Thu, 13 Mar 2025 14:40:31 +1100 Subject: [PATCH] change text selection handle and background colors in compose screen bubbles to ensure they always have a high(ish) contrast to bubble colours and to match with theme color --- .../moez/QKSMS/feature/compose/MessagesAdapter.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt index c4421ef1..da362703 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/MessagesAdapter.kt @@ -22,6 +22,7 @@ import android.animation.ObjectAnimator import android.content.Context import android.graphics.Typeface import android.net.Uri +import android.os.Build import android.text.Layout import android.text.Spannable import android.text.SpannableString @@ -49,6 +50,7 @@ import dev.octoshrimpy.quik.common.util.extensions.setBackgroundTint import dev.octoshrimpy.quik.common.util.extensions.setPadding import dev.octoshrimpy.quik.common.util.extensions.setTint import dev.octoshrimpy.quik.common.util.extensions.setVisible +import dev.octoshrimpy.quik.common.util.extensions.withAlpha import dev.octoshrimpy.quik.compat.SubscriptionManagerCompat import dev.octoshrimpy.quik.extensions.isSmil import dev.octoshrimpy.quik.extensions.isText @@ -276,6 +278,19 @@ class MessagesAdapter @Inject constructor( holder.body.setTextColor(theme.textPrimary) holder.body.setBackgroundTint(theme.theme) + holder.body.highlightColor = R.attr.bubbleColor.withAlpha(0x5d) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + holder.body.textSelectHandle?.setTint(R.attr.bubbleColor.withAlpha(0x7d)) + holder.body.textSelectHandleLeft?.setTint(R.attr.bubbleColor.withAlpha(0x7d)) + holder.body.textSelectHandleRight?.setTint(R.attr.bubbleColor.withAlpha(0x7d)) + } + } else { + holder.body.highlightColor = theme.theme.withAlpha(0x5d) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + holder.body.textSelectHandle?.setTint(theme.theme.withAlpha(0xad)) + holder.body.textSelectHandleLeft?.setTint(theme.theme.withAlpha(0xad)) + holder.body.textSelectHandleRight?.setTint(theme.theme.withAlpha(0xad)) + } } // Bind the body text