diff options
Diffstat (limited to 'camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java')
-rw-r--r-- | camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java b/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java index d0600e8..ccd980a 100644 --- a/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java +++ b/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java @@ -38,6 +38,7 @@ public abstract class CameraSettings { protected final Map<String, String> mGeneralSetting = new TreeMap<>(); protected final List<Camera.Area> mMeteringAreas = new ArrayList<>(); protected final List<Camera.Area> mFocusAreas = new ArrayList<>(); + protected boolean mSizesLocked; protected int mPreviewFpsRangeMin; protected int mPreviewFpsRangeMax; protected int mPreviewFrameRate; @@ -57,7 +58,7 @@ public abstract class CameraSettings { protected boolean mAutoWhiteBalanceLocked; protected boolean mRecordingHintEnabled; protected GpsData mGpsData; - protected Size mExifThumbnailSize = new Size(0,0); + protected Size mExifThumbnailSize; /** * An immutable class storing GPS related information. @@ -116,6 +117,7 @@ public abstract class CameraSettings { mGeneralSetting.putAll(src.mGeneralSetting); mMeteringAreas.addAll(src.mMeteringAreas); mFocusAreas.addAll(src.mFocusAreas); + mSizesLocked = src.mSizesLocked; mPreviewFpsRangeMin = src.mPreviewFpsRangeMin; mPreviewFpsRangeMax = src.mPreviewFpsRangeMax; mPreviewFrameRate = src.mPreviewFrameRate; @@ -151,6 +153,19 @@ public abstract class CameraSettings { mGeneralSetting.put(key, value); } + /** + * Changes whether classes outside this class are allowed to set the preview + * and photo capture sizes. + * + * @param locked Whether to prevent changes to these fields. + * + * @see #setPhotoSize + * @see #setPreviewSize + */ + /*package*/ void setSizesLocked(boolean locked) { + mSizesLocked = locked; + } + /** Preview **/ /** @@ -212,9 +227,16 @@ public abstract class CameraSettings { /** * @param previewSize The size to use for preview. + * @return Whether the operation was allowed (i.e. the sizes are unlocked). */ - public void setPreviewSize(Size previewSize) { + public boolean setPreviewSize(Size previewSize) { + if (mSizesLocked) { + Log.w(TAG, "Attempt to change preview size while locked"); + return false; + } + mCurrentPreviewSize = new Size(previewSize); + return true; } /** @@ -245,12 +267,17 @@ public abstract class CameraSettings { } /** - * Sets the size for the photo. - * - * @param photoSize The photo size. + * @param photoSize The size to use for preview. + * @return Whether the operation was allowed (i.e. the sizes are unlocked). */ - public void setPhotoSize(Size photoSize) { + public boolean setPhotoSize(Size photoSize) { + if (mSizesLocked) { + Log.w(TAG, "Attempt to change photo size while locked"); + return false; + } + mCurrentPhotoSize = new Size(photoSize); + return true; } /** @@ -464,20 +491,22 @@ public abstract class CameraSettings { } /** - * Sets the size of the thumbnail in EXIF header. + * Sets the size of the thumbnail in EXIF header. To suppress thumbnail + * generation, set a size of (0,0). * - * @param s The size for the thumbnail. {@code null} will clear the size to - * (0,0). + * @param s The size for the thumbnail. If {@code null}, agent will not + * set a thumbnail size. */ public void setExifThumbnailSize(Size s) { - if (s != null) { - mExifThumbnailSize = s; - } else { - mExifThumbnailSize = new Size(0,0); - } + mExifThumbnailSize = s; } + /** + * Gets the size of the thumbnail in EXIF header. + * + * @return desired thumbnail size, or null if no size was set + */ public Size getExifThumbnailSize() { - return new Size(mExifThumbnailSize); + return (mExifThumbnailSize == null) ? null : new Size(mExifThumbnailSize); } } |