Using ViewStub for voice recoridng & reply to views
This commit is contained in:
parent
dfa6175b71
commit
b067a49cd0
4 changed files with 43 additions and 7 deletions
|
@ -32,6 +32,7 @@ import android.widget.PopupWindow
|
|||
import androidx.core.content.FileProvider
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
|
@ -493,6 +494,10 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
false
|
||||
}
|
||||
|
||||
binding.setCancelReplyToClickListener {
|
||||
chatSendingViewModel.cancelReply()
|
||||
}
|
||||
|
||||
binding.setScrollToBottomClickListener {
|
||||
scrollToFirstUnreadMessageOrBottom(true)
|
||||
}
|
||||
|
@ -536,6 +541,18 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
}
|
||||
}
|
||||
)
|
||||
|
||||
binding.stubbedMessageToReplyTo.setOnInflateListener { _, inflated ->
|
||||
Log.i("[Chat Room] Replying to message layout inflated")
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
|
||||
binding.stubbedVoiceRecording.setOnInflateListener { _, inflated ->
|
||||
Log.i("[Chat Room] Voice recording layout inflated")
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
}
|
||||
|
||||
override fun deleteItems(indexesOfItemToDelete: ArrayList<Int>) {
|
||||
|
|
|
@ -10,12 +10,16 @@
|
|||
<variable
|
||||
name="data"
|
||||
type="org.linphone.activities.main.chat.data.ChatMessageData" />
|
||||
<variable
|
||||
name="inflatedVisibility"
|
||||
type="Integer" />
|
||||
</data>
|
||||
|
||||
<RelativeLayout
|
||||
android:background="@{data.chatMessage.isOutgoing ? @color/chat_bubble_outgoing_color : @color/chat_bubble_incoming_color, default=@color/chat_bubble_incoming_color}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/reply_layout"
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
<variable
|
||||
name="viewModel"
|
||||
type="org.linphone.activities.main.chat.viewmodels.ChatMessageSendingViewModel" />
|
||||
<variable
|
||||
name="inflatedVisibility"
|
||||
type="Integer" />
|
||||
</data>
|
||||
|
||||
<RelativeLayout
|
||||
|
@ -14,7 +17,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp">
|
||||
android:paddingBottom="10dp"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cancel_recording"
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
<variable
|
||||
name="voiceRecordingTouchListener"
|
||||
type="android.view.View.OnTouchListener" />
|
||||
<variable
|
||||
name="cancelReplyToClickListener"
|
||||
type="android.view.View.OnClickListener" />
|
||||
<variable
|
||||
name="scrollToBottomClickListener"
|
||||
type="android.view.View.OnClickListener"/>
|
||||
|
@ -152,16 +155,24 @@
|
|||
android:background="?attr/lightToolbarBackgroundColor"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
<ViewStub
|
||||
android:id="@+id/stubbed_message_to_reply_to"
|
||||
android:visibility="@{chatSendingViewModel.isPendingAnswer ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:inflatedVisibility="@{chatSendingViewModel.isPendingAnswer ? View.VISIBLE : View.GONE}"
|
||||
app:data="@{chatSendingViewModel.pendingChatMessageToReplyTo}"
|
||||
app:cancelClickListener="@{() -> chatSendingViewModel.cancelReply()}"
|
||||
layout="@layout/chat_message_reply" />
|
||||
android:layout="@layout/chat_message_reply"
|
||||
app:cancelClickListener="@{cancelReplyToClickListener}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<include
|
||||
<ViewStub
|
||||
android:id="@+id/stubbed_voice_recording"
|
||||
android:visibility="@{chatSendingViewModel.isPendingVoiceRecord ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:inflatedVisibility="@{chatSendingViewModel.isPendingVoiceRecord ? View.VISIBLE : View.GONE}"
|
||||
app:viewModel="@{chatSendingViewModel}"
|
||||
layout="@layout/chat_message_voice_recording" />
|
||||
android:layout="@layout/chat_message_voice_recording"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<View
|
||||
android:visibility="@{chatSendingViewModel.isPendingVoiceRecord && chatSendingViewModel.attachments.size() > 0 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
|
|
Loading…
Reference in a new issue