Hide switch camera button if less than 2 cameras
This commit is contained in:
parent
e53db5491a
commit
8e330ce664
8 changed files with 16 additions and 5 deletions
|
@ -41,7 +41,7 @@ class QrCodeViewModel : ViewModel() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
coreContext.core.addListener(listener)
|
coreContext.core.addListener(listener)
|
||||||
showSwitchCamera.value = coreContext.core.videoDevicesList.size > 1
|
showSwitchCamera.value = coreContext.showSwitchCameraButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
|
|
|
@ -44,6 +44,8 @@ class ControlsViewModel : ViewModel() {
|
||||||
|
|
||||||
val isVideoUpdateInProgress = MutableLiveData<Boolean>()
|
val isVideoUpdateInProgress = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
|
val showSwitchCamera = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
val isPauseEnabled = MutableLiveData<Boolean>()
|
val isPauseEnabled = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
val isRecording = MutableLiveData<Boolean>()
|
val isRecording = MutableLiveData<Boolean>()
|
||||||
|
@ -129,6 +131,7 @@ class ControlsViewModel : ViewModel() {
|
||||||
|
|
||||||
isRecording.value = currentCall?.isRecording
|
isRecording.value = currentCall?.isRecording
|
||||||
isVideoUpdateInProgress.value = false
|
isVideoUpdateInProgress.value = false
|
||||||
|
showSwitchCamera.value = coreContext.showSwitchCameraButton()
|
||||||
|
|
||||||
updateUI()
|
updateUI()
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ class DialerViewModel : ViewModel() {
|
||||||
|
|
||||||
val showPreview = MutableLiveData<Boolean>()
|
val showPreview = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
|
val showSwitchCamera = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
val onKeyClick: NumpadDigitListener = object : NumpadDigitListener {
|
val onKeyClick: NumpadDigitListener = object : NumpadDigitListener {
|
||||||
override fun handleClick(key: Char) {
|
override fun handleClick(key: Char) {
|
||||||
enteredUri.value += key.toString()
|
enteredUri.value += key.toString()
|
||||||
|
@ -73,6 +75,8 @@ class DialerViewModel : ViewModel() {
|
||||||
enteredUri.value = ""
|
enteredUri.value = ""
|
||||||
atLeastOneCall.value = coreContext.core.callsNb > 0
|
atLeastOneCall.value = coreContext.core.callsNb > 0
|
||||||
transferVisibility.value = false
|
transferVisibility.value = false
|
||||||
|
|
||||||
|
showSwitchCamera.value = coreContext.showSwitchCameraButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
|
|
|
@ -363,6 +363,10 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
call.update(null)
|
call.update(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showSwitchCameraButton(): Boolean {
|
||||||
|
return core.videoDevicesList.orEmpty().size > 2 // Count StaticImage camera
|
||||||
|
}
|
||||||
|
|
||||||
fun createCallOverlay() {
|
fun createCallOverlay() {
|
||||||
if (!corePreferences.showCallOverlay || callOverlay != null) {
|
if (!corePreferences.showCallOverlay || callOverlay != null) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
<ImageView
|
<ImageView
|
||||||
android:onClick="@{() -> controlsViewModel.switchCamera()}"
|
android:onClick="@{() -> controlsViewModel.switchCamera()}"
|
||||||
android:enabled="@{!viewModel.callPausedByRemote}"
|
android:enabled="@{!viewModel.callPausedByRemote}"
|
||||||
android:visibility="@{controlsViewModel.isVideoEnabled ? View.VISIBLE : View.GONE, default=gone}"
|
android:visibility="@{controlsViewModel.isVideoEnabled && controlsViewModel.showSwitchCamera ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
android:contentDescription="@string/content_description_switch_camera"
|
android:contentDescription="@string/content_description_switch_camera"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:onClick="@{() -> viewModel.switchCamera()}"
|
android:onClick="@{() -> viewModel.switchCamera()}"
|
||||||
android:visibility="@{viewModel.showPreview ? View.VISIBLE : View.GONE, default=gone}"
|
android:visibility="@{viewModel.showPreview && viewModel.showSwitchCamera ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
android:contentDescription="@string/content_description_switch_camera"
|
android:contentDescription="@string/content_description_switch_camera"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:onClick="@{() -> viewModel.switchCamera()}"
|
android:onClick="@{() -> viewModel.switchCamera()}"
|
||||||
android:visibility="@{viewModel.showPreview ? View.VISIBLE : View.GONE, default=gone}"
|
android:visibility="@{viewModel.showPreview && viewModel.showSwitchCamera ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
android:contentDescription="@string/content_description_switch_camera"
|
android:contentDescription="@string/content_description_switch_camera"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
|
|
@ -208,7 +208,7 @@
|
||||||
<ImageView
|
<ImageView
|
||||||
android:onClick="@{() -> controlsViewModel.switchCamera()}"
|
android:onClick="@{() -> controlsViewModel.switchCamera()}"
|
||||||
android:enabled="@{!viewModel.callPausedByRemote}"
|
android:enabled="@{!viewModel.callPausedByRemote}"
|
||||||
android:visibility="@{controlsViewModel.isVideoEnabled ? View.VISIBLE : View.GONE, default=gone}"
|
android:visibility="@{controlsViewModel.isVideoEnabled && controlsViewModel.showSwitchCamera ? View.VISIBLE : View.GONE, default=gone}"
|
||||||
android:contentDescription="@string/content_description_switch_camera"
|
android:contentDescription="@string/content_description_switch_camera"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
|
|
Loading…
Reference in a new issue