Added back video preview on call activity while in PiP mode + added setting to keep previous behavior even if not recommended

This commit is contained in:
Sylvain Berfini 2020-09-28 16:38:47 +02:00
parent f88054f138
commit b4a5d9bf44
7 changed files with 26 additions and 3 deletions

View file

@ -102,6 +102,7 @@
<activity android:name=".activities.call.CallActivity"
android:launchMode="singleTop"
android:resizeableActivity="true"
android:supportsPictureInPicture="true" />
<activity android:name=".activities.call.IncomingCallActivity"

View file

@ -26,6 +26,7 @@ import android.view.MotionEvent
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.LinphoneApplication.Companion.corePreferences
import org.linphone.R
import org.linphone.activities.call.viewmodels.ControlsFadingViewModel
import org.linphone.activities.call.viewmodels.SharedCallViewModel
@ -134,6 +135,11 @@ class CallActivity : ProximitySensorActivity() {
if (isInPictureInPictureMode) {
viewModel.areControlsHidden.value = true
}
viewModel.isVideoPreviewHidden.value = isInPictureInPictureMode
if (corePreferences.hideCameraPreviewInPipMode) {
viewModel.isVideoPreviewHidden.value = isInPictureInPictureMode
} else {
viewModel.isVideoPreviewResizedForPip.value = isInPictureInPictureMode
}
}
}

View file

@ -38,6 +38,7 @@ class ControlsFadingViewModel : ViewModel() {
val areControlsHidden = MutableLiveData<Boolean>()
val isVideoPreviewHidden = MutableLiveData<Boolean>()
val isVideoPreviewResizedForPip = MutableLiveData<Boolean>()
private val videoEnabled = MutableLiveData<Boolean>()
private val nonEarpieceOutputAudioDevice = MutableLiveData<Boolean>()
@ -78,6 +79,7 @@ class ControlsFadingViewModel : ViewModel() {
areControlsHidden.value = false
isVideoPreviewHidden.value = false
isVideoPreviewResizedForPip.value = false
nonEarpieceOutputAudioDevice.value = coreContext.core.outputAudioDevice?.type != AudioDevice.Type.Earpiece
val isVideoCall = coreContext.isVideoCallOrConferenceActive()

View file

@ -235,7 +235,7 @@ class CorePreferences constructor(private val context: Context) {
config.setInt("app", "version_check_url_last_timestamp", value)
}
/* Read only application settings previously in non_localizable_custom */
/* Read only application settings, some were previously in non_localizable_custom */
val defaultDomain: String
get() = config.getString("app", "default_domain", "sip.linphone.org")!!
@ -279,6 +279,11 @@ class CorePreferences constructor(private val context: Context) {
val showIncomingChatMessagesDeliveryStatus: Boolean
get() = config.getBool("app", "show_incoming_messages_delivery_status", false)
// If enabled, this will cause the video to "freeze" on your correspondent screen
// as you won't send video packets anymore
val hideCameraPreviewInPipMode: Boolean
get() = config.getBool("app", "hide_camera_preview_in_pip_mode", false)
/* Tabs */
val showHistory: Boolean

View file

@ -81,6 +81,12 @@ fun View.setLayoutHeight(dimension: Float) {
this.layoutParams.height = dimension.toInt()
}
@BindingAdapter("android:layout_size")
fun View.setLayoutSize(dimension: Float) {
this.layoutParams.height = dimension.toInt()
this.layoutParams.width = dimension.toInt()
}
@BindingAdapter("android:background")
fun LinearLayout.setBackground(resource: Int) {
this.setBackgroundResource(resource)

View file

@ -30,8 +30,9 @@
<org.linphone.mediastream.video.capture.CaptureTextureView
android:onTouch="@{previewTouchListener}"
android:visibility="@{viewModel.isVideoPreviewHidden ? View.INVISIBLE : View.VISIBLE}"
android:visibility="@{viewModel.isVideoPreviewHidden ? View.INVISIBLE : View.VISIBLE, default=visible}"
android:id="@+id/local_preview_video_surface"
android:layout_size="@{viewModel.isVideoPreviewResizedForPip ? @dimen/video_preview_pip_max_size : @dimen/video_preview_max_size}"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignParentRight="true"

View file

@ -5,4 +5,6 @@
<dimen name="outgoing_chat_message_bubble_left_margin">45dp</dimen>
<dimen name="chat_message_bubble_image_height_big">200dp</dimen>
<dimen name="chat_message_bubble_image_height_small">100dp</dimen>
<dimen name="video_preview_max_size">200dp</dimen>
<dimen name="video_preview_pip_max_size">50dp</dimen>
</resources>