diff --git a/CHANGES.md b/CHANGES.md index 9d1ba6ce07..036bec8537 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Features ✨: Improvements 🙌: - Fetch homeserver type and version and display in a new setting screen and add info in rageshakes (#2831) - Improve initial sync performance (#983) + - PIP support for Jitsi call (#2418) Bugfix 🐛: - diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml index 52932920d4..bb56c4532e 100644 --- a/vector/src/main/AndroidManifest.xml +++ b/vector/src/main/AndroidManifest.xml @@ -37,7 +37,7 @@ tools:node="remove" /> - + @@ -83,8 +83,7 @@ android:resource="@xml/shortcuts" /> - + - + + android:configChanges="orientation|smallestScreenSize|screenLayout|screenSize" + android:resizeableActivity="true" + android:supportsPictureInPicture="true" /> @@ -247,27 +249,28 @@ - + - - + + - - + + - - - - + + + + - + jitsiMeetPropertiesFactory.create(url) } setState { - copy( - widget = Success(jitsiWidget), - jitsiUrl = "https://${ppt?.domain}", - confId = ppt?.confId ?: "", - subject = roomName ?: "" - ) + copy(widget = Success(jitsiWidget)) + } + + if (!confIsStarted) { + confIsStarted = true + startConference(jitsiWidget) } } else { setState { @@ -87,6 +77,26 @@ class JitsiCallViewModel @AssistedInject constructor( .disposeOnClear() } + private fun startConference(jitsiWidget: Widget) { + val me = session.getRoomMember(session.myUserId, args.roomId)?.toMatrixItem() + val userInfo = JitsiMeetUserInfo().apply { + displayName = me?.getBestName() + avatar = me?.avatarUrl?.let { session.contentUrlResolver().resolveFullSize(it) }?.let { URL(it) } + } + val roomName = session.getRoomSummary(args.roomId)?.displayName + + val ppt = widgetService.getWidgetComputedUrl(jitsiWidget, themeProvider.isLightTheme()) + ?.let { url -> jitsiMeetPropertiesFactory.create(url) } + + _viewEvents.post(JitsiCallViewEvents.StartConference( + enableVideo = args.enableVideo, + jitsiUrl = "https://${ppt?.domain}", + subject = roomName ?: "", + confId = ppt?.confId ?: "", + userInfo = userInfo + )) + } + override fun handle(action: JitsiCallViewActions) { } @@ -106,8 +116,7 @@ class JitsiCallViewModel @AssistedInject constructor( return JitsiCallViewState( roomId = args.roomId, - widgetId = args.widgetId, - enableVideo = args.enableVideo + widgetId = args.widgetId ) } } diff --git a/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewState.kt b/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewState.kt index 72b87e7f1b..fe327f5867 100644 --- a/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewState.kt +++ b/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewState.kt @@ -19,16 +19,10 @@ package im.vector.app.features.call.conference import com.airbnb.mvrx.Async import com.airbnb.mvrx.MvRxState import com.airbnb.mvrx.Uninitialized -import org.jitsi.meet.sdk.JitsiMeetUserInfo import org.matrix.android.sdk.api.session.widgets.model.Widget data class JitsiCallViewState( val roomId: String = "", val widgetId: String = "", - val enableVideo: Boolean = true, - val jitsiUrl: String = "", - val subject: String = "", - val confId: String = "", - val userInfo: JitsiMeetUserInfo = JitsiMeetUserInfo(), val widget: Async = Uninitialized ) : MvRxState diff --git a/vector/src/main/java/im/vector/app/features/call/conference/VectorJitsiActivity.kt b/vector/src/main/java/im/vector/app/features/call/conference/VectorJitsiActivity.kt index caece858aa..7fe2c2da0b 100644 --- a/vector/src/main/java/im/vector/app/features/call/conference/VectorJitsiActivity.kt +++ b/vector/src/main/java/im/vector/app/features/call/conference/VectorJitsiActivity.kt @@ -80,6 +80,12 @@ class VectorJitsiActivity : VectorBaseActivity(), JitsiMee renderState(it) } + jitsiViewModel.observeViewEvents { + when(it) { + is JitsiCallViewEvents.StartConference -> configureJitsiView(it) + } + } + registerForBroadcastMessages() } @@ -96,7 +102,6 @@ class VectorJitsiActivity : VectorBaseActivity(), JitsiMee is Success -> { views.jitsiProgressLayout.isVisible = false jitsiMeetView?.isVisible = true - configureJitsiView(viewState) } else -> { jitsiMeetView?.isVisible = false @@ -105,12 +110,12 @@ class VectorJitsiActivity : VectorBaseActivity(), JitsiMee } } - private fun configureJitsiView(viewState: JitsiCallViewState) { + private fun configureJitsiView(startConference: JitsiCallViewEvents.StartConference) { val jitsiMeetConferenceOptions = JitsiMeetConferenceOptions.Builder() - .setVideoMuted(!viewState.enableVideo) - .setUserInfo(viewState.userInfo) + .setVideoMuted(!startConference.enableVideo) + .setUserInfo(startConference.userInfo) .apply { - tryOrNull { URL(viewState.jitsiUrl) }?.let { + tryOrNull { URL(startConference.jitsiUrl) }?.let { setServerURL(it) } } @@ -120,8 +125,8 @@ class VectorJitsiActivity : VectorBaseActivity(), JitsiMee .setFeatureFlag("add-people.enabled", false) .setFeatureFlag("video-share.enabled", false) .setFeatureFlag("call-integration.enabled", false) - .setRoom(viewState.confId) - .setSubject(viewState.subject) + .setRoom(startConference.confId) + .setSubject(startConference.subject) .build() jitsiMeetView?.join(jitsiMeetConferenceOptions) } @@ -147,10 +152,10 @@ class VectorJitsiActivity : VectorBaseActivity(), JitsiMee super.onDestroy() } -// override fun onUserLeaveHint() { -// super.onUserLeaveHint() -// jitsiMeetView?.enterPictureInPicture() -// } + override fun onUserLeaveHint() { + super.onUserLeaveHint() + jitsiMeetView?.enterPictureInPicture() + } override fun onNewIntent(intent: Intent?) { JitsiMeetActivityDelegate.onNewIntent(intent)