summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-09-09 04:37:04 +0800
committerWu-cheng Li <wuchengli@google.com>2011-09-09 05:36:22 +0800
commit6a6cad85e4932ca6b3f00acd6617e9ad1701d13d (patch)
tree8451ec1c2e86ede56d5f3965615e536cbd5b7de9
parent4d08a6cda05212e7861b75845f999e1e979e3c5f (diff)
downloadLegacyCamera-6a6cad85e4932ca6b3f00acd6617e9ad1701d13d.zip
LegacyCamera-6a6cad85e4932ca6b3f00acd6617e9ad1701d13d.tar.gz
LegacyCamera-6a6cad85e4932ca6b3f00acd6617e9ad1701d13d.tar.bz2
Put a red border around the viewfinder during video snapshot.
Also remove the viewfinder border in all other cases. bug:5187868 Change-Id: I4164fc9b0b62268b80496c71058466e03cbf0aa3
-rw-r--r--res/drawable-hdpi/border_preview.9.pngbin1365 -> 0 bytes
-rw-r--r--res/drawable-hdpi/border_preview_time_lapse.9.pngbin499 -> 0 bytes
-rw-r--r--res/drawable-hdpi/ic_snapshot_border.9.pngbin0 -> 247 bytes
-rwxr-xr-xres/drawable-mdpi/border_preview.9.pngbin312 -> 0 bytes
-rw-r--r--res/drawable-mdpi/border_preview_time_lapse.9.pngbin417 -> 0 bytes
-rw-r--r--res/drawable-mdpi/ic_snapshot_border.9.pngbin0 -> 223 bytes
-rw-r--r--res/drawable-w1024dp-hdpi/border_preview.9.pngbin797 -> 0 bytes
-rw-r--r--res/drawable-w1024dp-hdpi/ic_snapshot_border.9.pngbin0 -> 327 bytes
-rw-r--r--res/drawable-w1024dp-mdpi/border_preview.9.pngbin1720 -> 0 bytes
-rw-r--r--res/drawable-w1024dp-mdpi/ic_snapshot_border.9.pngbin0 -> 299 bytes
-rw-r--r--res/drawable-w1024dp-xhdpi/ic_snapshot_border.9.pngbin0 -> 419 bytes
-rw-r--r--res/drawable-xhdpi/ic_snapshot_border.9.pngbin0 -> 257 bytes
-rw-r--r--res/layout-w1024dp/preview_frame.xml7
-rw-r--r--res/layout-w1024dp/preview_frame_video.xml8
-rw-r--r--res/layout/preview_frame.xml5
-rw-r--r--res/layout/preview_frame_video.xml10
-rw-r--r--src/com/android/camera/Camera.java2
-rw-r--r--src/com/android/camera/PreviewFrameLayout.java35
-rw-r--r--src/com/android/camera/VideoCamera.java30
19 files changed, 47 insertions, 50 deletions
diff --git a/res/drawable-hdpi/border_preview.9.png b/res/drawable-hdpi/border_preview.9.png
deleted file mode 100644
index b5922bf..0000000
--- a/res/drawable-hdpi/border_preview.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/border_preview_time_lapse.9.png b/res/drawable-hdpi/border_preview_time_lapse.9.png
deleted file mode 100644
index 331826d..0000000
--- a/res/drawable-hdpi/border_preview_time_lapse.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_snapshot_border.9.png b/res/drawable-hdpi/ic_snapshot_border.9.png
new file mode 100644
index 0000000..e6baffe
--- /dev/null
+++ b/res/drawable-hdpi/ic_snapshot_border.9.png
Binary files differ
diff --git a/res/drawable-mdpi/border_preview.9.png b/res/drawable-mdpi/border_preview.9.png
deleted file mode 100755
index cb1141f..0000000
--- a/res/drawable-mdpi/border_preview.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/border_preview_time_lapse.9.png b/res/drawable-mdpi/border_preview_time_lapse.9.png
deleted file mode 100644
index 207f44f..0000000
--- a/res/drawable-mdpi/border_preview_time_lapse.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_snapshot_border.9.png b/res/drawable-mdpi/ic_snapshot_border.9.png
new file mode 100644
index 0000000..1fa9978
--- /dev/null
+++ b/res/drawable-mdpi/ic_snapshot_border.9.png
Binary files differ
diff --git a/res/drawable-w1024dp-hdpi/border_preview.9.png b/res/drawable-w1024dp-hdpi/border_preview.9.png
deleted file mode 100644
index bc62d07..0000000
--- a/res/drawable-w1024dp-hdpi/border_preview.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-w1024dp-hdpi/ic_snapshot_border.9.png b/res/drawable-w1024dp-hdpi/ic_snapshot_border.9.png
new file mode 100644
index 0000000..291d36b
--- /dev/null
+++ b/res/drawable-w1024dp-hdpi/ic_snapshot_border.9.png
Binary files differ
diff --git a/res/drawable-w1024dp-mdpi/border_preview.9.png b/res/drawable-w1024dp-mdpi/border_preview.9.png
deleted file mode 100644
index 75031dd..0000000
--- a/res/drawable-w1024dp-mdpi/border_preview.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-w1024dp-mdpi/ic_snapshot_border.9.png b/res/drawable-w1024dp-mdpi/ic_snapshot_border.9.png
new file mode 100644
index 0000000..6b76066
--- /dev/null
+++ b/res/drawable-w1024dp-mdpi/ic_snapshot_border.9.png
Binary files differ
diff --git a/res/drawable-w1024dp-xhdpi/ic_snapshot_border.9.png b/res/drawable-w1024dp-xhdpi/ic_snapshot_border.9.png
new file mode 100644
index 0000000..b4e1332
--- /dev/null
+++ b/res/drawable-w1024dp-xhdpi/ic_snapshot_border.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_snapshot_border.9.png b/res/drawable-xhdpi/ic_snapshot_border.9.png
new file mode 100644
index 0000000..aae096b
--- /dev/null
+++ b/res/drawable-xhdpi/ic_snapshot_border.9.png
Binary files differ
diff --git a/res/layout-w1024dp/preview_frame.xml b/res/layout-w1024dp/preview_frame.xml
index ea57476..762fef5 100644
--- a/res/layout-w1024dp/preview_frame.xml
+++ b/res/layout-w1024dp/preview_frame.xml
@@ -33,11 +33,4 @@
<include layout="@layout/priority_indicators"/>
<include layout="@layout/tap_to_focus_toast"/>
</RelativeLayout>
- <!-- This is the border of preview and the corner is round. If it is the background,
- preview will be on top and the inner corner will be square, which looks bad.
- So this is put in the end of layout to keep corner round. -->
- <ImageView android:id="@+id/preview_border"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/border_preview"/>
</com.android.camera.PreviewFrameLayout>
diff --git a/res/layout-w1024dp/preview_frame_video.xml b/res/layout-w1024dp/preview_frame_video.xml
index 98d9ce2..edd176a 100644
--- a/res/layout-w1024dp/preview_frame_video.xml
+++ b/res/layout-w1024dp/preview_frame_video.xml
@@ -63,11 +63,9 @@
android:visibility="gone"
android:background="@android:color/black"/>
</RelativeLayout>
- <!-- This is the border of preview and the corner is round. If it is the background,
- preview will be on top and the inner corner will be square, which looks bad.
- So this is put in the end of layout to keep corner round. -->
- <ImageView android:id="@+id/preview_border"
+ <!-- Border for video snapshot. -->
+ <View android:id="@+id/preview_border"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@drawable/border_preview"/>
+ android:visibility="gone"/>
</com.android.camera.PreviewFrameLayout>
diff --git a/res/layout/preview_frame.xml b/res/layout/preview_frame.xml
index e8afb12..a8b4d99 100644
--- a/res/layout/preview_frame.xml
+++ b/res/layout/preview_frame.xml
@@ -20,11 +20,6 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="2dp">
- <!-- To be consistent with w1024dp layout, preview border is not inside the preview frame. -->
- <ImageView android:id="@+id/preview_border"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/border_preview"/>
<RelativeLayout android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
diff --git a/res/layout/preview_frame_video.xml b/res/layout/preview_frame_video.xml
index 3dc8299..4164b41 100644
--- a/res/layout/preview_frame_video.xml
+++ b/res/layout/preview_frame_video.xml
@@ -20,11 +20,6 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip">
- <!-- To be consistent with w1024dp layout, preview border is not inside the preview frame. -->
- <ImageView android:id="@+id/preview_border"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/border_preview"/>
<RelativeLayout android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -68,4 +63,9 @@
android:visibility="gone"
android:text="@string/bg_replacement_message" />
</RelativeLayout>
+ <!-- Border for video snapshot. -->
+ <View android:id="@+id/preview_border"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone"/>
</com.android.camera.PreviewFrameLayout>
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 7d8a986..23dd6aa 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -148,7 +148,6 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
private PreviewFrameLayout mPreviewFrameLayout;
private View mPreviewFrame; // Preview frame area.
- private View mPreviewBorder;
// A popup window that contains a bigger thumbnail and a list of apps to share.
private SharePopup mSharePopup;
@@ -376,7 +375,6 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
// Initialize focus UI.
mPreviewFrame = findViewById(R.id.camera_preview);
mPreviewFrame.setOnTouchListener(this);
- mPreviewBorder = findViewById(R.id.preview_border);
mFocusIndicator = (RotateLayout) findViewById(R.id.focus_indicator_rotate_layout);
mFocusManager.initialize(mFocusIndicator, mPreviewFrame, mFaceView, this);
mFocusManager.initializeToneGenerator();
diff --git a/src/com/android/camera/PreviewFrameLayout.java b/src/com/android/camera/PreviewFrameLayout.java
index 75e7c35..d19ff6d 100644
--- a/src/com/android/camera/PreviewFrameLayout.java
+++ b/src/com/android/camera/PreviewFrameLayout.java
@@ -34,7 +34,7 @@ public class PreviewFrameLayout extends RelativeLayout {
private double mAspectRatio = 4.0 / 3.0;
private View mFrame;
- private View mBorderView;
+ private View mPreviewBorder;
private final DisplayMetrics mMetrics = new DisplayMetrics();
public PreviewFrameLayout(Context context, AttributeSet attrs) {
@@ -47,7 +47,7 @@ public class PreviewFrameLayout extends RelativeLayout {
protected void onFinishInflate() {
super.onFinishInflate();
mFrame = (View) findViewById(R.id.frame);
- mBorderView = (View) findViewById(R.id.preview_border);
+ mPreviewBorder = (View) findViewById(R.id.preview_border);
}
public void setAspectRatio(double ratio) {
@@ -64,11 +64,14 @@ public class PreviewFrameLayout extends RelativeLayout {
// Calculate the width and the height of preview frame.
int frameWidth = getWidth();
int frameHeight = getHeight();
- View f = mBorderView;
- int horizontalPadding = f.getPaddingLeft() + f.getPaddingRight();
- int verticalPadding = f.getPaddingBottom() + f.getPaddingTop();
- int previewHeight = frameHeight - verticalPadding;
- int previewWidth = frameWidth - horizontalPadding;
+ 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;
if (previewWidth > previewHeight * mAspectRatio) {
previewWidth = (int) (previewHeight * mAspectRatio + .5);
} else {
@@ -84,13 +87,15 @@ public class PreviewFrameLayout extends RelativeLayout {
mFrame.layout(hSpace, vSpace, frameWidth + hSpace, frameHeight + vSpace);
// Measure and layout the border of preview frame.
- frameWidth = previewWidth + horizontalPadding;
- frameHeight = previewHeight + verticalPadding;
- hSpace = ((r - l) - frameWidth) / 2;
- vSpace = ((b - t) - frameHeight) / 2;
- mBorderView.measure(
- MeasureSpec.makeMeasureSpec(frameWidth, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(frameHeight, MeasureSpec.EXACTLY));
- mBorderView.layout(hSpace, vSpace, frameWidth + hSpace, frameHeight + vSpace);
+ 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);
+ }
}
}
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 6b7fd3b..f0ebe05 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -443,18 +443,14 @@ public class VideoCamera extends ActivityBase
}
showTimeLapseUI(mCaptureTimeLapse);
+ initializeVideoSnapshot();
resizeForPreviewAspectRatio();
mBackCameraId = CameraHolder.instance().getBackCameraId();
mFrontCameraId = CameraHolder.instance().getFrontCameraId();
- // Initialize after startPreview becuase this need mParameters.
initializeZoomControl();
initializeIndicatorControl();
- if ("true".equals(mParameters.get("video-snapshot-supported")) &&
- !mIsVideoCaptureIntent) {
- preview.setOnTouchListener(this);
- }
}
private void loadCameraPreferences() {
@@ -806,6 +802,7 @@ public class VideoCamera extends ActivityBase
mZoomValue = 0;
mReviewImage.setVisibility(View.GONE);
+ showVideoSnapshotUI(false);
// Start orientation listener as soon as possible because it takes
// some time to get first orientation.
@@ -2037,12 +2034,6 @@ public class VideoCamera extends ActivityBase
if (mTimeLapseLabel != null) {
mTimeLapseLabel.setVisibility(enable ? View.VISIBLE : View.GONE);
}
- if (mPreviewBorder != null) {
- mPreviewBorder.setBackgroundResource(enable
- ? R.drawable.border_preview_time_lapse
- : R.drawable.border_preview);
- }
-
}
private void showSharePopup() {
@@ -2171,6 +2162,21 @@ public class VideoCamera extends ActivityBase
}
}
+ private void initializeVideoSnapshot() {
+ if ("true".equals(mParameters.get("video-snapshot-supported")) &&
+ !mIsVideoCaptureIntent) {
+ findViewById(R.id.camera_preview).setOnTouchListener(this);
+ mPreviewBorder.setBackgroundResource(R.drawable.ic_snapshot_border);
+ }
+ }
+
+ void showVideoSnapshotUI(boolean enable) {
+ if ("true".equals(mParameters.get("video-snapshot-supported")) &&
+ !mIsVideoCaptureIntent) {
+ mPreviewBorder.setVisibility(enable ? View.VISIBLE : View.INVISIBLE);
+ }
+ }
+
// Preview area is touched. Take a picture.
@Override
public boolean onTouch(View v, MotionEvent e) {
@@ -2186,6 +2192,7 @@ public class VideoCamera extends ActivityBase
Log.v(TAG, "Video snapshot start");
mCameraDevice.takePicture(null, null, null, new JpegPictureCallback(loc));
+ showVideoSnapshotUI(true);
mSnapshotInProgress = true;
return true;
}
@@ -2201,6 +2208,7 @@ public class VideoCamera extends ActivityBase
public void onPictureTaken(byte [] jpegData, android.hardware.Camera camera) {
Log.v(TAG, "onPictureTaken");
mSnapshotInProgress = false;
+ showVideoSnapshotUI(false);
storeImage(jpegData, mLocation);
}
}