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) { if (cameraEnumerator!!.deviceNames.size < 2) {
binding!!.switchSelfVideoButton.visibility = View.GONE binding!!.switchSelfVideoButton.visibility = View.GONE
} }
initSelfVideoView() initSelfVideoViewForNormalMode()
} }
binding!!.gridview.setOnTouchListener { _, me -> binding!!.gridview.setOnTouchListener { _, me ->
val action = me.actionMasked val action = me.actionMasked
@ -924,7 +924,7 @@ class CallActivity : CallBaseActivity() {
} }
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
private fun initSelfVideoView() { private fun initSelfVideoViewForNormalMode() {
try { try {
binding!!.selfVideoRenderer.init(rootEglBase!!.eglBaseContext, null) binding!!.selfVideoRenderer.init(rootEglBase!!.eglBaseContext, null)
} catch (e: IllegalStateException) { } catch (e: IllegalStateException) {
@ -937,6 +937,20 @@ class CallActivity : CallBaseActivity() {
binding!!.selfVideoRenderer.setOnTouchListener(SelfVideoTouchListener()) 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() { private fun initGridAdapter() {
Log.d(TAG, "initGridAdapter") Log.d(TAG, "initGridAdapter")
val columns: Int val columns: Int
@ -1353,8 +1367,18 @@ class CallActivity : CallBaseActivity() {
} }
if (enable) { if (enable) {
binding!!.selfVideoRenderer.visibility = View.VISIBLE binding!!.selfVideoRenderer.visibility = View.VISIBLE
binding!!.pipSelfVideoRenderer.visibility = View.VISIBLE
initSelfVideoViewForNormalMode()
} else { } else {
binding!!.selfVideoRenderer.visibility = View.INVISIBLE binding!!.selfVideoRenderer.visibility = View.INVISIBLE
binding!!.pipSelfVideoRenderer.visibility = View.INVISIBLE
binding!!.selfVideoRenderer.clearImage()
binding!!.selfVideoRenderer.release()
binding!!.pipSelfVideoRenderer.clearImage()
binding!!.pipSelfVideoRenderer.release()
} }
} else { } else {
if (enable) { if (enable) {
@ -3211,17 +3235,21 @@ class CallActivity : CallBaseActivity() {
binding!!.callInfosLinearLayout.visibility = View.GONE binding!!.callInfosLinearLayout.visibility = View.GONE
binding!!.selfVideoViewWrapper.visibility = View.GONE binding!!.selfVideoViewWrapper.visibility = View.GONE
binding!!.callStates.callStateRelativeLayout.visibility = View.GONE binding!!.callStates.callStateRelativeLayout.visibility = View.GONE
binding!!.selfVideoRenderer.release()
if (participantDisplayItems!!.size > 1) { if (participantDisplayItems!!.size > 1) {
binding!!.pipCallConversationNameTextView.text = conversationName binding!!.pipCallConversationNameTextView.text = conversationName
binding!!.pipGroupCallOverlay.visibility = View.VISIBLE binding!!.pipSelfVideoOverlay.visibility = View.VISIBLE
initSelfVideoViewForPipMode()
} else { } else {
binding!!.pipGroupCallOverlay.visibility = View.GONE binding!!.pipSelfVideoOverlay.visibility = View.GONE
} }
binding!!.selfVideoRenderer.release()
} }
override fun updateUiForNormalMode() { override fun updateUiForNormalMode() {
Log.d(TAG, "updateUiForNormalMode") Log.d(TAG, "updateUiForNormalMode")
binding!!.pipSelfVideoOverlay.visibility = View.GONE
if (isVoiceOnlyCall) { if (isVoiceOnlyCall) {
binding!!.callControls.visibility = View.VISIBLE binding!!.callControls.visibility = View.VISIBLE
} else { } else {
@ -3231,7 +3259,6 @@ class CallActivity : CallBaseActivity() {
initViews() initViews()
binding!!.callInfosLinearLayout.visibility = View.VISIBLE binding!!.callInfosLinearLayout.visibility = View.VISIBLE
binding!!.selfVideoViewWrapper.visibility = View.VISIBLE binding!!.selfVideoViewWrapper.visibility = View.VISIBLE
binding!!.pipGroupCallOverlay.visibility = View.GONE
} }
override fun suppressFitsSystemWindows() { override fun suppressFitsSystemWindows() {

View File

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