Minor whitespace and comment cleanup.

git-svn-id: https://zxing.googlecode.com/svn/trunk@1968 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
dswitkin@google.com 2011-10-13 19:09:31 +00:00
parent e65b139447
commit a75bc5d021

View file

@ -26,6 +26,10 @@ import android.view.WindowManager;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/**
* A class which deals with reading, parsing, and setting the camera parameters which are used to
* configure the camera hardware.
*/
final class CameraConfigurationManager { final class CameraConfigurationManager {
private static final String TAG = CameraConfigurationManager.class.getSimpleName(); private static final String TAG = CameraConfigurationManager.class.getSimpleName();
@ -91,13 +95,13 @@ final class CameraConfigurationManager {
private static Point getCameraResolution(Camera.Parameters parameters, Point screenResolution) { private static Point getCameraResolution(Camera.Parameters parameters, Point screenResolution) {
String previewSizeValueString = parameters.get("preview-size-values"); String previewSizeValueString = parameters.get("preview-size-values");
// saw this on Xperia
// This string is wrong but was seen on the Sony Xperia.
if (previewSizeValueString == null) { if (previewSizeValueString == null) {
previewSizeValueString = parameters.get("preview-size-value"); previewSizeValueString = parameters.get("preview-size-value");
} }
Point cameraResolution = null; Point cameraResolution = null;
if (previewSizeValueString != null) { if (previewSizeValueString != null) {
Log.d(TAG, "preview-size-values parameter: " + previewSizeValueString); Log.d(TAG, "preview-size-values parameter: " + previewSizeValueString);
cameraResolution = findBestPreviewSizeValue(previewSizeValueString, screenResolution); cameraResolution = findBestPreviewSizeValue(previewSizeValueString, screenResolution);
@ -105,11 +109,8 @@ final class CameraConfigurationManager {
if (cameraResolution == null) { if (cameraResolution == null) {
// Ensure that the camera resolution is a multiple of 8, as the screen may not be. // Ensure that the camera resolution is a multiple of 8, as the screen may not be.
cameraResolution = new Point( cameraResolution = new Point((screenResolution.x >> 3) << 3, (screenResolution.y >> 3) << 3);
(screenResolution.x >> 3) << 3,
(screenResolution.y >> 3) << 3);
} }
return cameraResolution; return cameraResolution;
} }
@ -119,7 +120,6 @@ final class CameraConfigurationManager {
int bestY = 0; int bestY = 0;
int diff = Integer.MAX_VALUE; int diff = Integer.MAX_VALUE;
for (String previewSize : COMMA_PATTERN.split(previewSizeValueString)) { for (String previewSize : COMMA_PATTERN.split(previewSizeValueString)) {
previewSize = previewSize.trim(); previewSize = previewSize.trim();
int dimPosition = previewSize.indexOf('x'); int dimPosition = previewSize.indexOf('x');
if (dimPosition < 0) { if (dimPosition < 0) {
@ -147,7 +147,6 @@ final class CameraConfigurationManager {
bestY = newY; bestY = newY;
diff = newDiff; diff = newDiff;
} }
} }
if (bestX > 0 && bestY > 0) { if (bestX > 0 && bestY > 0) {
@ -193,7 +192,6 @@ final class CameraConfigurationManager {
} }
int tenDesiredZoom = TEN_DESIRED_ZOOM; int tenDesiredZoom = TEN_DESIRED_ZOOM;
String maxZoomString = parameters.get("max-zoom"); String maxZoomString = parameters.get("max-zoom");
if (maxZoomString != null) { if (maxZoomString != null) {
try { try {
@ -236,14 +234,14 @@ final class CameraConfigurationManager {
} }
} }
// Set zoom. This helps encourage the user to pull back. // Sets the zoom which helps encourage the user to pull back.
// Some devices like the Behold have a zoom parameter // Some devices like the Behold have a zoom parameter.
if (maxZoomString != null || motZoomValuesString != null) { if (maxZoomString != null || motZoomValuesString != null) {
parameters.set("zoom", String.valueOf(tenDesiredZoom / 10.0)); parameters.set("zoom", String.valueOf(tenDesiredZoom / 10.0));
} }
// Most devices, like the Hero, appear to expose this zoom parameter. // Most devices, like the Hero, appear to expose this zoom parameter.
// It takes on values like "27" which appears to mean 2.7x zoom // It takes on values like "27" which appears to mean 2.7x zoom.
if (takingPictureZoomMaxString != null) { if (takingPictureZoomMaxString != null) {
parameters.set("taking-picture-zoom", tenDesiredZoom); parameters.set("taking-picture-zoom", tenDesiredZoom);
} }