From b5eab3668cf75782fc449adb2635b66df66d25c1 Mon Sep 17 00:00:00 2001 From: althafvly Date: Fri, 15 Sep 2023 14:43:54 +0530 Subject: [PATCH] camera: add support to ignore camera IDs --- .../net/sourceforge/opencamera/MainActivity.java | 12 ++++++++++++ app/src/main/res/values/config.xml | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index 7ae06d028..b163eb747 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -435,6 +435,11 @@ public class MainActivity extends AppCompatActivity { cameraIdentifier.init(); } + String[] ignoredCameraIDs = getResources().getStringArray(R.array.config_ignoredCameraIds); + if( MyDebug.LOG ) { + Log.d(TAG, "ignoredCameraIDs: " + Arrays.toString(ignoredCameraIDs)); + } + // Setup multi-camera buttons (must be done after creating preview so we know which Camera API is being used, // and before initialising on-screen visibility). // We only allow the separate icon for switching cameras if: @@ -462,6 +467,9 @@ public class MainActivity extends AppCompatActivity { } for(String cameraId: camerafinder.getAllCameraIdList()) { + if (Arrays.stream(ignoredCameraIDs).anyMatch(id -> id.equals(cameraId))) { + continue; + } int id = Integer.parseInt(cameraId); cameraCharacteristics = camerafinder.getCameraCharacteristics(id); Integer facing = cameraCharacteristics.get(CameraCharacteristics.LENS_FACING); @@ -486,6 +494,10 @@ public class MainActivity extends AppCompatActivity { this.front_camera_ids = new ArrayList<>(); this.other_camera_ids = new ArrayList<>(); for (int i = 0; i < n_cameras; i++) { + String currentCameraID = String.valueOf(i); + if (Arrays.stream(ignoredCameraIDs).anyMatch(id -> id.equals(currentCameraID))) { + continue; + } switch (preview.getCameraControllerManager().getFacing(i)) { case FACING_BACK: back_camera_ids.add(i); diff --git a/app/src/main/res/values/config.xml b/app/src/main/res/values/config.xml index 8a88dcd24..05cdb8261 100644 --- a/app/src/main/res/values/config.xml +++ b/app/src/main/res/values/config.xml @@ -17,4 +17,9 @@ + + + + + -- GitLab