2021-06-01 06:56:58 +02:00
|
|
|
package org.thoughtcrime.securesms.conversation.v2.messages
|
|
|
|
|
|
|
|
import android.content.Context
|
2021-06-18 07:11:41 +02:00
|
|
|
import android.content.res.Resources
|
2021-06-01 06:56:58 +02:00
|
|
|
import android.util.AttributeSet
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.widget.LinearLayout
|
2021-06-18 07:11:41 +02:00
|
|
|
import android.widget.RelativeLayout
|
2021-06-01 06:56:58 +02:00
|
|
|
import kotlinx.android.synthetic.main.view_quote.view.*
|
|
|
|
import network.loki.messenger.R
|
2021-06-18 07:11:41 +02:00
|
|
|
import org.session.libsession.utilities.recipients.Recipient
|
|
|
|
import org.thoughtcrime.securesms.conversation.v2.utilities.TextUtilities
|
2021-06-01 06:56:58 +02:00
|
|
|
import org.thoughtcrime.securesms.database.model.MessageRecord
|
2021-06-18 07:11:41 +02:00
|
|
|
import org.thoughtcrime.securesms.loki.utilities.toPx
|
|
|
|
import org.thoughtcrime.securesms.mms.SlideDeck
|
2021-06-01 06:56:58 +02:00
|
|
|
|
|
|
|
class QuoteView : LinearLayout {
|
2021-06-18 07:11:41 +02:00
|
|
|
private val screenWidth by lazy { Resources.getSystem().displayMetrics.widthPixels }
|
2021-06-01 06:56:58 +02:00
|
|
|
|
2021-06-18 07:11:41 +02:00
|
|
|
enum class Mode { Regular, Draft }
|
2021-06-01 06:56:58 +02:00
|
|
|
|
2021-06-18 07:11:41 +02:00
|
|
|
// region Lifecycle
|
|
|
|
constructor(context: Context) : super(context) { initialize() }
|
|
|
|
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { initialize() }
|
|
|
|
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { initialize() }
|
2021-06-01 06:56:58 +02:00
|
|
|
|
2021-06-18 07:11:41 +02:00
|
|
|
private fun initialize() {
|
|
|
|
LayoutInflater.from(context).inflate(R.layout.view_quote, this)
|
2021-06-01 06:56:58 +02:00
|
|
|
}
|
2021-06-18 07:11:41 +02:00
|
|
|
// endregion
|
2021-06-01 06:56:58 +02:00
|
|
|
|
2021-06-18 07:11:41 +02:00
|
|
|
// region General
|
|
|
|
fun getIntrinsicHeight(): Int {
|
|
|
|
var result = 0
|
|
|
|
val width = screenWidth
|
|
|
|
val author = quoteViewAuthorTextView.text
|
|
|
|
result += TextUtilities.getIntrinsicHeight(author, quoteViewAuthorTextView.paint, width)
|
|
|
|
val body = quoteViewBodyTextView.text
|
|
|
|
result += TextUtilities.getIntrinsicHeight(body, quoteViewBodyTextView.paint, width)
|
|
|
|
return result
|
2021-06-01 06:56:58 +02:00
|
|
|
}
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
// region Updating
|
2021-06-18 07:11:41 +02:00
|
|
|
fun bind(authorPublicKey: String, body: String, attachments: SlideDeck?, thread: Recipient) {
|
|
|
|
val accentLineLayoutParams = quoteViewAccentLine.layoutParams as RelativeLayout.LayoutParams
|
|
|
|
accentLineLayoutParams.height = getIntrinsicHeight()
|
|
|
|
quoteViewAccentLine.layoutParams = accentLineLayoutParams
|
2021-06-01 06:56:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fun recycle() {
|
|
|
|
// TODO: Implement
|
|
|
|
}
|
|
|
|
// endregion
|
|
|
|
}
|