From cd5783cd2c833a1cc0b31b682c521e3387522275 Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 19 Dec 2023 13:35:04 +0530 Subject: [PATCH 1/4] camera: Fix test class import errors --- .../opencamera/InstrumentedTest.java | 10 +- .../net/sourceforge/opencamera/TestUtils.java | 75 +- .../opencamera/test/MainActivityTest.java | 822 +++++++++--------- 3 files changed, 458 insertions(+), 449 deletions(-) diff --git a/app/src/androidTest/java/net/sourceforge/opencamera/InstrumentedTest.java b/app/src/androidTest/java/net/sourceforge/opencamera/InstrumentedTest.java index a7fd9bdd8..cc26f5496 100644 --- a/app/src/androidTest/java/net/sourceforge/opencamera/InstrumentedTest.java +++ b/app/src/androidTest/java/net/sourceforge/opencamera/InstrumentedTest.java @@ -7,7 +7,11 @@ import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.endsWith; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import android.annotation.TargetApi; import android.content.Intent; @@ -39,6 +43,8 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReference; +import foundation.e.camera.R; + interface PhotoTests {} interface HDRTests {} @@ -6168,7 +6174,7 @@ public class InstrumentedTest { if( !single_tap_photo && !double_tap_photo ) { mActivityRule.getScenario().onActivity(activity -> { - View takePhotoButton = activity.findViewById(net.sourceforge.opencamera.R.id.take_photo); + View takePhotoButton = activity.findViewById(R.id.take_photo); assertFalse( activity.hasThumbnailAnimation() ); Log.d(TAG, "about to click take photo"); clickView(takePhotoButton); diff --git a/app/src/androidTest/java/net/sourceforge/opencamera/TestUtils.java b/app/src/androidTest/java/net/sourceforge/opencamera/TestUtils.java index 92c980f52..0e5182e8e 100644 --- a/app/src/androidTest/java/net/sourceforge/opencamera/TestUtils.java +++ b/app/src/androidTest/java/net/sourceforge/opencamera/TestUtils.java @@ -1,6 +1,11 @@ package net.sourceforge.opencamera; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import android.annotation.TargetApi; import android.content.ContentUris; @@ -23,8 +28,8 @@ import android.renderscript.Allocation; import android.util.Log; import android.view.View; -import androidx.annotation.RequiresApi; import androidx.exifinterface.media.ExifInterface; +import androidx.test.filters.SdkSuppress; import net.sourceforge.opencamera.preview.Preview; @@ -41,6 +46,8 @@ import java.util.Date; import java.util.List; import java.util.Locale; +import foundation.e.camera.R; + /** Helper class for testing. This method should not include any code specific to any test framework * (e.g., shouldn't be specific to ActivityInstrumentationTestCase2). */ @@ -356,7 +363,7 @@ public class TestUtils { * We check that we have a single range of non-zero values. * @param bitmap The bitmap to compute and check a histogram for. */ - @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) + @SdkSuppress(minSdkVersion = Build.VERSION_CODES.LOLLIPOP) public static HistogramDetails checkHistogram(MainActivity activity, Bitmap bitmap) { int [] histogram = activity.getApplicationInterface().getHDRProcessor().computeHistogram(bitmap, true); assertEquals(256, histogram.length); @@ -778,17 +785,17 @@ public class TestUtils { public static void waitForTakePhotoChecks(MainActivity activity, long time_s) { Preview preview = activity.getPreview(); - View switchCameraButton = activity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); - View switchMultiCameraButton = activity.findViewById(net.sourceforge.opencamera.R.id.switch_multi_camera); - View switchVideoButton = activity.findViewById(net.sourceforge.opencamera.R.id.switch_video); - //View flashButton = activity.findViewById(net.sourceforge.opencamera.R.id.flash); - //View focusButton = activity.findViewById(net.sourceforge.opencamera.R.id.focus_mode); - View exposureButton = activity.findViewById(net.sourceforge.opencamera.R.id.exposure); - View exposureLockButton = activity.findViewById(net.sourceforge.opencamera.R.id.exposure_lock); - View audioControlButton = activity.findViewById(net.sourceforge.opencamera.R.id.audio_control); - View popupButton = activity.findViewById(net.sourceforge.opencamera.R.id.popup); - View trashButton = activity.findViewById(net.sourceforge.opencamera.R.id.trash); - View shareButton = activity.findViewById(net.sourceforge.opencamera.R.id.share); + View switchCameraButton = activity.findViewById(R.id.switch_camera); + View switchMultiCameraButton = activity.findViewById(R.id.switch_multi_camera); + View switchVideoButton = activity.findViewById(R.id.switch_video); + //View flashButton = activity.findViewById(R.id.flash); + //View focusButton = activity.findViewById(R.id.focus_mode); + View exposureButton = activity.findViewById(R.id.exposure); + View exposureLockButton = activity.findViewById(R.id.exposure_lock); + View audioControlButton = activity.findViewById(R.id.audio_control); + View popupButton = activity.findViewById(R.id.popup); + View trashButton = activity.findViewById(R.id.trash); + View shareButton = activity.findViewById(R.id.share); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity); boolean is_focus_bracketing = activity.supportsFocusBracketing() && sharedPreferences.getString(PreferenceKeys.PhotoModePreferenceKey, "preference_photo_mode_std").equals("preference_photo_mode_focus_bracketing"); boolean is_panorama = activity.supportsPanorama() && sharedPreferences.getString(PreferenceKeys.PhotoModePreferenceKey, "preference_photo_mode_std").equals("preference_photo_mode_panorama"); @@ -1227,15 +1234,15 @@ public class TestUtils { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity); boolean has_audio_control_button = !sharedPreferences.getString(PreferenceKeys.AudioControlPreferenceKey, "none").equals("none"); - View switchCameraButton = activity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); - View switchMultiCameraButton = activity.findViewById(net.sourceforge.opencamera.R.id.switch_multi_camera); - View switchVideoButton = activity.findViewById(net.sourceforge.opencamera.R.id.switch_video); - View exposureButton = activity.findViewById(net.sourceforge.opencamera.R.id.exposure); - View exposureLockButton = activity.findViewById(net.sourceforge.opencamera.R.id.exposure_lock); - View audioControlButton = activity.findViewById(net.sourceforge.opencamera.R.id.audio_control); - View popupButton = activity.findViewById(net.sourceforge.opencamera.R.id.popup); - View trashButton = activity.findViewById(net.sourceforge.opencamera.R.id.trash); - View shareButton = activity.findViewById(net.sourceforge.opencamera.R.id.share); + View switchCameraButton = activity.findViewById(R.id.switch_camera); + View switchMultiCameraButton = activity.findViewById(R.id.switch_multi_camera); + View switchVideoButton = activity.findViewById(R.id.switch_video); + View exposureButton = activity.findViewById(R.id.exposure); + View exposureLockButton = activity.findViewById(R.id.exposure_lock); + View audioControlButton = activity.findViewById(R.id.audio_control); + View popupButton = activity.findViewById(R.id.popup); + View trashButton = activity.findViewById(R.id.trash); + View shareButton = activity.findViewById(R.id.share); // trash/share only shown when preview is paused after taking a photo boolean pause_preview = sharedPreferences.getBoolean(PreferenceKeys.PausePreviewPreferenceKey, false); @@ -1296,17 +1303,17 @@ public class TestUtils { boolean has_audio_control_button = !sharedPreferences.getString(PreferenceKeys.AudioControlPreferenceKey, "none").equals("none"); - View switchCameraButton = activity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); - View switchMultiCameraButton = activity.findViewById(net.sourceforge.opencamera.R.id.switch_multi_camera); - View switchVideoButton = activity.findViewById(net.sourceforge.opencamera.R.id.switch_video); - //View flashButton = activity.findViewById(net.sourceforge.opencamera.R.id.flash); - //View focusButton = activity.findViewById(net.sourceforge.opencamera.R.id.focus_mode); - View exposureButton = activity.findViewById(net.sourceforge.opencamera.R.id.exposure); - View exposureLockButton = activity.findViewById(net.sourceforge.opencamera.R.id.exposure_lock); - View audioControlButton = activity.findViewById(net.sourceforge.opencamera.R.id.audio_control); - View popupButton = activity.findViewById(net.sourceforge.opencamera.R.id.popup); - View trashButton = activity.findViewById(net.sourceforge.opencamera.R.id.trash); - View shareButton = activity.findViewById(net.sourceforge.opencamera.R.id.share); + View switchCameraButton = activity.findViewById(R.id.switch_camera); + View switchMultiCameraButton = activity.findViewById(R.id.switch_multi_camera); + View switchVideoButton = activity.findViewById(R.id.switch_video); + //View flashButton = activity.findViewById(R.id.flash); + //View focusButton = activity.findViewById(R.id.focus_mode); + View exposureButton = activity.findViewById(R.id.exposure); + View exposureLockButton = activity.findViewById(R.id.exposure_lock); + View audioControlButton = activity.findViewById(R.id.audio_control); + View popupButton = activity.findViewById(R.id.popup); + View trashButton = activity.findViewById(R.id.trash); + View shareButton = activity.findViewById(R.id.share); assertEquals(switchCameraButton.getVisibility(), (immersive_mode ? View.GONE : (activity.getPreview().getCameraControllerManager().getNumberOfCameras() > 1 ? View.VISIBLE : View.GONE))); assertEquals(switchMultiCameraButton.getVisibility(), (immersive_mode ? View.GONE : (activity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE))); assertEquals(switchVideoButton.getVisibility(), (immersive_mode ? View.GONE : View.VISIBLE)); diff --git a/app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java b/app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java index b1db2c87b..34aa71a01 100644 --- a/app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java +++ b/app/src/androidTest/java/net/sourceforge/opencamera/test/MainActivityTest.java @@ -1,44 +1,9 @@ package net.sourceforge.opencamera.test; -import java.io.File; -import java.io.FileDescriptor; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Set; - -import net.sourceforge.opencamera.LocationSupplier; -import net.sourceforge.opencamera.MyPreferenceFragment; -import net.sourceforge.opencamera.TestUtils; -import net.sourceforge.opencamera.cameracontroller.CameraController2; -import net.sourceforge.opencamera.HDRProcessor; -import net.sourceforge.opencamera.HDRProcessorException; -import net.sourceforge.opencamera.ImageSaver; -import net.sourceforge.opencamera.MainActivity; -import net.sourceforge.opencamera.MyApplicationInterface; -import net.sourceforge.opencamera.PreferenceKeys; -import net.sourceforge.opencamera.preview.ApplicationInterface; -import net.sourceforge.opencamera.preview.VideoProfile; -import net.sourceforge.opencamera.SaveLocationHistory; -import net.sourceforge.opencamera.cameracontroller.CameraController; -import net.sourceforge.opencamera.preview.Preview; -import net.sourceforge.opencamera.ui.DrawPreview; -import net.sourceforge.opencamera.ui.FolderChooserDialog; -import net.sourceforge.opencamera.ui.MainUI; -import net.sourceforge.opencamera.ui.PopupView; - import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Intent; import android.content.SharedPreferences; -//import android.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Point; @@ -64,6 +29,37 @@ import android.widget.SeekBar; import android.widget.TextView; import android.widget.ZoomControls; +import net.sourceforge.opencamera.HDRProcessor; +import net.sourceforge.opencamera.HDRProcessorException; +import net.sourceforge.opencamera.ImageSaver; +import net.sourceforge.opencamera.LocationSupplier; +import net.sourceforge.opencamera.MainActivity; +import net.sourceforge.opencamera.MyApplicationInterface; +import net.sourceforge.opencamera.MyPreferenceFragment; +import net.sourceforge.opencamera.PreferenceKeys; +import net.sourceforge.opencamera.SaveLocationHistory; +import net.sourceforge.opencamera.TestUtils; +import net.sourceforge.opencamera.cameracontroller.CameraController; +import net.sourceforge.opencamera.cameracontroller.CameraController2; +import net.sourceforge.opencamera.preview.ApplicationInterface; +import net.sourceforge.opencamera.preview.Preview; +import net.sourceforge.opencamera.preview.VideoProfile; +import net.sourceforge.opencamera.ui.DrawPreview; +import net.sourceforge.opencamera.ui.FolderChooserDialog; +import net.sourceforge.opencamera.ui.MainUI; +import net.sourceforge.opencamera.ui.PopupView; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Set; + +import foundation.e.camera.R; + // ignore warning about "Call to Thread.sleep in a loop", this is only test code @SuppressWarnings("BusyWait") public class MainActivityTest extends ActivityInstrumentationTestCase2 { @@ -252,7 +248,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { Log.d(TAG, "switch camera"); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); clickView(switchCameraButton); waitUntilCameraOpened(); @@ -980,7 +976,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { Log.d(TAG, "switch camera"); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); clickView(switchCameraButton); waitUntilCameraOpened(); @@ -1374,7 +1370,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { int cameraId = mPreview.getCameraId(); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); clickView(switchCameraButton); waitUntilCameraOpened(); // check face detection already started @@ -1649,22 +1645,22 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { int cameraId = mPreview.getCameraId(); Log.d(TAG, "cameraId? "+ cameraId); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); //mActivity.clickedSwitchCamera(switchCameraButton); clickView(switchCameraButton); waitUntilCameraOpened(); @@ -1830,7 +1826,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 0); - String next_string = mActivity.getResources().getString(next ? net.sourceforge.opencamera.R.string.next : net.sourceforge.opencamera.R.string.previous); + String next_string = mActivity.getResources().getString(next ? R.string.next : R.string.previous); assertTrue(next_string.length() > 0); assertTrue(content_description.startsWith(next_string + " " + title)); } @@ -1855,16 +1851,16 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.preference_video_capture_rate, "VIDEOCAPTURERATE", false, false); - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.preference_video_capture_rate, "VIDEOCAPTURERATE", true, true); + subTestPopupButtonContentDescription(R.string.preference_video_capture_rate, "VIDEOCAPTURERATE", false, false); + subTestPopupButtonContentDescription(R.string.preference_video_capture_rate, "VIDEOCAPTURERATE", true, true); } - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.preference_timer, "TIMER", false, false); - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.preference_timer, "TIMER", true, true); - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.preference_burst_mode, "REPEAT_MODE", false, false); - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.preference_burst_mode, "REPEAT_MODE", true, true); - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.grid, "GRID", false, true); - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.grid, "GRID", true, true); + subTestPopupButtonContentDescription(R.string.preference_timer, "TIMER", false, false); + subTestPopupButtonContentDescription(R.string.preference_timer, "TIMER", true, true); + subTestPopupButtonContentDescription(R.string.preference_burst_mode, "REPEAT_MODE", false, false); + subTestPopupButtonContentDescription(R.string.preference_burst_mode, "REPEAT_MODE", true, true); + subTestPopupButtonContentDescription(R.string.grid, "GRID", false, true); + subTestPopupButtonContentDescription(R.string.grid, "GRID", true, true); int saved_count = mPreview.count_cameraAutoFocus; Log.d(TAG, "0 count_cameraAutoFocus: " + saved_count); @@ -1906,7 +1902,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { int cameraId = mPreview.getCameraId(); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); clickView(switchCameraButton); waitUntilCameraOpened(); int new_cameraId = mPreview.getCameraId(); @@ -1917,14 +1913,14 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.preference_video_capture_rate, "VIDEOCAPTURERATE", false, false); - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.preference_video_capture_rate, "VIDEOCAPTURERATE", true, true); + subTestPopupButtonContentDescription(R.string.preference_video_capture_rate, "VIDEOCAPTURERATE", false, false); + subTestPopupButtonContentDescription(R.string.preference_video_capture_rate, "VIDEOCAPTURERATE", true, true); } - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.preference_timer, "TIMER", false, false); - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.preference_timer, "TIMER", true, true); - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.preference_burst_mode, "REPEAT_MODE", false, false); - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.preference_burst_mode, "REPEAT_MODE", true, true); - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.grid, "GRID", false, true); - subTestPopupButtonContentDescription(net.sourceforge.opencamera.R.string.grid, "GRID", true, true); + subTestPopupButtonContentDescription(R.string.preference_timer, "TIMER", false, false); + subTestPopupButtonContentDescription(R.string.preference_timer, "TIMER", true, true); + subTestPopupButtonContentDescription(R.string.preference_burst_mode, "REPEAT_MODE", false, false); + subTestPopupButtonContentDescription(R.string.preference_burst_mode, "REPEAT_MODE", true, true); + subTestPopupButtonContentDescription(R.string.grid, "GRID", false, true); + subTestPopupButtonContentDescription(R.string.grid, "GRID", true, true); clickView(switchVideoButton); waitUntilCameraOpened(); @@ -2024,7 +2020,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 saved_count_cameraContinuousFocusMoving ); // switch to video - View switchVideoButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_video); + View switchVideoButton = mActivity.findViewById(R.id.switch_video); clickView(switchVideoButton); waitUntilCameraOpened(); String focus_value = mPreview.getCameraController().getFocusValue(); @@ -2071,7 +2067,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { Log.d(TAG, "switch camera"); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); clickView(switchCameraButton); waitUntilCameraOpened(); @@ -2936,10 +2932,10 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { Log.d(TAG, "switch camera"); int old_max = mPreview.getMaximumISO(); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); clickView(switchCameraButton); waitUntilCameraOpened(); @@ -3080,7 +3076,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ? View.VISIBLE : View.GONE))); assertEquals(switchMultiCameraButton.getVisibility(), (immersive_mode ? View.GONE : (mActivity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE))); assertEquals(switchVideoButton.getVisibility(), (immersive_mode ? View.GONE : View.VISIBLE)); @@ -4504,7 +4500,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ? View.VISIBLE : View.GONE)); assertEquals(switchMultiCameraButton.getVisibility(), (mActivity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE)); assertEquals(switchVideoButton.getVisibility(), View.VISIBLE); @@ -4661,7 +4657,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ? View.VISIBLE : View.GONE)); assertEquals(switchMultiCameraButton.getVisibility(), (mActivity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE)); assertEquals(switchVideoButton.getVisibility(), View.VISIBLE); @@ -5021,7 +5017,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { int cameraId = mPreview.getCameraId(); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); while( switchCameraButton.getVisibility() != View.VISIBLE ) { // wait until photo is taken and button is visible again } @@ -5155,7 +5151,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { int cameraId = mPreview.getCameraId(); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); while( switchCameraButton.getVisibility() != View.VISIBLE ) { // wait until photo is taken and button is visible again } @@ -5251,23 +5247,23 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ? View.VISIBLE : View.GONE))); assertEquals(switchMultiCameraButton.getVisibility(), (immersive_mode ? View.GONE : (mActivity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE))); assertEquals(switchVideoButton.getVisibility(), (immersive_mode ? View.GONE : View.VISIBLE)); @@ -5321,9 +5317,9 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2= Build.VERSION_CODES.N ) assertEquals(pauseVideoButton.getVisibility(), View.VISIBLE); else @@ -5378,10 +5374,10 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ? View.VISIBLE : View.GONE)); assertEquals(switchMultiCameraButton.getVisibility(), (mActivity.showSwitchMultiCamIcon() ? View.VISIBLE : View.GONE)); assertEquals(switchVideoButton.getVisibility(), View.VISIBLE); @@ -7102,7 +7098,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { Log.d(TAG, "switch camera"); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); clickView(switchCameraButton); waitUntilCameraOpened(); subTestVideoPopup(false); @@ -8005,7 +8001,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { Log.d(TAG, "switch camera"); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); clickView(switchCameraButton); waitUntilCameraOpened(); subTestVideoPopup(true); @@ -8249,20 +8245,20 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); clickView(switchCameraButton); waitUntilCameraOpened(); assertTrue(mActivity.getLocationSupplier().hasLocationListeners()); @@ -8609,7 +8605,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { int cameraId = mPreview.getCameraId(); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); clickView(switchCameraButton); waitUntilCameraOpened(); this.getInstrumentation().waitForIdleSync(); @@ -8708,7 +8704,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); clickView(switchCameraButton); waitUntilCameraOpened(); // shouldn't need to wait for test_has_received_location to be true, as should remember from before switching camera @@ -8806,7 +8802,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ) { Log.d(TAG, "switch camera"); - View switchCameraButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.switch_camera); + View switchCameraButton = mActivity.findViewById(R.id.switch_camera); clickView(switchCameraButton); waitUntilCameraOpened(); assertNotNull(mPreview.getCameraControllerManager()); @@ -10352,7 +10348,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 1 ? View.VISIBLE : View.GONE)); @@ -11581,7 +11577,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2 Date: Tue, 19 Dec 2023 13:39:48 +0530 Subject: [PATCH 2/4] camera: sign debug with AOSP test keys --- app/build.gradle | 13 ++++++++++++- app/keys/platform.jks | Bin 0 -> 3052 bytes 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 app/keys/platform.jks diff --git a/app/build.gradle b/app/build.gradle index c9eee76d4..52eeee9ed 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,6 +10,16 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } + signingConfigs { + // These are public keys provided by AOSP, Use different passcode protected keys for production + debug { + storeFile file('keys/platform.jks') + storePassword 'platform' + keyAlias 'platform' + keyPassword 'platform' + } + } + defaultConfig { applicationId "foundation.e.camera" minSdkVersion 25 @@ -27,7 +37,8 @@ android { buildTypes { debug { - applicationIdSuffix ".debug" + //applicationIdSuffix ".debug" + signingConfig signingConfigs.debug } release { diff --git a/app/keys/platform.jks b/app/keys/platform.jks new file mode 100644 index 0000000000000000000000000000000000000000..b778840542e79c048bcf570aa960243eeb9b9d53 GIT binary patch literal 3052 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 X4gBin;_WFr#VkVgR?9E{583|$1Z;)? literal 0 HcmV?d00001 -- GitLab From 66bbaaf80a16bc1ea2f3f112d1d3237b84636f3d Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 19 Dec 2023 14:41:34 +0530 Subject: [PATCH 3/4] camera: Log if its debug build --- app/src/main/java/net/sourceforge/opencamera/MyDebug.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/MyDebug.java b/app/src/main/java/net/sourceforge/opencamera/MyDebug.java index 00e82f8f5..260c4550b 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MyDebug.java +++ b/app/src/main/java/net/sourceforge/opencamera/MyDebug.java @@ -1,8 +1,10 @@ package net.sourceforge.opencamera; +import foundation.e.camera.BuildConfig; + /** Global constant to control logging, should always be set to false in * released versions. */ public class MyDebug { - public static final boolean LOG = false; + public static final boolean LOG = BuildConfig.DEBUG; } -- GitLab From 625fb880a95edd2c725af2a6de2a2f96a1751577 Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 19 Dec 2023 14:40:47 +0530 Subject: [PATCH 4/4] camera: allow to set default resolution --- .../sourceforge/opencamera/MainActivity.java | 17 +++++++++++++++++ app/src/main/res/values/config.xml | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java index b163eb747..de596e265 100644 --- a/app/src/main/java/net/sourceforge/opencamera/MainActivity.java +++ b/app/src/main/java/net/sourceforge/opencamera/MainActivity.java @@ -997,6 +997,23 @@ public class MainActivity extends AppCompatActivity { } } } + + String[] defaultResolutions = getResources().getStringArray( + R.array.config_e_os_camera_default_resolution_lens); + SharedPreferences.Editor editor = sharedPreferences.edit(); + + for (String entry : defaultResolutions) { + if (!entry.matches("\\d+:\\d+x\\d+")) continue; + + String[] mainParts = entry.split(":"); + String[] resParts = mainParts[1].split("x"); + int cameraId = Integer.parseInt(mainParts[0]); + String resolution = resParts[0] + " " + resParts[1]; + + editor.putString(PreferenceKeys.getResolutionPreferenceKey(cameraId), resolution); + } + + editor.apply(); } /** Switches modes if required, if called from a relevant intent/tile. diff --git a/app/src/main/res/values/config.xml b/app/src/main/res/values/config.xml index 05cdb8261..13ff57447 100644 --- a/app/src/main/res/values/config.xml +++ b/app/src/main/res/values/config.xml @@ -22,4 +22,9 @@ + + + + + -- GitLab