WebRTC call: draggable views should be sticky

This commit is contained in:
ganfra 2021-07-13 19:37:53 +02:00
parent 0da8a46311
commit a102fc4ec3
2 changed files with 82 additions and 65 deletions

View file

@ -103,6 +103,7 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
private var rootEglBase: EglBase? = null
private var pipDraggrableView: DraggableView<MaterialCardView>? = null
private var otherCallDraggableView: DraggableView<MaterialCardView>? = null
var surfaceRenderersAreInitialized = false
@ -191,7 +192,7 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
}
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) = withState(callViewModel) {
renderState(it)
renderState(it)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
@ -242,13 +243,15 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
is CallState.CreateOffer,
is CallState.LocalRinging,
is CallState.Dialing -> {
views.callVideoGroup.isVisible = false
views.fullscreenRenderer.isVisible = false
views.pipRendererWrapper.isVisible = false
views.callInfoGroup.isVisible = true
views.callToolbar.setSubtitle(R.string.call_ringing)
configureCallInfo(state)
}
is CallState.Answering -> {
views.callVideoGroup.isVisible = false
views.fullscreenRenderer.isVisible = false
views.pipRendererWrapper.isVisible = false
views.callInfoGroup.isVisible = true
views.callToolbar.setSubtitle(R.string.call_connecting)
configureCallInfo(state)
@ -258,7 +261,8 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
if (callState.iceConnectionState == MxPeerConnectionState.CONNECTED) {
if (state.isLocalOnHold || state.isRemoteOnHold) {
views.smallIsHeldIcon.isVisible = true
views.callVideoGroup.isVisible = false
views.fullscreenRenderer.isVisible = false
views.pipRendererWrapper.isVisible = false
views.callInfoGroup.isVisible = true
configureCallInfo(state, blurAvatar = true)
if (state.isRemoteOnHold) {
@ -285,17 +289,20 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
} else {
configureCallInfo(state)
if (callArgs.isVideoCall) {
views.callVideoGroup.isVisible = true
views.fullscreenRenderer.isVisible = true
views.pipRendererWrapper.isVisible = true
views.callInfoGroup.isVisible = false
views.pipRenderer.isVisible = !state.isVideoCaptureInError && state.otherKnownCallInfo == null
} else {
views.callVideoGroup.isVisible = false
views.fullscreenRenderer.isVisible = false
views.pipRendererWrapper.isVisible = false
views.callInfoGroup.isVisible = true
}
}
} else {
// This state is not final, if you change network, new candidates will be sent
views.callVideoGroup.isVisible = false
views.fullscreenRenderer.isVisible = false
views.pipRendererWrapper.isVisible = false
views.callInfoGroup.isVisible = true
configureCallInfo(state)
views.callToolbar.setSubtitle(R.string.call_connecting)
@ -315,6 +322,7 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
views.callControlsView.isVisible = false
views.pipRendererWrapper.isVisible = false
views.pipRenderer.isVisible = false
views.callActionText.isVisible = false
when (callState) {
is CallState.Idle,
is CallState.CreateOffer,
@ -396,7 +404,13 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
finish()
}
}
pipDraggrableView = views.pipRendererWrapper.setupDraggable().build()
pipDraggrableView = views.pipRendererWrapper.setupDraggable()
.setStickyMode(DraggableView.Mode.STICKY_XY)
.build()
otherCallDraggableView = views.otherKnownCallLayout.setupDraggable()
.setStickyMode(DraggableView.Mode.STICKY_XY)
.build()
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {

View file

@ -29,25 +29,71 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/pipRendererWrapper"
android:layout_width="@dimen/call_pip_width"
android:layout_height="@dimen/call_pip_height"
app:cardCornerRadius="@dimen/call_pip_radius"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
app:layout_goneMarginEnd="0dp"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/pipContainer"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/callControlsView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/callControlsView">
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/callToolbar">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/pipRenderer"
<com.google.android.material.card.MaterialCardView
android:id="@+id/pipRendererWrapper"
android:layout_width="@dimen/call_pip_width"
android:layout_height="@dimen/call_pip_height"
android:visibility="gone"
tools:visibility="visible" />
android:layout_marginEnd="16dp"
app:layout_goneMarginEnd="0dp"
app:cardCornerRadius="@dimen/call_pip_radius"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/pipRenderer"
android:layout_width="@dimen/call_pip_width"
android:layout_height="@dimen/call_pip_height"
android:visibility="gone"
tools:visibility="visible" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="@+id/otherKnownCallLayout"
android:layout_width="@dimen/call_pip_width"
android:layout_height="@dimen/call_pip_height"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="@color/element_background_light"
android:foreground="?attr/selectableItemBackground"
android:visibility="gone"
app:cardBackgroundColor="@color/bg_call_screen"
app:cardCornerRadius="@dimen/call_pip_radius"
app:cardElevation="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/pipRendererWrapper"
tools:visibility="visible">
<ImageView
android:id="@+id/otherKnownCallAvatarView"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center"
android:importantForAccessibility="no"
android:scaleType="centerCrop"
tools:src="@tools:sample/avatars" />
<ImageView
android:id="@+id/otherSmallIsHeldIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:importantForAccessibility="no"
android:src="@drawable/ic_call_small_pause" />
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/callToolbar"
@ -68,41 +114,6 @@
app:titleTextAppearance="@style/TextAppearance.Vector.Body.Medium"
app:titleTextColor="@color/element_background_light" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/otherKnownCallLayout"
android:layout_width="@dimen/call_pip_width"
android:layout_height="@dimen/call_pip_height"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="@color/element_background_light"
android:foreground="?attr/selectableItemBackground"
android:visibility="gone"
app:cardBackgroundColor="@color/bg_call_screen"
app:cardCornerRadius="@dimen/call_pip_radius"
app:cardElevation="4dp"
app:layout_constraintBottom_toTopOf="@id/callControlsView"
app:layout_constraintEnd_toStartOf="@id/pipRendererWrapper"
tools:visibility="visible">
<ImageView
android:id="@+id/otherKnownCallAvatarView"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center"
android:importantForAccessibility="no"
android:scaleType="centerCrop"
tools:src="@tools:sample/avatars" />
<ImageView
android:id="@+id/otherSmallIsHeldIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:importantForAccessibility="no"
android:src="@drawable/ic_call_small_pause" />
</com.google.android.material.card.MaterialCardView>
<ImageView
android:id="@+id/otherMemberAvatar"
android:layout_width="120dp"
@ -164,14 +175,6 @@
android:visibility="visible"
app:constraint_referenced_ids="participantNameText, otherMemberAvatar" />
<androidx.constraintlayout.widget.Group
android:id="@+id/callVideoGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
app:constraint_referenced_ids="pipRendererWrapper, fullscreenRenderer"
tools:visibility="invisible" />
<im.vector.app.features.call.CallControlsView
android:id="@+id/callControlsView"
android:layout_width="match_parent"