Merge pull request #4939 from nextcloud/improvePipMode

Improve pip mode
This commit is contained in:
Marcel Hibbe 2025-05-07 07:58:57 +00:00 committed by GitHub
commit d1500c9c75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 50 additions and 17 deletions

View File

@ -901,7 +901,7 @@ class CallActivity : CallBaseActivity() {
if (cameraEnumerator!!.deviceNames.size < 2) {
binding!!.switchSelfVideoButton.visibility = View.GONE
}
initSelfVideoView()
initSelfVideoViewForNormalMode()
}
binding!!.gridview.setOnTouchListener { _, me ->
val action = me.actionMasked
@ -924,7 +924,7 @@ class CallActivity : CallBaseActivity() {
}
@SuppressLint("ClickableViewAccessibility")
private fun initSelfVideoView() {
private fun initSelfVideoViewForNormalMode() {
try {
binding!!.selfVideoRenderer.init(rootEglBase!!.eglBaseContext, null)
} catch (e: IllegalStateException) {
@ -937,6 +937,20 @@ class CallActivity : CallBaseActivity() {
binding!!.selfVideoRenderer.setOnTouchListener(SelfVideoTouchListener())
}
private fun initSelfVideoViewForPipMode() {
try {
binding!!.pipSelfVideoRenderer.init(rootEglBase!!.eglBaseContext, null)
} catch (e: IllegalStateException) {
Log.d(TAG, "pipGroupVideoRenderer already initialized", e)
}
binding!!.pipSelfVideoRenderer.setZOrderMediaOverlay(true)
// disabled because it causes some devices to crash
binding!!.pipSelfVideoRenderer.setEnableHardwareScaler(false)
binding!!.pipSelfVideoRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT)
localVideoTrack!!.addSink(binding!!.pipSelfVideoRenderer)
}
private fun initGridAdapter() {
Log.d(TAG, "initGridAdapter")
val columns: Int
@ -1353,8 +1367,18 @@ class CallActivity : CallBaseActivity() {
}
if (enable) {
binding!!.selfVideoRenderer.visibility = View.VISIBLE
binding!!.pipSelfVideoRenderer.visibility = View.VISIBLE
initSelfVideoViewForNormalMode()
} else {
binding!!.selfVideoRenderer.visibility = View.INVISIBLE
binding!!.pipSelfVideoRenderer.visibility = View.INVISIBLE
binding!!.selfVideoRenderer.clearImage()
binding!!.selfVideoRenderer.release()
binding!!.pipSelfVideoRenderer.clearImage()
binding!!.pipSelfVideoRenderer.release()
}
} else {
if (enable) {
@ -3211,17 +3235,21 @@ class CallActivity : CallBaseActivity() {
binding!!.callInfosLinearLayout.visibility = View.GONE
binding!!.selfVideoViewWrapper.visibility = View.GONE
binding!!.callStates.callStateRelativeLayout.visibility = View.GONE
binding!!.selfVideoRenderer.release()
if (participantDisplayItems!!.size > 1) {
binding!!.pipCallConversationNameTextView.text = conversationName
binding!!.pipGroupCallOverlay.visibility = View.VISIBLE
binding!!.pipSelfVideoOverlay.visibility = View.VISIBLE
initSelfVideoViewForPipMode()
} else {
binding!!.pipGroupCallOverlay.visibility = View.GONE
binding!!.pipSelfVideoOverlay.visibility = View.GONE
}
binding!!.selfVideoRenderer.release()
}
override fun updateUiForNormalMode() {
Log.d(TAG, "updateUiForNormalMode")
binding!!.pipSelfVideoOverlay.visibility = View.GONE
if (isVoiceOnlyCall) {
binding!!.callControls.visibility = View.VISIBLE
} else {
@ -3231,7 +3259,6 @@ class CallActivity : CallBaseActivity() {
initViews()
binding!!.callInfosLinearLayout.visibility = View.VISIBLE
binding!!.selfVideoViewWrapper.visibility = View.VISIBLE
binding!!.pipGroupCallOverlay.visibility = View.GONE
}
override fun suppressFitsSystemWindows() {

View File

@ -182,9 +182,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="50dp"
android:layout_marginBottom="50dp">
</RelativeLayout>
android:layout_marginBottom="50dp"/>
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/flexboxLayout"
@ -228,8 +226,6 @@
</com.google.android.flexbox.FlexboxLayout>
</RelativeLayout>
<com.google.android.flexbox.FlexboxLayout
@ -330,8 +326,8 @@
</com.google.android.flexbox.FlexboxLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/pipGroupCallOverlay"
<RelativeLayout
android:id="@+id/pipSelfVideoOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
@ -341,12 +337,13 @@
<TextView
android:id="@+id/pipCallConversationNameTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginStart="5dp"
android:layout_marginTop="-30dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="15dp"
android:layout_marginBottom="-30dp"
android:ellipsize="end"
android:maxLines="3"
android:textAlignment="center"
@ -357,9 +354,18 @@
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerInParent="true"
app:srcCompat="@drawable/ic_circular_group"
tools:ignore="ContentDescription" />
</LinearLayout>
<org.webrtc.SurfaceViewRenderer
android:id="@+id/pipSelfVideoRenderer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:clickable="false"
tools:visibility="gone" />
</RelativeLayout>
</RelativeLayout>