This commit is contained in:
Niels Andriesse 2021-06-16 09:51:50 +10:00
parent 196fc25902
commit 871bafe66d
3 changed files with 28 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import android.os.Bundle
import android.view.ActionMode import android.view.ActionMode
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.widget.RelativeLayout
import androidx.loader.app.LoaderManager import androidx.loader.app.LoaderManager
import androidx.loader.content.Loader import androidx.loader.content.Loader
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -13,13 +14,14 @@ import kotlinx.android.synthetic.main.activity_conversation_v2_action_bar.*
import kotlinx.android.synthetic.main.view_input_bar.view.* import kotlinx.android.synthetic.main.view_input_bar.view.*
import network.loki.messenger.R import network.loki.messenger.R
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
import org.thoughtcrime.securesms.conversation.v2.input_bar.InputBarDelegate
import org.thoughtcrime.securesms.conversation.v2.menus.ConversationActionModeCallback import org.thoughtcrime.securesms.conversation.v2.menus.ConversationActionModeCallback
import org.thoughtcrime.securesms.conversation.v2.menus.ConversationMenuHelper import org.thoughtcrime.securesms.conversation.v2.menus.ConversationMenuHelper
import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.database.model.MessageRecord import org.thoughtcrime.securesms.database.model.MessageRecord
import org.thoughtcrime.securesms.mms.GlideApp import org.thoughtcrime.securesms.mms.GlideApp
class ConversationActivityV2 : PassphraseRequiredActionBarActivity() { class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDelegate {
private var threadID: Long = -1 private var threadID: Long = -1
private var actionMode: ActionMode? = null private var actionMode: ActionMode? = null
@ -64,6 +66,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity() {
threadID = intent.getLongExtra(THREAD_ID, -1) threadID = intent.getLongExtra(THREAD_ID, -1)
setUpRecyclerView() setUpRecyclerView()
setUpToolBar() setUpToolBar()
inputBar.delegate = this
} }
private fun setUpRecyclerView() { private fun setUpRecyclerView() {
@ -103,6 +106,14 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity() {
} }
// endregion // endregion
// region Updating
override fun inputBarHeightChanged(newValue: Int) {
val recyclerViewLayoutParams = conversationRecyclerView.layoutParams as RelativeLayout.LayoutParams
recyclerViewLayoutParams.bottomMargin = newValue
conversationRecyclerView.layoutParams = recyclerViewLayoutParams
}
// endregion
// region Interaction // region Interaction
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
// TODO: Implement // TODO: Implement

View File

@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.conversation.v2.input_bar
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.RelativeLayout import android.widget.RelativeLayout
@ -12,6 +13,7 @@ import org.thoughtcrime.securesms.loki.utilities.toDp
import kotlin.math.roundToInt import kotlin.math.roundToInt
class InputBar : LinearLayout, InputBarEditTextDelegate { class InputBar : LinearLayout, InputBarEditTextDelegate {
var delegate: InputBarDelegate? = null
private val attachmentsButton by lazy { InputBarButton(context, R.drawable.ic_plus_24) } private val attachmentsButton by lazy { InputBarButton(context, R.drawable.ic_plus_24) }
private val microphoneButton by lazy { InputBarButton(context, R.drawable.ic_microphone) } private val microphoneButton by lazy { InputBarButton(context, R.drawable.ic_microphone) }
@ -43,10 +45,17 @@ class InputBar : LinearLayout, InputBarEditTextDelegate {
// endregion // endregion
override fun inputBarEditTextHeightChanged(newValue: Int) { override fun inputBarEditTextHeightChanged(newValue: Int) {
val vMargin = resources.getDimension(R.dimen.small_spacing).roundToInt() val vMargin = toDp(4, resources)
val layoutParams = this.layoutParams as RelativeLayout.LayoutParams val layoutParams = inputBarLinearLayout.layoutParams as LayoutParams
layoutParams.height = newValue + 2 * vMargin val newHeight = newValue + 2 * vMargin
this.layoutParams = layoutParams layoutParams.height = newHeight
inputBarLinearLayout.layoutParams = layoutParams
delegate?.inputBarHeightChanged(newHeight)
} }
// endregion // endregion
} }
interface InputBarDelegate {
fun inputBarHeightChanged(newValue: Int)
}

View File

@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/inputBarLinearLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/input_bar_height" android:layout_height="@dimen/input_bar_height"
android:orientation="vertical"> android:orientation="vertical"
android:background="@color/input_bar_background">
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"