summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera')
-rw-r--r--src/com/android/camera/Camera.java7
-rw-r--r--src/com/android/camera/PreviewFrameLayout.java72
-rw-r--r--src/com/android/camera/VideoCamera.java12
-rw-r--r--src/com/android/camera/ui/IndicatorButton.java2
-rw-r--r--src/com/android/camera/ui/OtherSettingIndicatorButton.java2
-rw-r--r--src/com/android/camera/ui/SecondLevelIndicatorControlBar.java6
6 files changed, 41 insertions, 60 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 8973bac..5a35837 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -145,6 +145,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.
@@ -1605,7 +1606,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
@@ -1953,8 +1955,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/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 8c39f6b..02822cf 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;
@@ -399,8 +399,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
@@ -421,7 +421,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);
@@ -2052,7 +2051,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);
}
@@ -2177,13 +2176,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/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);
}
}