From 7a48011aa46f19627e37ea29441253fec46079ce Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 29 Jan 2022 20:30:30 +0100 Subject: [PATCH] properly color the background of pinned clips --- .../keyboard/adapters/ClipsKeyboardAdapter.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/adapters/ClipsKeyboardAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/adapters/ClipsKeyboardAdapter.kt index f5bbd33..ec9056a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/adapters/ClipsKeyboardAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/adapters/ClipsKeyboardAdapter.kt @@ -2,6 +2,8 @@ package com.simplemobiletools.keyboard.adapters import android.annotation.SuppressLint import android.content.Context +import android.graphics.drawable.LayerDrawable +import android.graphics.drawable.RippleDrawable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -33,6 +35,7 @@ class ClipsKeyboardAdapter( private val layoutInflater = LayoutInflater.from(context) private val baseConfig = context.config private var textColor = baseConfig.textColor + private var backgroundColor = baseConfig.backgroundColor override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val layoutId = when (viewType) { @@ -64,10 +67,16 @@ class ClipsKeyboardAdapter( } private fun setupClip(view: View, clip: Clip) { - view.clip_value.apply { - text = clip.value - removeUnderlines() - setTextColor(textColor) + view.apply { + val rippleBg = clip_holder.background as RippleDrawable + val layerDrawable = rippleBg.findDrawableByLayerId(R.id.clipboard_background_holder) as LayerDrawable + layerDrawable.findDrawableByLayerId(R.id.clipboard_background_shape).applyColorFilter(backgroundColor) + + clip_value.apply { + text = clip.value + removeUnderlines() + setTextColor(textColor) + } } }