Hide video related icons when feature disabled in core + prevent two seconds delay for outgoing call fragment to display info by starting it sooner (OutgoingInit instead of OutgoingProgress)

This commit is contained in:
Sylvain Berfini 2024-01-10 11:18:45 +01:00
parent 6ab9f4232b
commit 70e98dfe78
10 changed files with 38 additions and 18 deletions

View file

@ -149,7 +149,7 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
) {
Log.i("$TAG Call [${call.remoteAddress.asStringUriOnly()}] state changed [$state]")
when (state) {
Call.State.OutgoingProgress -> {
Call.State.OutgoingInit -> {
val conferenceInfo = core.findConferenceInformationFromUri(call.remoteAddress)
// Do not show outgoing call view for conference calls, wait for connected state
if (conferenceInfo == null) {
@ -163,8 +163,11 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
}
}
Call.State.Connected -> {
postOnMainThread {
showCallActivity()
val conferenceInfo = core.findConferenceInformationFromUri(call.remoteAddress)
if (conferenceInfo != null) {
postOnMainThread {
showCallActivity()
}
}
}
else -> {
@ -415,7 +418,7 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
@WorkerThread
fun showSwitchCameraButton(): Boolean {
return core.videoDevicesList.size > 2 // Count StaticImage camera
return core.isVideoCaptureEnabled && core.videoDevicesList.size > 2 // Count StaticImage camera
}
@WorkerThread

View file

@ -91,16 +91,16 @@ class CallActivity : GenericActivity() {
ViewModelProvider(this)[SharedCallViewModel::class.java]
}
callsViewModel = run {
ViewModelProvider(this)[CallsViewModel::class.java]
}
binding.callsViewModel = callsViewModel
callViewModel = run {
ViewModelProvider(this)[CurrentCallViewModel::class.java]
}
binding.callViewModel = callViewModel
callsViewModel = run {
ViewModelProvider(this)[CallsViewModel::class.java]
}
binding.callsViewModel = callsViewModel
callViewModel.showAudioDevicesListEvent.observe(this) {
it.consume { devices ->
showAudioRoutesMenu(devices)

View file

@ -99,6 +99,8 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
val isMediaEncrypted = MutableLiveData<Boolean>()
val hideVideo = MutableLiveData<Boolean>()
val incomingCallTitle: MutableLiveData<String> by lazy {
MutableLiveData<String>()
}
@ -372,12 +374,12 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
}
init {
isVideoEnabled.value = false
isMicrophoneMuted.value = false
fullScreenMode.value = false
coreContext.postOnCoreThread { core ->
core.addListener(coreListener)
hideVideo.postValue(!core.isVideoEnabled)
showSwitchCamera.postValue(coreContext.showSwitchCameraButton())
val call = core.currentCall ?: core.calls.firstOrNull()
if (call != null) {
@ -386,10 +388,12 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
} else {
Log.e("$TAG Failed to find call!")
}
showSwitchCamera.postValue(coreContext.showSwitchCameraButton())
}
isVideoEnabled.value = false
isMicrophoneMuted.value = false
fullScreenMode.value = false
numpadModel = NumpadModel(
{ digit -> // onDigitClicked
appendDigitToSearchBarEvent.value = Event(digit)
@ -771,6 +775,7 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
@WorkerThread
private fun configureCall(call: Call) {
Log.i("$TAG Configuring call [$call] as current")
contact.value?.destroy()
currentCall = call

View file

@ -54,6 +54,8 @@ class MeetingWaitingRoomViewModel @UiThread constructor() : ViewModel() {
val isSwitchCameraAvailable = MutableLiveData<Boolean>()
val hideVideo = MutableLiveData<Boolean>()
val conferenceInfoFoundEvent = MutableLiveData<Event<Boolean>>()
val conferenceCreatedEvent: MutableLiveData<Event<Boolean>> by lazy {
@ -78,6 +80,8 @@ class MeetingWaitingRoomViewModel @UiThread constructor() : ViewModel() {
init {
coreContext.postOnCoreThread { core ->
core.addListener(coreListener)
hideVideo.postValue(!core.isVideoEnabled)
}
}

View file

@ -91,7 +91,7 @@
android:textColor="?attr/color_main2_000"
android:textSize="13sp"
android:paddingBottom="2dp"
android:visibility="@{viewModel.unreadMessages > 0 ? View.VISIBLE : View.GONE}"
android:visibility="@{viewModel.unreadMessages > 0 &amp;&amp; !viewModel.hideConversations ? View.VISIBLE : View.GONE}"
app:layout_constraintTop_toTopOf="@id/conversations"
app:layout_constraintEnd_toEndOf="@id/conversations"/>

View file

@ -106,7 +106,7 @@
android:textColor="?attr/color_main2_000"
android:textSize="13sp"
android:paddingBottom="2dp"
android:visibility="@{viewModel.unreadMessages > 0 ? View.VISIBLE : View.GONE}"
android:visibility="@{viewModel.unreadMessages > 0 &amp;&amp; !viewModel.hideConversations ? View.VISIBLE : View.GONE}"
app:layout_constraintTop_toTopOf="@id/conversations"
app:layout_constraintStart_toStartOf="@id/conversations"
app:layout_constraintEnd_toEndOf="@id/conversations"/>

View file

@ -55,6 +55,7 @@
android:layout_marginEnd="16dp"
android:padding="@dimen/call_button_icon_padding"
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"
app:tint="@color/in_call_button_tint_color"

View file

@ -4,6 +4,9 @@
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="org.linphone.ui.call.viewmodel.CurrentCallViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
@ -36,6 +39,7 @@
android:enabled="false"
android:src="@drawable/video_camera_slash"
android:background="@drawable/shape_round_in_call_disabled_button_background"
android:visibility="@{viewModel.hideVideo ? View.GONE : View.VISIBLE}"
app:tint="?attr/color_grey_500"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintHorizontal_chainStyle="packed"

View file

@ -1,6 +1,7 @@
<?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">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
@ -178,6 +179,7 @@
<include
android:id="@+id/bottom_bar"
layout="@layout/call_ended_actions"
bind:viewModel="@{viewModel}"
android:layout_width="0dp"
android:layout_height="@dimen/call_main_actions_menu_height"
app:layout_constraintStart_toStartOf="parent"

View file

@ -128,6 +128,7 @@
android:layout_marginEnd="16dp"
android:padding="@dimen/call_button_icon_padding"
android:enabled="@{viewModel.isVideoAvailable}"
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"
app:tint="@color/in_call_button_tint_color"