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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 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