2021-05-31 06:06:02 +02:00
|
|
|
package org.thoughtcrime.securesms.conversation.v2.messages
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.util.AttributeSet
|
2021-05-31 06:29:11 +02:00
|
|
|
import android.view.LayoutInflater
|
2021-06-01 07:43:37 +02:00
|
|
|
import android.view.View
|
2021-05-31 06:06:02 +02:00
|
|
|
import android.widget.LinearLayout
|
2021-06-01 07:43:37 +02:00
|
|
|
import androidx.core.content.res.ResourcesCompat
|
2021-06-01 05:01:03 +02:00
|
|
|
import kotlinx.android.synthetic.main.view_control_message.view.*
|
2021-05-31 06:29:11 +02:00
|
|
|
import network.loki.messenger.R
|
2021-05-31 06:06:02 +02:00
|
|
|
import org.thoughtcrime.securesms.database.model.MessageRecord
|
|
|
|
|
2021-06-01 01:48:02 +02:00
|
|
|
class ControlMessageView : LinearLayout {
|
2021-05-31 06:06:02 +02:00
|
|
|
|
|
|
|
// region Lifecycle
|
|
|
|
constructor(context: Context) : super(context) {
|
|
|
|
setUpViewHierarchy()
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
|
|
|
setUpViewHierarchy()
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
|
|
|
setUpViewHierarchy()
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun setUpViewHierarchy() {
|
2021-06-01 01:48:02 +02:00
|
|
|
LayoutInflater.from(context).inflate(R.layout.view_control_message, this)
|
2021-05-31 06:06:02 +02:00
|
|
|
}
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
// region Updating
|
|
|
|
fun bind(message: MessageRecord) {
|
2021-06-01 07:43:37 +02:00
|
|
|
iconImageView.visibility = View.GONE
|
|
|
|
if (message.isExpirationTimerUpdate) {
|
|
|
|
iconImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_timer, context.theme))
|
|
|
|
iconImageView.visibility = View.VISIBLE
|
|
|
|
}
|
2021-06-01 06:28:14 +02:00
|
|
|
textView.text = message.getDisplayBody(context)
|
2021-05-31 06:06:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fun recycle() {
|
|
|
|
// TODO: Implement
|
|
|
|
}
|
|
|
|
// endregion
|
|
|
|
}
|