diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/com/android/camera/Camera.java | 17 | ||||
| -rw-r--r-- | src/com/android/camera/PreviewFrameLayout.java | 72 | ||||
| -rw-r--r-- | src/com/android/camera/Util.java | 13 | ||||
| -rw-r--r-- | src/com/android/camera/VideoCamera.java | 24 | ||||
| -rw-r--r-- | src/com/android/camera/panorama/PanoramaActivity.java | 13 | ||||
| -rw-r--r-- | src/com/android/camera/ui/IndicatorButton.java | 2 | ||||
| -rw-r--r-- | src/com/android/camera/ui/OtherSettingIndicatorButton.java | 2 | ||||
| -rw-r--r-- | src/com/android/camera/ui/SecondLevelIndicatorControlBar.java | 6 |
8 files changed, 79 insertions, 70 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 7db1dd1..ffd2137 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -141,6 +141,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, private boolean mOpenCameraFail = false; private boolean mCameraDisabled = false; + private View mPreviewPanel; // The container of PreviewFrameLayout. private PreviewFrameLayout mPreviewFrameLayout; private View mPreviewFrame; // Preview frame area. @@ -1250,7 +1251,6 @@ public class Camera extends ActivityBase implements FocusManager.Listener, mThumbnail.saveTo(new File(getFilesDir(), Thumbnail.LAST_THUMB_FILENAME)); } } - hidePostCaptureAlert(); } if (mDidRegister) { @@ -1325,7 +1325,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener, // Preview area is touched. Handle touch focus. @Override public boolean onTouch(View v, MotionEvent e) { - if (mPausing || !mFirstTimeInitialized || mCameraState == SNAPSHOT_IN_PROGRESS) { + if (mPausing || mCameraDevice == null || !mFirstTimeInitialized + || mCameraState == SNAPSHOT_IN_PROGRESS) { return false; } @@ -1588,7 +1589,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener, // Set the preview frame aspect ratio according to the picture size. Size size = mParameters.getPictureSize(); - mPreviewFrameLayout = (PreviewFrameLayout) findViewById(R.id.frame_layout); + mPreviewPanel = findViewById(R.id.frame_layout); + mPreviewFrameLayout = (PreviewFrameLayout) findViewById(R.id.frame); mPreviewFrameLayout.setAspectRatio((double) size.width / size.height); // Set a preview size that is closest to the viewfinder height and has @@ -1750,8 +1752,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener, private void showPostCaptureAlert() { if (mIsImageCaptureIntent) { - mShutterButton.setVisibility(View.GONE); - mIndicatorControlContainer.setVisibility(View.GONE); + Util.fadeOut(mIndicatorControlContainer); + Util.fadeOut(mShutterButton); int[] pickIds = {R.id.btn_retake, R.id.btn_done}; for (int id : pickIds) { @@ -1766,7 +1768,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, int[] pickIds = {R.id.btn_retake, R.id.btn_done}; for (int id : pickIds) { - (findViewById(id)).setVisibility(View.GONE); + Util.fadeOut(findViewById(id)); } Util.fadeIn(mShutterButton); @@ -1936,8 +1938,9 @@ public class Camera extends ActivityBase implements FocusManager.Listener, private void showSharePopup() { Uri uri = mThumbnail.getUri(); if (mSharePopup == null || !uri.equals(mSharePopup.getUri())) { + // SharePopup window takes the mPreviewPanel as its size reference. mSharePopup = new SharePopup(this, uri, mThumbnail.getBitmap(), - mOrientationCompensation, mPreviewFrameLayout); + mOrientationCompensation, mPreviewPanel); } mSharePopup.showAtLocation(mThumbnailView, Gravity.NO_GRAVITY, 0, 0); } diff --git a/src/com/android/camera/PreviewFrameLayout.java b/src/com/android/camera/PreviewFrameLayout.java index d19ff6d..5d31e2b 100644 --- a/src/com/android/camera/PreviewFrameLayout.java +++ b/src/com/android/camera/PreviewFrameLayout.java @@ -16,13 +16,12 @@ package com.android.camera; -import android.app.Activity; +import com.android.camera.R; + import android.content.Context; +import android.graphics.Rect; import android.util.AttributeSet; -import android.util.DisplayMetrics; -import android.view.View; import android.widget.RelativeLayout; - /** * A layout which handles the preview aspect ratio. */ @@ -33,69 +32,48 @@ public class PreviewFrameLayout extends RelativeLayout { } private double mAspectRatio = 4.0 / 3.0; - private View mFrame; - private View mPreviewBorder; - private final DisplayMetrics mMetrics = new DisplayMetrics(); public PreviewFrameLayout(Context context, AttributeSet attrs) { super(context, attrs); - ((Activity) context).getWindowManager() - .getDefaultDisplay().getMetrics(mMetrics); - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - mFrame = (View) findViewById(R.id.frame); - mPreviewBorder = (View) findViewById(R.id.preview_border); } public void setAspectRatio(double ratio) { if (ratio <= 0.0) throw new IllegalArgumentException(); - if (mAspectRatio != ratio) { mAspectRatio = ratio; requestLayout(); } } + public void showBorder(boolean enabled) { + setActivated(enabled); + } + + @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - // Calculate the width and the height of preview frame. - int frameWidth = getWidth(); - int frameHeight = getHeight(); - int hPadding = 0; - int vPadding = 0; - if (mPreviewBorder != null) { - hPadding = mPreviewBorder.getPaddingLeft() + mPreviewBorder.getPaddingRight(); - vPadding = mPreviewBorder.getPaddingBottom() + mPreviewBorder.getPaddingTop(); - } - int previewHeight = frameHeight - vPadding; - int previewWidth = frameWidth - hPadding; + protected void onMeasure(int widthSpec, int heightSpec) { + int previewWidth = MeasureSpec.getSize(widthSpec); + int previewHeight = MeasureSpec.getSize(heightSpec); + + // Get the padding of the border background. + int hPadding = mPaddingLeft + mPaddingRight; + int vPadding = mPaddingTop + mPaddingBottom; + + // Resize the preview frame with correct aspect ratio. + previewWidth -= hPadding; + previewHeight -= vPadding; if (previewWidth > previewHeight * mAspectRatio) { previewWidth = (int) (previewHeight * mAspectRatio + .5); } else { previewHeight = (int) (previewWidth / mAspectRatio + .5); } - // Measure and layout preview frame. - int hSpace = ((r - l) - previewWidth) / 2; - int vSpace = ((b - t) - previewHeight) / 2; - mFrame.measure( - MeasureSpec.makeMeasureSpec(previewWidth, MeasureSpec.EXACTLY), - MeasureSpec.makeMeasureSpec(previewHeight, MeasureSpec.EXACTLY)); - mFrame.layout(hSpace, vSpace, frameWidth + hSpace, frameHeight + vSpace); + // Add the padding of the border. + previewWidth += hPadding; + previewHeight += vPadding; - // Measure and layout the border of preview frame. - if (mPreviewBorder != null) { - frameWidth = previewWidth + hPadding; - frameHeight = previewHeight + vPadding; - hSpace = ((r - l) - frameWidth) / 2; - vSpace = ((b - t) - frameHeight) / 2; - mPreviewBorder.measure( - MeasureSpec.makeMeasureSpec(frameWidth, MeasureSpec.EXACTLY), - MeasureSpec.makeMeasureSpec(frameHeight, MeasureSpec.EXACTLY)); - mPreviewBorder.layout(hSpace, vSpace, frameWidth + hSpace, frameHeight + vSpace); - } + // Ask children to follow the new preview dimension. + super.onMeasure(MeasureSpec.makeMeasureSpec(previewWidth, MeasureSpec.EXACTLY), + MeasureSpec.makeMeasureSpec(previewHeight, MeasureSpec.EXACTLY)); } } diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java index 24ae1b7..c5bc79d 100644 --- a/src/com/android/camera/Util.java +++ b/src/com/android/camera/Util.java @@ -524,10 +524,21 @@ public class Util { } public static void fadeIn(View view) { + if (view.getVisibility() == View.VISIBLE) return; + view.setVisibility(View.VISIBLE); Animation animation = new AlphaAnimation(0F, 1F); - animation.setDuration(500); + animation.setDuration(400); + view.startAnimation(animation); + } + + public static void fadeOut(View view) { + if (view.getVisibility() != View.VISIBLE) return; + + Animation animation = new AlphaAnimation(1F, 0F); + animation.setDuration(400); view.startAnimation(animation); + view.setVisibility(View.GONE); } public static void setRotationParameter(Parameters parameters, int cameraId, int orientation) { diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 8eb12b4..5c3e160 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -139,6 +139,7 @@ public class VideoCamera extends ActivityBase private ComboPreferences mPreferences; private PreferenceGroup mPreferenceGroup; + private View mPreviewPanel; // The container of PreviewFrameLayout. private PreviewFrameLayout mPreviewFrameLayout; private SurfaceHolder mSurfaceHolder = null; private IndicatorControlContainer mIndicatorControlContainer; @@ -207,7 +208,6 @@ public class VideoCamera extends ActivityBase // Default 0. If it is larger than 0, the camcorder is in time lapse mode. private int mTimeBetweenTimeLapseFrameCaptureMs = 0; private View mTimeLapseLabel; - private View mPreviewBorder; private int mDesiredPreviewWidth; private int mDesiredPreviewHeight; @@ -388,8 +388,8 @@ public class VideoCamera extends ActivityBase mModePicker.setOnModeChangeListener(this); } - mPreviewFrameLayout = (PreviewFrameLayout) - findViewById(R.id.frame_layout); + mPreviewPanel = findViewById(R.id.frame_layout); + mPreviewFrameLayout = (PreviewFrameLayout) findViewById(R.id.frame); mReviewImage = (ImageView) findViewById(R.id.review_image); // don't set mSurfaceHolder here. We have it set ONLY within @@ -410,7 +410,6 @@ public class VideoCamera extends ActivityBase mRecordingTimeView = (TextView) findViewById(R.id.recording_time); mOrientationListener = new MyOrientationEventListener(VideoCamera.this); mTimeLapseLabel = findViewById(R.id.time_lapse_label); - mPreviewBorder = findViewById(R.id.preview_border); mBgLearningMessage = (TextView) findViewById(R.id.bg_replace_message); @@ -437,7 +436,6 @@ public class VideoCamera extends ActivityBase mBackCameraId = CameraHolder.instance().getBackCameraId(); mFrontCameraId = CameraHolder.instance().getFrontCameraId(); - initializeZoomControl(); initializeIndicatorControl(); } @@ -811,6 +809,10 @@ public class VideoCamera extends ActivityBase return; } } + + // Initializing it here after the preview is started. + initializeZoomControl(); + keepScreenOnAwhile(); // install an intent filter to receive SD card related events. @@ -1582,8 +1584,8 @@ public class VideoCamera extends ActivityBase } } - mShutterButton.setVisibility(View.GONE); - mIndicatorControlContainer.setVisibility(View.GONE); + Util.fadeOut(mShutterButton); + Util.fadeOut(mIndicatorControlContainer); int[] pickIds = {R.id.btn_retake, R.id.btn_done, R.id.btn_play}; for (int id : pickIds) { Util.fadeIn(findViewById(id)); @@ -1597,7 +1599,7 @@ public class VideoCamera extends ActivityBase int[] pickIds = {R.id.btn_retake, R.id.btn_done, R.id.btn_play}; for (int id : pickIds) { - (findViewById(id)).setVisibility(View.GONE); + Util.fadeOut(findViewById(id)); } Util.fadeIn(mShutterButton); Util.fadeIn(mIndicatorControlContainer); @@ -2017,6 +2019,7 @@ public class VideoCamera extends ActivityBase Intent i = new Intent(Intent.ACTION_PICK); i.setDataAndType(Video.Media.EXTERNAL_CONTENT_URI, "video/*"); + i.putExtra(Intent.EXTRA_LOCAL_ONLY, true); startActivityForResult(i, EffectsRecorder.EFFECT_BACKDROPPER); return true; } @@ -2040,7 +2043,7 @@ public class VideoCamera extends ActivityBase Uri uri = mThumbnail.getUri(); if (mSharePopup == null || !uri.equals(mSharePopup.getUri())) { mSharePopup = new SharePopup(this, uri, mThumbnail.getBitmap(), - mOrientationCompensation, mPreviewFrameLayout); + mOrientationCompensation, mPreviewPanel); } mSharePopup.showAtLocation(mThumbnailView, Gravity.NO_GRAVITY, 0, 0); } @@ -2165,13 +2168,12 @@ public class VideoCamera extends ActivityBase private void initializeVideoSnapshot() { if (mParameters.isVideoSnapshotSupported() && !mIsVideoCaptureIntent) { findViewById(R.id.camera_preview).setOnTouchListener(this); - mPreviewBorder.setBackgroundResource(R.drawable.ic_snapshot_border); } } void showVideoSnapshotUI(boolean enabled) { if (mParameters.isVideoSnapshotSupported() && !mIsVideoCaptureIntent) { - mPreviewBorder.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE); + mPreviewFrameLayout.showBorder(enabled); mIndicatorControlContainer.enableZoom(!enabled); mShutterButton.setEnabled(!enabled); } diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java index 397e706..2bb9f6c 100644 --- a/src/com/android/camera/panorama/PanoramaActivity.java +++ b/src/com/android/camera/panorama/PanoramaActivity.java @@ -165,6 +165,10 @@ public class PanoramaActivity extends Activity implements private float[] mTransformMatrix; private float mHorizontalViewAngle; + // Prefer FOCUS_MODE_INFINITY to FOCUS_MODE_CONTINUOUS_VIDEO because of + // getting a better image quality by the former. + private String mTargetFocusMode = Parameters.FOCUS_MODE_INFINITY; + private PanoOrientationEventListener mOrientationEventListener; // The value could be 0, 1, 2, 3 for the 4 different orientations measured in clockwise // respectively. @@ -349,6 +353,15 @@ public class PanoramaActivity extends Activity implements parameters.setPreviewFpsRange(minFps, maxFps); Log.v(TAG, "preview fps: " + minFps + ", " + maxFps); + List<String> supportedFocusModes = parameters.getSupportedFocusModes(); + if (supportedFocusModes.indexOf(mTargetFocusMode) >= 0) { + parameters.setFocusMode(mTargetFocusMode); + } else { + // Use the default focus mode and log a message + Log.w(TAG, "Cannot set the focus mode to " + mTargetFocusMode + + " becuase the mode is not supported."); + } + parameters.setRecordingHint(false); mHorizontalViewAngle = ((mDeviceOrientation % 2) == 0) ? diff --git a/src/com/android/camera/ui/IndicatorButton.java b/src/com/android/camera/ui/IndicatorButton.java index 6685358..880a650 100644 --- a/src/com/android/camera/ui/IndicatorButton.java +++ b/src/com/android/camera/ui/IndicatorButton.java @@ -100,7 +100,7 @@ public class IndicatorButton extends AbstractIndicatorButton implements BasicSet protected void initializePopup() { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( Context.LAYOUT_INFLATER_SERVICE); - ViewGroup root = (ViewGroup) getRootView().findViewById(R.id.frame); + ViewGroup root = (ViewGroup) getRootView().findViewById(R.id.frame_layout); BasicSettingPopup popup = (BasicSettingPopup) inflater.inflate( R.layout.basic_setting_popup, root, false); diff --git a/src/com/android/camera/ui/OtherSettingIndicatorButton.java b/src/com/android/camera/ui/OtherSettingIndicatorButton.java index e020f94..69d627a 100644 --- a/src/com/android/camera/ui/OtherSettingIndicatorButton.java +++ b/src/com/android/camera/ui/OtherSettingIndicatorButton.java @@ -53,7 +53,7 @@ public class OtherSettingIndicatorButton extends AbstractIndicatorButton { protected void initializePopup() { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( Context.LAYOUT_INFLATER_SERVICE); - ViewGroup root = (ViewGroup) getRootView().findViewById(R.id.frame); + ViewGroup root = (ViewGroup) getRootView().findViewById(R.id.frame_layout); OtherSettingsPopup popup = (OtherSettingsPopup) inflater.inflate( R.layout.other_setting_popup, root, false); diff --git a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java index 4b87bdc..670bbb9 100644 --- a/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java +++ b/src/com/android/camera/ui/SecondLevelIndicatorControlBar.java @@ -108,9 +108,11 @@ public class SecondLevelIndicatorControlBar extends IndicatorControl implements int width = right - left; int height = bottom - top; int h = height / count; + + // TODO: follow the redlines of UI design in next change. The icons are + // simply distributed on the bar equally with current implmentation. for (int i = 0; i < count; i++) { - getChildAt(i).layout(0, top + i * height / count, width, - top + i * height / count + h); + getChildAt(i).layout(0, i * h, width, (i + 1) * h); } } |
