mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 18:05:36 +03:00
Fix issue with Back button not working when conference is not joined yet.
This commit is contained in:
parent
1b5852fbcb
commit
6b34bb2086
2 changed files with 44 additions and 1 deletions
|
@ -24,6 +24,7 @@ import androidx.lifecycle.DefaultLifecycleObserver
|
|||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.facebook.react.bridge.JavaOnlyMap
|
||||
import im.vector.app.config.Config
|
||||
import org.jitsi.meet.sdk.BroadcastEmitter
|
||||
import org.jitsi.meet.sdk.BroadcastEvent
|
||||
import org.jitsi.meet.sdk.JitsiMeet
|
||||
|
@ -35,6 +36,7 @@ sealed class ConferenceEvent(open val data: Map<String, Any>) {
|
|||
data class Terminated(override val data: Map<String, Any>) : ConferenceEvent(data)
|
||||
data class WillJoin(override val data: Map<String, Any>) : ConferenceEvent(data)
|
||||
data class Joined(override val data: Map<String, Any>) : ConferenceEvent(data)
|
||||
object ReadyToClose : ConferenceEvent(emptyMap())
|
||||
|
||||
fun extractConferenceUrl(): String? {
|
||||
return data[CONFERENCE_URL_DATA_KEY] as? String
|
||||
|
@ -84,14 +86,24 @@ class ConferenceEventObserver(
|
|||
|
||||
private fun onBroadcastReceived(intent: Intent) {
|
||||
val event = BroadcastEvent(intent)
|
||||
safeLog("onBroadcastReceived: Event received (type ${event.type})", event.data)
|
||||
val conferenceEvent = when (event.type) {
|
||||
BroadcastEvent.Type.CONFERENCE_JOINED -> ConferenceEvent.Joined(event.data)
|
||||
BroadcastEvent.Type.CONFERENCE_TERMINATED -> ConferenceEvent.Terminated(event.data)
|
||||
BroadcastEvent.Type.CONFERENCE_WILL_JOIN -> ConferenceEvent.WillJoin(event.data)
|
||||
BroadcastEvent.Type.READY_TO_CLOSE -> ConferenceEvent.ReadyToClose
|
||||
else -> null
|
||||
}
|
||||
if (conferenceEvent != null) {
|
||||
onBroadcastEvent(conferenceEvent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun safeLog(message: String, sensitiveData: Any?) {
|
||||
if (Config.LOW_PRIVACY_LOG_ENABLE) {
|
||||
Timber.v("$message: $sensitiveData")
|
||||
} else {
|
||||
Timber.v(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package im.vector.app.features.call.conference
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Configuration
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
|
@ -46,6 +47,7 @@ import org.jitsi.meet.sdk.JitsiMeet
|
|||
import org.jitsi.meet.sdk.JitsiMeetActivityDelegate
|
||||
import org.jitsi.meet.sdk.JitsiMeetActivityInterface
|
||||
import org.jitsi.meet.sdk.JitsiMeetConferenceOptions
|
||||
import org.jitsi.meet.sdk.JitsiMeetOngoingConferenceService
|
||||
import org.jitsi.meet.sdk.JitsiMeetView
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.util.JsonDict
|
||||
|
@ -68,6 +70,13 @@ class VectorJitsiActivity : VectorBaseActivity<ActivityJitsiBinding>(), JitsiMee
|
|||
|
||||
private val jitsiViewModel: JitsiCallViewModel by viewModel()
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
val intent = Intent("onConfigurationChanged")
|
||||
intent.putExtra("newConfig", newConfig)
|
||||
this.sendBroadcast(intent)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
addOnPictureInPictureModeChangedListener(pictureInPictureModeChangedInfoConsumer)
|
||||
|
@ -107,16 +116,26 @@ class VectorJitsiActivity : VectorBaseActivity<ActivityJitsiBinding>(), JitsiMee
|
|||
|
||||
override fun onDestroy() {
|
||||
val currentConf = JitsiMeet.getCurrentConference()
|
||||
handleLeaveConference()
|
||||
jitsiMeetView?.dispose()
|
||||
// Fake emitting CONFERENCE_TERMINATED event when currentConf is not null (probably when closing the PiP screen).
|
||||
if (currentConf != null) {
|
||||
ConferenceEventEmitter(this).emitConferenceEnded()
|
||||
}
|
||||
JitsiMeetOngoingConferenceService.abort(this)
|
||||
JitsiMeetActivityDelegate.onHostDestroy(this)
|
||||
removeOnPictureInPictureModeChangedListener(pictureInPictureModeChangedInfoConsumer)
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
// Activity lifecycle methods
|
||||
//
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
@Suppress("DEPRECATION")
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
JitsiMeetActivityDelegate.onActivityResult(this, requestCode, resultCode, data)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
JitsiMeetActivityDelegate.onBackPressed()
|
||||
}
|
||||
|
@ -224,10 +243,17 @@ class VectorJitsiActivity : VectorBaseActivity<ActivityJitsiBinding>(), JitsiMee
|
|||
Timber.v("Broadcast received: $event")
|
||||
when (event) {
|
||||
is ConferenceEvent.Terminated -> onConferenceTerminated(event.data)
|
||||
else -> Unit
|
||||
is ConferenceEvent.Joined -> onConferenceJoined(event.data)
|
||||
is ConferenceEvent.ReadyToClose -> onReadyToClose()
|
||||
is ConferenceEvent.WillJoin -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
private fun onConferenceJoined(extraData: Map<String, Any>) {
|
||||
// Launch the service for the ongoing notification.
|
||||
JitsiMeetOngoingConferenceService.launch(this, HashMap(extraData))
|
||||
}
|
||||
|
||||
private fun onConferenceTerminated(data: JsonDict) {
|
||||
Timber.v("JitsiMeetViewListener.onConferenceTerminated()")
|
||||
// Do not finish if there is an error
|
||||
|
@ -236,6 +262,11 @@ class VectorJitsiActivity : VectorBaseActivity<ActivityJitsiBinding>(), JitsiMee
|
|||
}
|
||||
}
|
||||
|
||||
private fun onReadyToClose() {
|
||||
Timber.v("SDK is ready to close")
|
||||
finish()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newIntent(context: Context, roomId: String, widgetId: String, enableVideo: Boolean): Intent {
|
||||
return Intent(context, VectorJitsiActivity::class.java).apply {
|
||||
|
|
Loading…
Reference in a new issue