Reworked how lifecyle owner is set on view stubs after being inflated, fixes voice messages UI not being updated when playing
This commit is contained in:
parent
98aae5af37
commit
ab6c3004de
24 changed files with 46 additions and 115 deletions
|
@ -33,7 +33,6 @@ import androidx.core.content.ContextCompat
|
|||
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.recyclerview.widget.ItemTouchHelper
|
||||
|
@ -678,18 +677,6 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
sharedViewModel.isPendingMessageForward.value = false
|
||||
}
|
||||
}
|
||||
|
||||
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>) {
|
||||
|
|
|
@ -30,8 +30,6 @@ import android.widget.Chronometer
|
|||
import android.widget.Toast
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import androidx.transition.AutoTransition
|
||||
import androidx.transition.TransitionManager
|
||||
|
@ -252,49 +250,6 @@ class ConferenceCallFragment : GenericFragment<VoipConferenceCallFragmentBinding
|
|||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
binding.stubbedConferenceActiveSpeakerLayout.setOnInflateListener { _, inflated ->
|
||||
Log.i("[Conference Call] Active speaker conference layout inflated")
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
startTimer(R.id.active_conference_timer)
|
||||
|
||||
adjustActiveSpeakerLayout()
|
||||
}
|
||||
|
||||
binding.stubbedConferenceGridLayout.setOnInflateListener { _, inflated ->
|
||||
Log.i("[Conference Call] Mosaic conference layout inflated")
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
startTimer(R.id.active_conference_timer)
|
||||
}
|
||||
|
||||
binding.stubbedConferenceAudioOnlyLayout.setOnInflateListener { _, inflated ->
|
||||
Log.i("[Conference Call] Audio only conference layout inflated")
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
startTimer(R.id.active_conference_timer)
|
||||
}
|
||||
|
||||
binding.stubbedAudioRoutes.setOnInflateListener { _, inflated ->
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
|
||||
binding.stubbedNumpad.setOnInflateListener { _, inflated ->
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
|
||||
binding.stubbedCallStats.setOnInflateListener { _, inflated ->
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
|
||||
binding.stubbedPausedConference.setOnInflateListener { _, inflated ->
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
|
|
@ -23,8 +23,6 @@ import android.os.Bundle
|
|||
import android.os.SystemClock
|
||||
import android.view.View
|
||||
import android.widget.Chronometer
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
|
@ -84,10 +82,5 @@ class OutgoingCallFragment : GenericVideoPreviewFragment<VoipCallOutgoingFragmen
|
|||
coreContext.core.nativePreviewWindowId = binding.localPreviewVideoSurface
|
||||
}
|
||||
}
|
||||
|
||||
binding.stubNumpad.setOnInflateListener { _, inflated ->
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ import android.os.SystemClock
|
|||
import android.view.View
|
||||
import android.widget.Chronometer
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import androidx.window.layout.FoldingFeature
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
|
@ -162,31 +160,6 @@ class SingleCallFragment : GenericVideoPreviewFragment<VoipSingleCallFragmentBin
|
|||
|
||||
coreContext.core.nativeVideoWindowId = binding.remoteVideoSurface
|
||||
coreContext.core.nativePreviewWindowId = binding.localPreviewVideoSurface
|
||||
|
||||
binding.stubbedAudioRoutes.setOnInflateListener { _, inflated ->
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
|
||||
binding.stubbedNumpad.setOnInflateListener { _, inflated ->
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
|
||||
binding.stubbedCallStats.setOnInflateListener { _, inflated ->
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
|
||||
binding.stubbedPausedCall.setOnInflateListener { _, inflated ->
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
|
||||
binding.stubbedRemotelyPausedCall.setOnInflateListener { _, inflated ->
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(inflated)
|
||||
binding?.lifecycleOwner = viewLifecycleOwner
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
|
|
@ -25,10 +25,7 @@ import android.content.Context
|
|||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.util.Patterns
|
||||
import android.view.LayoutInflater
|
||||
import android.view.TextureView
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.*
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.*
|
||||
|
@ -228,6 +225,13 @@ fun setListener(view: SeekBar, lambda: (Any) -> Unit) {
|
|||
})
|
||||
}
|
||||
|
||||
@BindingAdapter("inflatedLifecycleOwner")
|
||||
fun setInflatedViewStubLifecycleOwner(view: View, enable: Boolean) {
|
||||
val binding = DataBindingUtil.bind<ViewDataBinding>(view)
|
||||
// This is a bit hacky...
|
||||
binding?.lifecycleOwner = view.context as GenericActivity
|
||||
}
|
||||
|
||||
@BindingAdapter("entries")
|
||||
fun setEntries(
|
||||
viewGroup: ViewGroup,
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_margin="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? @dimen/margin_0dp : @dimen/voip_remote_margin, default=@dimen/voip_remote_margin}"
|
||||
android:paddingBottom="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? @dimen/margin_0dp : @dimen/voip_buttons_fragment_margin_size}"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<View
|
||||
android:id="@+id/top_barrier"
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_margin="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? @dimen/margin_0dp : @dimen/voip_remote_margin, default=@dimen/voip_remote_margin}"
|
||||
android:paddingBottom="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? @dimen/margin_0dp : @dimen/voip_buttons_fragment_margin_size}"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<View
|
||||
android:id="@+id/top_barrier"
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@color/voip_translucent_popup_background"
|
||||
android:clickable="true"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<View
|
||||
android:id="@+id/background"
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
android:orientation="vertical"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/shape_conference_invite_background"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="?attr/backgroundColor"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<TextView
|
||||
style="@style/chat_file_attachment_font"
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="?attr/backgroundColor"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<TextView
|
||||
style="@style/chat_file_attachment_font"
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<ImageView
|
||||
android:onClick="@{() -> data.openFile()}"
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
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:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/reply_layout"
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<ImageView
|
||||
android:onClick="@{() -> data.openFile()}"
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onLongClick="@{longClickListener}"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<org.linphone.views.VoiceRecordProgressBar
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cancel_recording"
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
android:background="@color/voip_translucent_popup_background"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/resume_call"
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
android:background="@color/voip_translucent_popup_background"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/paused_call"
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@color/voip_translucent_popup_background"
|
||||
android:clickable="true"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<View
|
||||
android:id="@+id/background"
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_margin="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? @dimen/margin_0dp : @dimen/voip_remote_margin, default=@dimen/voip_remote_margin}"
|
||||
android:paddingBottom="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? @dimen/margin_0dp : @dimen/voip_buttons_fragment_margin_size}"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<View
|
||||
android:id="@+id/top_barrier"
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_margin="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? @dimen/margin_0dp : @dimen/voip_remote_margin, default=@dimen/voip_remote_margin}"
|
||||
android:paddingBottom="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? @dimen/margin_0dp : @dimen/voip_buttons_fragment_margin_size}"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<View
|
||||
android:id="@+id/top_barrier"
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_margin="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? @dimen/margin_0dp : @dimen/voip_remote_margin, default=@dimen/voip_remote_margin}"
|
||||
android:paddingBottom="@{controlsViewModel.fullScreenMode || controlsViewModel.pipMode ? @dimen/margin_0dp : @dimen/voip_buttons_fragment_margin_size}"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<View
|
||||
android:id="@+id/top_barrier"
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
android:background="@color/voip_translucent_popup_background"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/resume_conference"
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@color/voip_translucent_popup_background"
|
||||
android:clickable="true"
|
||||
android:visibility="@{inflatedVisibility}">
|
||||
android:visibility="@{inflatedVisibility}"
|
||||
inflatedLifecycleOwner="@{true}">
|
||||
|
||||
<View
|
||||
android:id="@+id/background"
|
||||
|
|
Loading…
Reference in a new issue