Fixed disable video button even in call + audio route switching from bluetooth to speaker when video was enabled

This commit is contained in:
Sylvain Berfini 2024-01-18 17:17:31 +01:00
parent 8aa17ed097
commit 570492cea9
9 changed files with 88 additions and 12 deletions

View file

@ -233,7 +233,11 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
} else {
val videoEnabled = call.currentParams.isVideoEnabled
if (videoEnabled && isVideoEnabled.value == false) {
if (corePreferences.routeAudioToSpeakerWhenVideoIsEnabled) {
if (isBluetoothEnabled.value == true || isHeadsetEnabled.value == true) {
Log.i(
"$TAG Audio is routed to bluetooth or headset, do not change it to speaker because video was enabled"
)
} else if (corePreferences.routeAudioToSpeakerWhenVideoIsEnabled) {
Log.i("$TAG Video is now enabled, routing audio to speaker")
AudioUtils.routeAudioToSpeaker(call)
}

View file

@ -37,7 +37,6 @@
android:layout_height="@dimen/call_main_actions_menu_height"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
bind:showExpandToggle="@{true}"
bind:viewModel="@{viewModel}" />
<ImageView

View file

@ -34,7 +34,6 @@
android:layout_height="@dimen/call_main_actions_menu_height"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
bind:showExpandToggle="@{true}"
bind:viewModel="@{viewModel}" />
<ImageView

View file

@ -7,9 +7,6 @@
<variable
name="viewModel"
type="org.linphone.ui.call.viewmodel.CurrentCallViewModel" />
<variable
name="showExpandToggle"
type="Boolean" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
@ -20,7 +17,6 @@
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
android:onClick="@{() -> viewModel.toggleExpandActionsMenu()}"
android:visibility="@{showExpandToggle ? View.VISIBLE : View.INVISIBLE}"
android:id="@+id/toggle_expand"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -54,7 +50,7 @@
android:layout_height="@dimen/call_button_size"
android:layout_marginEnd="16dp"
android:padding="@dimen/call_button_icon_padding"
android:enabled="@{!viewModel.isOutgoing &amp;&amp; !viewModel.isPaused &amp;&amp; !viewModel.isPausedByRemote}"
android:enabled="@{!viewModel.isPaused &amp;&amp; !viewModel.isPausedByRemote}"
android:visibility="@{viewModel.hideVideo ? View.GONE : View.VISIBLE}"
android:src="@{viewModel.isVideoEnabled ? @drawable/video_camera : @drawable/video_camera_slash, default=@drawable/video_camera}"
android:background="@drawable/in_call_button_background_red"

View file

@ -34,7 +34,6 @@
android:layout_height="@dimen/call_main_actions_menu_height"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
bind:showExpandToggle="@{true}"
bind:viewModel="@{viewModel}" />
<ImageView

View file

@ -135,7 +135,7 @@
<include
bind:viewModel="@{viewModel}"
android:id="@+id/bottom_bar"
layout="@layout/call_incoming_bottom_bar"
layout="@layout/call_incoming_actions"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"

View file

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="org.linphone.ui.call.viewmodel.CurrentCallViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="@dimen/call_main_actions_menu_height"
android:paddingBottom="5dp"
android:background="@drawable/shape_call_bottom_sheet_background">
<ImageView
android:onClick="@{() -> viewModel.hangUp()}"
android:id="@+id/hang_up"
android:layout_width="wrap_content"
android:layout_height="@dimen/call_button_size"
android:layout_marginStart="16dp"
android:paddingStart="30dp"
android:paddingEnd="30dp"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:src="@drawable/phone_disconnect"
android:background="@drawable/squircle_red_button_background"
app:tint="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<ImageView
android:id="@+id/toggle_video"
android:layout_width="@dimen/call_button_size"
android:layout_height="@dimen/call_button_size"
android:layout_marginEnd="16dp"
android:padding="@dimen/call_button_icon_padding"
android:visibility="@{viewModel.hideVideo ? View.GONE : View.VISIBLE}"
android:src="@{viewModel.isVideoEnabled ? @drawable/video_camera : @drawable/video_camera_slash, default=@drawable/video_camera}"
android:background="@drawable/shape_round_in_call_disabled_button_background"
app:tint="@color/gray_500"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/hang_up"
app:layout_constraintEnd_toStartOf="@id/toggle_mute_mic" />
<ImageView
android:onClick="@{() -> viewModel.toggleMuteMicrophone()}"
android:id="@+id/toggle_mute_mic"
android:layout_width="@dimen/call_button_size"
android:layout_height="@dimen/call_button_size"
android:layout_marginEnd="16dp"
android:padding="@dimen/call_button_icon_padding"
android:src="@{viewModel.isMicrophoneMuted ? @drawable/microphone_slash : @drawable/microphone, default=@drawable/microphone}"
android:background="@drawable/in_call_button_background_red"
app:tint="@color/in_call_button_tint_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/toggle_video"
app:layout_constraintEnd_toStartOf="@id/change_audio_output" />
<ImageView
android:onClick="@{() -> viewModel.changeAudioOutputDevice()}"
android:id="@+id/change_audio_output"
android:layout_width="@dimen/call_button_size"
android:layout_height="@dimen/call_button_size"
android:layout_marginEnd="16dp"
android:padding="@dimen/call_button_icon_padding"
android:src="@{viewModel.isHeadsetEnabled ? @drawable/headset : viewModel.isBluetoothEnabled ? @drawable/bluetooth : viewModel.isSpeakerEnabled ? @drawable/speaker_high : @drawable/speaker_slash, default=@drawable/speaker_slash}"
android:background="@drawable/in_call_button_background_red"
app:tint="@color/in_call_button_tint_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/toggle_mute_mic"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -147,9 +147,8 @@
<include
bind:viewModel="@{viewModel}"
bind:showExpandToggle="@{false}"
android:id="@+id/bottom_bar"
layout="@layout/call_common_actions"
layout="@layout/call_outgoing_actions"
android:layout_width="0dp"
android:layout_height="@dimen/call_main_actions_menu_height"
app:layout_constraintStart_toStartOf="parent"