|
|
|
@ -1,13 +1,14 @@
|
|
|
|
|
package org.thoughtcrime.securesms.components.menu
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import android.content.res.ColorStateList
|
|
|
|
|
import android.util.TypedValue
|
|
|
|
|
import android.view.View
|
|
|
|
|
import android.widget.ImageView
|
|
|
|
|
import android.widget.TextView
|
|
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
|
import androidx.core.view.isGone
|
|
|
|
|
import androidx.core.view.isVisible
|
|
|
|
|
import androidx.core.widget.ImageViewCompat
|
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
|
@ -78,19 +79,26 @@ class ContextMenuList(recyclerView: RecyclerView, onItemClick: () -> Unit) {
|
|
|
|
|
val subtitle: TextView = itemView.findViewById(R.id.context_menu_item_subtitle)
|
|
|
|
|
|
|
|
|
|
override fun bind(model: DisplayItem) {
|
|
|
|
|
if (model.item.iconRes > 0) {
|
|
|
|
|
val item = model.item
|
|
|
|
|
val color = item.color?.let { ContextCompat.getColor(context, it) }
|
|
|
|
|
|
|
|
|
|
if (item.iconRes > 0) {
|
|
|
|
|
val typedValue = TypedValue()
|
|
|
|
|
context.theme.resolveAttribute(model.item.iconRes, typedValue, true)
|
|
|
|
|
context.theme.resolveAttribute(item.iconRes, typedValue, true)
|
|
|
|
|
icon.setImageDrawable(ContextCompat.getDrawable(context, typedValue.resourceId))
|
|
|
|
|
|
|
|
|
|
icon.imageTintList = color?.let(ColorStateList::valueOf)
|
|
|
|
|
}
|
|
|
|
|
model.item.contentDescription?.let(context.resources::getString)?.let { itemView.contentDescription = it }
|
|
|
|
|
title.setText(model.item.title)
|
|
|
|
|
item.contentDescription?.let(context.resources::getString)?.let { itemView.contentDescription = it }
|
|
|
|
|
title.setText(item.title)
|
|
|
|
|
color?.let(title::setTextColor)
|
|
|
|
|
color?.let(title::setTextColor)
|
|
|
|
|
subtitle.isGone = true
|
|
|
|
|
model.item.subtitle?.let {
|
|
|
|
|
item.subtitle?.let {
|
|
|
|
|
startSubtitleJob(subtitle, it)
|
|
|
|
|
}
|
|
|
|
|
itemView.setOnClickListener {
|
|
|
|
|
model.item.action.run()
|
|
|
|
|
item.action.run()
|
|
|
|
|
onItemClick()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|