Fixed pause/video buttons to be disabled until next call state update or UI pause/resume

This commit is contained in:
Sylvain Berfini 2021-04-09 15:28:25 +02:00
parent 42bb6b8635
commit cefb7ffd90
2 changed files with 16 additions and 5 deletions

View file

@ -26,7 +26,10 @@ import android.os.Vibrator
import android.view.animation.LinearInterpolator import android.view.animation.LinearInterpolator
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlin.math.max import kotlin.math.max
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.linphone.LinphoneApplication import org.linphone.LinphoneApplication
import org.linphone.LinphoneApplication.Companion.coreContext import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.LinphoneApplication.Companion.corePreferences import org.linphone.LinphoneApplication.Companion.corePreferences
@ -386,6 +389,11 @@ class ControlsViewModel : ViewModel() {
AudioRouteUtils.routeAudioToBluetooth() AudioRouteUtils.routeAudioToBluetooth()
} }
fun updateMuteMicState() {
isMicrophoneMuted.value = !PermissionHelper.get().hasRecordAudioPermission() || !coreContext.core.micEnabled()
isMuteMicrophoneEnabled.value = coreContext.core.currentCall != null || coreContext.core.isInConference
}
private fun updateAudioRelated() { private fun updateAudioRelated() {
updateSpeakerState() updateSpeakerState()
updateBluetoothHeadsetState() updateBluetoothHeadsetState()
@ -399,11 +407,14 @@ class ControlsViewModel : ViewModel() {
isPauseEnabled.value = currentCall != null && !currentCall.mediaInProgress() isPauseEnabled.value = currentCall != null && !currentCall.mediaInProgress()
isMuteMicrophoneEnabled.value = currentCall != null || coreContext.core.isInConference isMuteMicrophoneEnabled.value = currentCall != null || coreContext.core.isInConference
updateConferenceState() updateConferenceState()
}
fun updateMuteMicState() { // Check periodically until mediaInProgress is false
isMicrophoneMuted.value = !PermissionHelper.get().hasRecordAudioPermission() || !coreContext.core.micEnabled() if (currentCall != null && currentCall.mediaInProgress()) {
isMuteMicrophoneEnabled.value = coreContext.core.currentCall != null || coreContext.core.isInConference viewModelScope.launch {
delay(1000)
updateUI()
}
}
} }
private fun updateSpeakerState() { private fun updateSpeakerState() {

View file

@ -53,7 +53,7 @@
tools:layout="@layout/call_status_fragment" /> tools:layout="@layout/call_status_fragment" />
<androidx.fragment.app.FragmentContainerView <androidx.fragment.app.FragmentContainerView
android:id="@+id/call_fragment" android:id="@+id/call_controls_fragment"
android:name="org.linphone.activities.call.fragments.ControlsFragment" android:name="org.linphone.activities.call.fragments.ControlsFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"