mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Try to enter PiP mode when leaving CallActivity during a video call, either by back gesture or button, and remove PiP when call is ended
This commit is contained in:
parent
6b7591c971
commit
17e3622bdc
5 changed files with 39 additions and 5 deletions
|
|
@ -46,6 +46,7 @@ class Api31Compatibility {
|
|||
.setAutoEnterEnabled(enable)
|
||||
.build()
|
||||
)
|
||||
Log.i("$TAG PiP auto enter has been [${if (enable) "enabled" else "disabled"}]")
|
||||
} catch (ise: IllegalArgumentException) {
|
||||
Log.e("$TAG Can't set PiP params: $ise")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ import kotlinx.coroutines.launch
|
|||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.R
|
||||
import org.linphone.compatibility.Api28Compatibility
|
||||
import org.linphone.compatibility.Compatibility
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.CallActivityBinding
|
||||
|
|
@ -64,6 +65,7 @@ import org.linphone.ui.call.model.AudioDeviceModel
|
|||
import org.linphone.ui.call.viewmodel.CallsViewModel
|
||||
import org.linphone.ui.call.viewmodel.CurrentCallViewModel
|
||||
import org.linphone.ui.call.viewmodel.SharedCallViewModel
|
||||
import org.linphone.ui.main.MainActivity
|
||||
|
||||
@UiThread
|
||||
class CallActivity : GenericActivity() {
|
||||
|
|
@ -376,7 +378,7 @@ class CallActivity : GenericActivity() {
|
|||
|
||||
if (::callViewModel.isInitialized) {
|
||||
if (isPipSupported && callViewModel.isVideoEnabled.value == true) {
|
||||
Log.i("$TAG User leave hint, entering PiP mode")
|
||||
Log.i("$TAG User leave hint, try entering PiP mode")
|
||||
val pipMode = Compatibility.enterPipMode(this)
|
||||
if (!pipMode) {
|
||||
Log.e("$TAG Failed to enter PiP mode")
|
||||
|
|
@ -386,6 +388,28 @@ class CallActivity : GenericActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun goToMainActivity() {
|
||||
if (isPipSupported && callViewModel.isVideoEnabled.value == true) {
|
||||
Log.i("$TAG User is going back to MainActivity, try entering PiP mode")
|
||||
val pipMode = Api28Compatibility.enterPipMode(this)
|
||||
if (!pipMode) {
|
||||
Log.e("$TAG Failed to enter PiP mode, finishing Activity")
|
||||
callViewModel.pipMode.value = false
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
Log.i("$TAG Launching MainActivity to have PiP above it")
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
||||
startActivity(intent)
|
||||
} else {
|
||||
Log.i("$TAG Either PiP isn't supported or video is not enabled, finishing Activity")
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateCurrentLayout(newLayoutInfo: WindowLayoutInfo) {
|
||||
if (newLayoutInfo.displayFeatures.isNotEmpty()) {
|
||||
for (feature in newLayoutInfo.displayFeatures) {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import org.linphone.LinphoneApplication.Companion.coreContext
|
|||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.CallActiveConferenceFragmentBinding
|
||||
import org.linphone.ui.call.CallActivity
|
||||
import org.linphone.ui.call.fragment.GenericCallFragment
|
||||
import org.linphone.ui.call.viewmodel.CallsViewModel
|
||||
import org.linphone.ui.call.viewmodel.CurrentCallViewModel
|
||||
|
|
@ -129,7 +130,8 @@ class ActiveConferenceCallFragment : GenericCallFragment() {
|
|||
Log.i("$TAG Back gesture/click detected, no bottom sheet is expanded, going back")
|
||||
isEnabled = false
|
||||
try {
|
||||
requireActivity().onBackPressedDispatcher.onBackPressed()
|
||||
Log.i("$TAG Back gesture detected, going to MainActivity")
|
||||
(requireActivity() as CallActivity).goToMainActivity()
|
||||
} catch (ise: IllegalStateException) {
|
||||
Log.w("$TAG Can't go back: $ise")
|
||||
}
|
||||
|
|
@ -279,7 +281,7 @@ class ActiveConferenceCallFragment : GenericCallFragment() {
|
|||
}
|
||||
|
||||
binding.setBackClickListener {
|
||||
requireActivity().finish()
|
||||
(requireActivity() as CallActivity).goToMainActivity()
|
||||
}
|
||||
|
||||
binding.setCallsListClickListener {
|
||||
|
|
|
|||
|
|
@ -145,7 +145,8 @@ class ActiveCallFragment : GenericCallFragment() {
|
|||
Log.i("$TAG Back gesture/click detected, no bottom sheet is expanded, going back")
|
||||
isEnabled = false
|
||||
try {
|
||||
requireActivity().onBackPressedDispatcher.onBackPressed()
|
||||
Log.i("$TAG Back gesture detected, going to MainActivity")
|
||||
(requireActivity() as CallActivity).goToMainActivity()
|
||||
} catch (ise: IllegalStateException) {
|
||||
Log.w(
|
||||
"$TAG Can't go back: $ise"
|
||||
|
|
@ -210,7 +211,7 @@ class ActiveCallFragment : GenericCallFragment() {
|
|||
callMediaEncryptionStatsBottomSheetBehavior.skipCollapsed = true
|
||||
|
||||
binding.setBackClickListener {
|
||||
requireActivity().finish()
|
||||
(requireActivity() as CallActivity).goToMainActivity()
|
||||
}
|
||||
|
||||
binding.setTransferCallClickListener {
|
||||
|
|
|
|||
|
|
@ -1427,6 +1427,12 @@ class CurrentCallViewModel
|
|||
finishActivityEvent.postValue(Event(true))
|
||||
}
|
||||
else -> {
|
||||
if (pipMode.value == true) {
|
||||
Log.i("$TAG Activity currently displayed in PiP, do not go to ended call fragment")
|
||||
finishActivityEvent.postValue(Event(true))
|
||||
return
|
||||
}
|
||||
|
||||
Log.i("$TAG Go to ended call fragment")
|
||||
updateCallDuration()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue