mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Fix height change handling
This commit is contained in:
parent
123cd6d486
commit
9471db76c2
@ -10,12 +10,14 @@ import androidx.core.view.isVisible
|
||||
import kotlinx.android.synthetic.main.view_input_bar.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.conversation.v2.messages.QuoteView
|
||||
import org.thoughtcrime.securesms.conversation.v2.messages.QuoteViewDelegate
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.loki.utilities.toDp
|
||||
import org.thoughtcrime.securesms.loki.utilities.toPx
|
||||
import kotlin.math.max
|
||||
|
||||
class InputBar : RelativeLayout, InputBarEditTextDelegate {
|
||||
class InputBar : RelativeLayout, InputBarEditTextDelegate, QuoteViewDelegate {
|
||||
private val vMargin by lazy { toDp(4, resources) }
|
||||
var delegate: InputBarDelegate? = null
|
||||
|
||||
private val attachmentsButton by lazy { InputBarButton(context, R.drawable.ic_plus_24) }
|
||||
@ -67,8 +69,7 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate {
|
||||
}
|
||||
|
||||
override fun inputBarEditTextHeightChanged(newValue: Int) {
|
||||
val vMargin = toDp(4, resources)
|
||||
val newHeight = max(newValue + 2 * vMargin + inputBarAdditionalContentContainer.height, toPx(56, resources))
|
||||
val newHeight = max(newValue + 2 * vMargin, toPx(56, resources)) + inputBarAdditionalContentContainer.height
|
||||
setHeight(newHeight)
|
||||
}
|
||||
|
||||
@ -83,9 +84,16 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate {
|
||||
fun draftQuote(message: MessageRecord) {
|
||||
inputBarAdditionalContentContainer.removeAllViews()
|
||||
val quoteView = QuoteView(context)
|
||||
quoteView.delegate = this
|
||||
inputBarAdditionalContentContainer.addView(quoteView)
|
||||
quoteView.bind(message.individualRecipient.address.toString(), message.body, null, message.recipient)
|
||||
val newHeight = height + quoteView.getIntrinsicHeight()
|
||||
val newHeight = max(inputBarEditText.height + 2 * vMargin, toPx(56, resources)) + quoteView.getIntrinsicHeight()
|
||||
setHeight(newHeight)
|
||||
}
|
||||
|
||||
override fun cancelQuoteDraft() {
|
||||
inputBarAdditionalContentContainer.removeAllViews()
|
||||
val newHeight = max(inputBarEditText.height + 2 * vMargin, toPx(56, resources))
|
||||
setHeight(newHeight)
|
||||
}
|
||||
// endregion
|
||||
|
@ -22,6 +22,7 @@ import kotlin.math.min
|
||||
class QuoteView : LinearLayout {
|
||||
private val screenWidth by lazy { Resources.getSystem().displayMetrics.widthPixels }
|
||||
private val vPadding by lazy { toPx(6, resources) }
|
||||
var delegate: QuoteViewDelegate? = null
|
||||
|
||||
enum class Mode { Regular, Draft }
|
||||
|
||||
@ -32,6 +33,7 @@ class QuoteView : LinearLayout {
|
||||
|
||||
private fun initialize() {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_quote, this)
|
||||
quoteViewCancelButton.setOnClickListener { delegate?.cancelQuoteDraft() }
|
||||
}
|
||||
// endregion
|
||||
|
||||
@ -75,4 +77,9 @@ class QuoteView : LinearLayout {
|
||||
quoteViewAccentLine.layoutParams = accentLineLayoutParams
|
||||
}
|
||||
// endregion
|
||||
}
|
||||
|
||||
interface QuoteViewDelegate {
|
||||
|
||||
fun cancelQuoteDraft()
|
||||
}
|
@ -52,6 +52,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/quoteViewCancelButton"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:padding="6dp"
|
||||
|
Loading…
x
Reference in New Issue
Block a user