mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Force front camera as default device when leaving QR code fragment
This commit is contained in:
parent
bf4b5a51f5
commit
7817e6603c
4 changed files with 40 additions and 24 deletions
|
|
@ -1269,4 +1269,26 @@ class CoreContext
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setBackCamera(): Boolean {
|
||||
for (camera in core.videoDevicesList) {
|
||||
if (camera.contains("Back")) {
|
||||
Log.i("TAG Found back facing camera [$camera], using it")
|
||||
coreContext.core.videoDevice = camera
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun setFrontCamera(): Boolean {
|
||||
for (camera in core.videoDevicesList) {
|
||||
if (camera.contains("Front")) {
|
||||
Log.i("$TAG Found front facing camera [$camera], using it")
|
||||
coreContext.core.videoDevice = camera
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,6 +147,8 @@ class QrCodeScannerFragment : GenericFragment() {
|
|||
core.nativePreviewWindowId = null
|
||||
core.isVideoPreviewEnabled = false
|
||||
core.isQrcodeVideoPreviewEnabled = false
|
||||
|
||||
coreContext.setFrontCamera()
|
||||
}
|
||||
|
||||
super.onPause()
|
||||
|
|
|
|||
|
|
@ -122,23 +122,17 @@ class QrCodeViewModel
|
|||
// this is required right after granting the CAMERA permission
|
||||
core.reloadVideoDevices()
|
||||
|
||||
for (camera in core.videoDevicesList) {
|
||||
if (camera.contains("Back")) {
|
||||
Log.i("$TAG Found back facing camera [$camera], using it")
|
||||
coreContext.core.videoDevice = camera
|
||||
return@postOnCoreThread
|
||||
if (!coreContext.setBackCamera()) {
|
||||
for (camera in core.videoDevicesList) {
|
||||
if (camera != "StaticImage: Static picture") {
|
||||
Log.w("$TAG No back facing camera found, using first one available [$camera]")
|
||||
coreContext.core.videoDevice = camera
|
||||
return@postOnCoreThread
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (camera in core.videoDevicesList) {
|
||||
if (camera != "StaticImage: Static picture") {
|
||||
Log.w("$TAG No back facing camera found, using first one available [$camera]")
|
||||
coreContext.core.videoDevice = camera
|
||||
return@postOnCoreThread
|
||||
}
|
||||
Log.e("$TAG No camera device found!")
|
||||
}
|
||||
|
||||
Log.e("$TAG No camera device found!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,18 +212,16 @@ class MeetingWaitingRoomViewModel
|
|||
@UiThread
|
||||
fun setFrontCamera() {
|
||||
coreContext.postOnCoreThread { core ->
|
||||
for (camera in core.videoDevicesList) {
|
||||
if (camera.contains("Front")) {
|
||||
Log.i("$TAG Found front facing camera [$camera], using it")
|
||||
coreContext.core.videoDevice = camera
|
||||
return@postOnCoreThread
|
||||
if (!coreContext.setFrontCamera()) {
|
||||
for (camera in core.videoDevicesList) {
|
||||
if (camera != "StaticImage: Static picture") {
|
||||
Log.w("$TAG No front facing camera found, using first one available [$camera]")
|
||||
coreContext.core.videoDevice = camera
|
||||
return@postOnCoreThread
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val first = core.videoDevicesList.firstOrNull()
|
||||
if (first != null) {
|
||||
Log.w("$TAG No front facing camera found, using first one available [$first]")
|
||||
coreContext.core.videoDevice = first
|
||||
Log.e("$TAG No camera device found!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue