Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75f4aa1c authored by Mark Harman's avatar Mark Harman
Browse files

Fix Android warnings.

parent 79e31a90
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -2106,7 +2106,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv

	    View exposureButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure);
		View exposureContainer = mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure_container);
		SeekBar seekBar = (SeekBar) mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure_seekbar);
		SeekBar seekBar = mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure_seekbar);
	    assertTrue(exposureButton.getVisibility() == (mPreview.supportsExposures() ? View.VISIBLE : View.GONE));
	    assertTrue(exposureContainer.getVisibility() == View.GONE);

@@ -2205,8 +2205,8 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv

		View exposureButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure);
		View exposureContainer = mActivity.findViewById(net.sourceforge.opencamera.R.id.manual_exposure_container);
		SeekBar isoSeekBar = (SeekBar) mActivity.findViewById(net.sourceforge.opencamera.R.id.iso_seekbar);
	    SeekBar exposureTimeSeekBar = (SeekBar) mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure_time_seekbar);
		SeekBar isoSeekBar = mActivity.findViewById(net.sourceforge.opencamera.R.id.iso_seekbar);
	    SeekBar exposureTimeSeekBar = mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure_time_seekbar);
	    assertTrue(exposureButton.getVisibility() == View.VISIBLE);
	    assertTrue(exposureContainer.getVisibility() == View.GONE);

@@ -2343,7 +2343,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
		int initial_temperature = mPreview.getCameraController().getWhiteBalanceTemperature();
		int initial_temperature_setting = settings.getInt(PreferenceKeys.WhiteBalanceTemperaturePreferenceKey, 5000);
		assertTrue(initial_temperature == initial_temperature_setting);
		SeekBar white_balance_seek_bar = ((SeekBar)mActivity.findViewById(net.sourceforge.opencamera.R.id.white_balance_seekbar));
		SeekBar white_balance_seek_bar = mActivity.findViewById(net.sourceforge.opencamera.R.id.white_balance_seekbar);
		int initial_white_balance_seek_bar_pos = white_balance_seek_bar.getProgress();

		/*SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mActivity);
@@ -2419,9 +2419,9 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv

		View exposureButton = mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure);
		View exposureContainer = mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure_container);
		SeekBar seekBar = (SeekBar) mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure_seekbar);
		SeekBar seekBar = mActivity.findViewById(net.sourceforge.opencamera.R.id.exposure_seekbar);
        View manualWBContainer = mActivity.findViewById(net.sourceforge.opencamera.R.id.manual_white_balance_container);
		SeekBar seekBarWB = (SeekBar) mActivity.findViewById(net.sourceforge.opencamera.R.id.white_balance_seekbar);
		SeekBar seekBarWB = mActivity.findViewById(net.sourceforge.opencamera.R.id.white_balance_seekbar);

		assertTrue(exposureButton.getVisibility() == (mPreview.supportsExposures() ? View.VISIBLE : View.GONE));
		assertTrue(exposureContainer.getVisibility() == View.GONE);
@@ -3424,7 +3424,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
			return;
		}
		setToDefault();
	    SeekBar seekBar = (SeekBar) mActivity.findViewById(net.sourceforge.opencamera.R.id.focus_seekbar);
	    SeekBar seekBar = mActivity.findViewById(net.sourceforge.opencamera.R.id.focus_seekbar);
	    assertTrue(seekBar.getVisibility() == View.GONE);
		switchToFocusValue("focus_mode_manual2");
	    assertTrue(seekBar.getVisibility() == View.VISIBLE);
@@ -7228,10 +7228,10 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
		SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mActivity);
		SharedPreferences.Editor editor = settings.edit();

	    final ZoomControls zoomControls = (ZoomControls) mActivity.findViewById(net.sourceforge.opencamera.R.id.zoom);
	    final ZoomControls zoomControls = mActivity.findViewById(net.sourceforge.opencamera.R.id.zoom);
		assertTrue(zoomControls.getVisibility() == View.GONE);

	    final SeekBar zoomSeekBar = (SeekBar) mActivity.findViewById(net.sourceforge.opencamera.R.id.zoom_seekbar);
	    final SeekBar zoomSeekBar = mActivity.findViewById(net.sourceforge.opencamera.R.id.zoom_seekbar);
		assertTrue(zoomSeekBar.getVisibility() == View.VISIBLE);
		int max_zoom = mPreview.getMaxZoom();
		assertTrue(zoomSeekBar.getMax() == max_zoom);
@@ -7402,7 +7402,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
	    	return;
	    }

	    final SeekBar zoomSeekBar = (SeekBar) mActivity.findViewById(net.sourceforge.opencamera.R.id.zoom_seekbar);
	    final SeekBar zoomSeekBar = mActivity.findViewById(net.sourceforge.opencamera.R.id.zoom_seekbar);
		assertTrue(zoomSeekBar.getVisibility() == View.VISIBLE);
		int init_zoom = mPreview.getCameraController().getZoom();
	    int max_zoom = mPreview.getMaxZoom();
@@ -7432,7 +7432,7 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
			return;
		}

	    final SeekBar zoomSeekBar = (SeekBar) mActivity.findViewById(net.sourceforge.opencamera.R.id.zoom_seekbar);
	    final SeekBar zoomSeekBar = mActivity.findViewById(net.sourceforge.opencamera.R.id.zoom_seekbar);
		assertTrue(zoomSeekBar.getVisibility() == View.VISIBLE);
		int init_zoom = mPreview.getCameraController().getZoom();
	    int max_zoom = mPreview.getMaxZoom();
+3 −3
Original line number Diff line number Diff line
@@ -142,10 +142,10 @@ public abstract class CameraController {
	public static class Size {
		public final int width;
		public final int height;
		public final List<int[]> fps_ranges;
		final List<int[]> fps_ranges;
		public final boolean high_speed;

		public Size(int width, int height, List<int[]> fps_ranges, boolean high_speed) {
		Size(int width, int height, List<int[]> fps_ranges, boolean high_speed) {
			this.width = width;
			this.height = height;
			this.fps_ranges = fps_ranges;
@@ -157,7 +157,7 @@ public abstract class CameraController {
			this(width, height, new ArrayList<int[]>(), false);
		}

		public boolean supportsFrameRate(double fps) {
		boolean supportsFrameRate(double fps) {
			for (int[] f : this.fps_ranges) {
				if (f[0] <= fps && fps <= f[1])
					return true;
+8 −12
Original line number Diff line number Diff line
@@ -418,7 +418,6 @@ public class CameraController1 extends CameraController {
	 */
	@Override
	public SupportedValues setSceneMode(String value) {
		String default_value = SCENE_MODE_DEFAULT;
		Camera.Parameters parameters = this.getParameters();
		List<String> values = parameters.getSupportedSceneModes();
		/*{
@@ -426,7 +425,7 @@ public class CameraController1 extends CameraController {
			values = new ArrayList<>();
			values.add(ISO_DEFAULT);
		}*/
		SupportedValues supported_values = checkModeIsSupported(values, value, default_value);
		SupportedValues supported_values = checkModeIsSupported(values, value, SCENE_MODE_DEFAULT);
		if( supported_values != null ) {
			String scene_mode = parameters.getSceneMode();
			// if scene mode is null, it should mean scene modes aren't supported anyway
@@ -455,10 +454,9 @@ public class CameraController1 extends CameraController {
	}

	public SupportedValues setColorEffect(String value) {
		String default_value = COLOR_EFFECT_DEFAULT;
		Camera.Parameters parameters = this.getParameters();
		List<String> values = parameters.getSupportedColorEffects();
		SupportedValues supported_values = checkModeIsSupported(values, value, default_value);
		SupportedValues supported_values = checkModeIsSupported(values, value, COLOR_EFFECT_DEFAULT);
		if( supported_values != null ) {
			String color_effect = parameters.getColorEffect();
			// have got nullpointerexception from Google Play, so now check for null
@@ -476,7 +474,6 @@ public class CameraController1 extends CameraController {
	}

	public SupportedValues setWhiteBalance(String value) {
		String default_value = WHITE_BALANCE_DEFAULT;
		Camera.Parameters parameters = this.getParameters();
		List<String> values = parameters.getSupportedWhiteBalance();
		if( values != null ) {
@@ -488,7 +485,7 @@ public class CameraController1 extends CameraController {
				values.remove("manual");
			}
		}
		SupportedValues supported_values = checkModeIsSupported(values, value, default_value);
		SupportedValues supported_values = checkModeIsSupported(values, value, WHITE_BALANCE_DEFAULT);
		if( supported_values != null ) {
			String white_balance = parameters.getWhiteBalance();
			// if white balance is null, it should mean white balances aren't supported anyway
@@ -519,10 +516,9 @@ public class CameraController1 extends CameraController {

	@Override
	public SupportedValues setAntiBanding(String value) {
		String default_value = ANTIBANDING_DEFAULT;
		Camera.Parameters parameters = this.getParameters();
		List<String> values = parameters.getSupportedAntibanding();
		SupportedValues supported_values = checkModeIsSupported(values, value, default_value);
		SupportedValues supported_values = checkModeIsSupported(values, value, ANTIBANDING_DEFAULT);
		if( supported_values != null ) {
			// for antibanding, if the requested value isn't available, we don't modify it at all
			// (so we stick with the device's default setting)
+41 −36
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ public class CameraController2 extends CameraController {
		BURSTTYPE_NONE, // for when enable_burst is false
		BURSTTYPE_EXPO, // enable expo bracketing mode; see expo_bracketing_n_images, expo_bracketing_stops for further control
		BURSTTYPE_NORMAL // take a regular burst; see burst_for_noise_reduction, burst_requested_n_images for further control
	};
	}
	private BurstType burst_type = BurstType.BURSTTYPE_NONE;
	// for BURSTTYPE_EXPO:
	private final static int max_expo_bracketing_n_images = 5; // could be more, but limit to 5 for now
@@ -1355,16 +1355,23 @@ public class CameraController2 extends CameraController {
			throw new CameraControllerException();*/
		if( MyDebug.LOG ) {
			int hardware_level = characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
			if( hardware_level == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY )
			switch (hardware_level) {
				case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY:
					Log.d(TAG, "Hardware Level: LEGACY");
			else if( hardware_level == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED )
					break;
				case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED:
					Log.d(TAG, "Hardware Level: LIMITED");
			else if( hardware_level == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL )
					break;
				case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL:
					Log.d(TAG, "Hardware Level: FULL");
			else if( hardware_level == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_3 )
					break;
				case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_3:
					Log.d(TAG, "Hardware Level: Level 3");
			else
					break;
				default:
					Log.e(TAG, "Unknown Hardware Level: " + hardware_level);
					break;
			}

			int [] nr_modes = characteristics.get(CameraCharacteristics.NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES);
			Log.d(TAG, "nr_modes:");
@@ -1802,7 +1809,6 @@ public class CameraController2 extends CameraController {
		if( MyDebug.LOG )
			Log.d(TAG, "setSceneMode: " + value);
		// we convert to/from strings to be compatible with original Android Camera API
		String default_value = SCENE_MODE_DEFAULT;
		int [] values2 = characteristics.get(CameraCharacteristics.CONTROL_AVAILABLE_SCENE_MODES);
		boolean has_disabled = false;
		List<String> values = new ArrayList<>();
@@ -1817,7 +1823,7 @@ public class CameraController2 extends CameraController {
		if( !has_disabled ) {
			values.add(0, SCENE_MODE_DEFAULT);
		}
		SupportedValues supported_values = checkModeIsSupported(values, value, default_value);
		SupportedValues supported_values = checkModeIsSupported(values, value, SCENE_MODE_DEFAULT);
		if( supported_values != null ) {
			int selected_value2 = CameraMetadata.CONTROL_SCENE_MODE_DISABLED;
			switch(supported_values.selected_value) {
@@ -1952,7 +1958,6 @@ public class CameraController2 extends CameraController {
		if( MyDebug.LOG )
			Log.d(TAG, "setColorEffect: " + value);
		// we convert to/from strings to be compatible with original Android Camera API
		String default_value = COLOR_EFFECT_DEFAULT;
		int [] values2 = characteristics.get(CameraCharacteristics.CONTROL_AVAILABLE_EFFECTS);
		List<String> values = new ArrayList<>();
		for(int value2 : values2) {
@@ -1961,7 +1966,7 @@ public class CameraController2 extends CameraController {
				values.add(this_value);
			}
		}
		SupportedValues supported_values = checkModeIsSupported(values, value, default_value);
		SupportedValues supported_values = checkModeIsSupported(values, value, COLOR_EFFECT_DEFAULT);
		if( supported_values != null ) {
			int selected_value2 = CameraMetadata.CONTROL_EFFECT_MODE_OFF;
			switch(supported_values.selected_value) {
@@ -2076,7 +2081,6 @@ public class CameraController2 extends CameraController {
		if( MyDebug.LOG )
			Log.d(TAG, "setWhiteBalance: " + value);
		// we convert to/from strings to be compatible with original Android Camera API
		String default_value = WHITE_BALANCE_DEFAULT;
		int [] values2 = characteristics.get(CameraCharacteristics.CONTROL_AWB_AVAILABLE_MODES);
		List<String> values = new ArrayList<>();
		for(int value2 : values2) {
@@ -2099,7 +2103,7 @@ public class CameraController2 extends CameraController {
			if( has_auto )
				values.add(0, WHITE_BALANCE_DEFAULT);
		}
		SupportedValues supported_values = checkModeIsSupported(values, value, default_value);
		SupportedValues supported_values = checkModeIsSupported(values, value, WHITE_BALANCE_DEFAULT);
		if( supported_values != null ) {
			int selected_value2 = CameraMetadata.CONTROL_AWB_MODE_AUTO;
			switch(supported_values.selected_value) {
@@ -2225,7 +2229,6 @@ public class CameraController2 extends CameraController {
		if( MyDebug.LOG )
			Log.d(TAG, "setAntiBanding: " + value);
		// we convert to/from strings to be compatible with original Android Camera API
		String default_value = ANTIBANDING_DEFAULT;
		int [] values2 = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_ANTIBANDING_MODES );
		List<String> values = new ArrayList<>();
		for(int value2 : values2) {
@@ -2234,7 +2237,7 @@ public class CameraController2 extends CameraController {
				values.add(this_value);
			}
		}
		SupportedValues supported_values = checkModeIsSupported(values, value, default_value);
		SupportedValues supported_values = checkModeIsSupported(values, value, ANTIBANDING_DEFAULT);
		if( supported_values != null ) {
			// for antibanding, if the requested value isn't available, we don't modify it at all
			// (so we stick with the device's default setting)
@@ -2948,23 +2951,25 @@ public class CameraController2 extends CameraController {
		if( MyDebug.LOG )
			Log.d(TAG, "convertFocusModeToValue: " + focus_mode);
		String focus_value = "";
		if( focus_mode == CaptureRequest.CONTROL_AF_MODE_AUTO ) {
		switch (focus_mode) {
			case CaptureRequest.CONTROL_AF_MODE_AUTO:
				focus_value = "focus_mode_auto";
    	}
		else if( focus_mode == CaptureRequest.CONTROL_AF_MODE_MACRO ) {
				break;
			case CaptureRequest.CONTROL_AF_MODE_MACRO:
				focus_value = "focus_mode_macro";
    	}
		else if( focus_mode == CaptureRequest.CONTROL_AF_MODE_EDOF ) {
				break;
			case CaptureRequest.CONTROL_AF_MODE_EDOF:
				focus_value = "focus_mode_edof";
    	}
		else if( focus_mode == CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE ) {
				break;
			case CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE:
				focus_value = "focus_mode_continuous_picture";
    	}
		else if( focus_mode == CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_VIDEO ) {
				break;
			case CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_VIDEO:
				focus_value = "focus_mode_continuous_video";
    	}
		else if( focus_mode == CaptureRequest.CONTROL_AF_MODE_OFF ) {
				break;
			case CaptureRequest.CONTROL_AF_MODE_OFF:
				focus_value = "focus_mode_manual2"; // n.b., could be infinity
				break;
		}
    	return focus_value;
	}
+14 −8
Original line number Diff line number Diff line
@@ -69,14 +69,20 @@ public class CameraControllerManager2 extends CameraControllerManager {
	static boolean isHardwareLevelSupported(CameraCharacteristics c, int requiredLevel) {
		int deviceLevel = c.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
		if( MyDebug.LOG ) {
			if( deviceLevel == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY )
			switch (deviceLevel) {
				case CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY:
					Log.d(TAG, "Camera has LEGACY Camera2 support");
			else if( deviceLevel == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED )
					break;
				case CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED:
					Log.d(TAG, "Camera has LIMITED Camera2 support");
			else if( deviceLevel == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL )
					break;
				case CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL:
					Log.d(TAG, "Camera has FULL Camera2 support");
			else
					break;
				default:
					Log.d(TAG, "Camera has unknown Camera2 support: " + deviceLevel);
					break;
			}
		}
		if (deviceLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) {
			return requiredLevel == deviceLevel;
Loading