mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Add icon and colours to quick chat settings
This commit is contained in:
parent
01e24ff6a4
commit
b1b554d97d
5 changed files with 81 additions and 12 deletions
|
|
@ -5,12 +5,13 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.geeksville.mesh.R
|
||||
import com.geeksville.mesh.database.entity.QuickChatAction
|
||||
|
||||
class QuickChatActionAdapter internal constructor(
|
||||
context: Context,
|
||||
private val context: Context,
|
||||
private val onEdit: (action: QuickChatAction) -> Unit,
|
||||
private val repositionAction: (fromPos: Int, toPos: Int) -> Unit,
|
||||
private val commitAction: () -> Unit,
|
||||
|
|
@ -20,9 +21,11 @@ class QuickChatActionAdapter internal constructor(
|
|||
private var actions = emptyList<QuickChatAction>()
|
||||
|
||||
inner class ActionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val container: View = itemView.findViewById(R.id.quickChatActionContainer)
|
||||
val actionName: TextView = itemView.findViewById(R.id.quickChatActionName)
|
||||
val actionValue: TextView = itemView.findViewById(R.id.quickChatActionValue)
|
||||
val actionEdit: View = itemView.findViewById(R.id.quickChatActionEdit)
|
||||
val actionInstant: View = itemView.findViewById(R.id.quickChatActionInstant)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ActionViewHolder {
|
||||
|
|
@ -34,12 +37,18 @@ class QuickChatActionAdapter internal constructor(
|
|||
val current = actions[position]
|
||||
holder.actionName.text = current.name
|
||||
holder.actionValue.text = current.message
|
||||
val isInstant = current.mode == QuickChatAction.Mode.Instant
|
||||
holder.actionInstant.visibility = if (isInstant) View.VISIBLE else View.INVISIBLE
|
||||
if (isInstant) {
|
||||
holder.container.backgroundTintList = ContextCompat.getColorStateList(context, R.color.colorMyMsg)
|
||||
} else {
|
||||
holder.container.backgroundTintList = null
|
||||
}
|
||||
holder.actionEdit.setOnClickListener {
|
||||
onEdit(current)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal fun setActions(actions: List<QuickChatAction>) {
|
||||
this.actions = actions
|
||||
notifyDataSetChanged()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue