summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-05-17 16:26:44 +0800
committerWu-cheng Li <wuchengli@google.com>2011-05-17 17:53:52 +0800
commit1c24f5161cfc6a78e45da5f564626d06f6278f7c (patch)
tree2da48db0672a27b5954a6e54ebf0f91bde20f01d /src/com
parent8ab2b624d51b3b8254ece98c46a7e22a6fb5d4aa (diff)
downloadLegacyCamera-1c24f5161cfc6a78e45da5f564626d06f6278f7c.zip
LegacyCamera-1c24f5161cfc6a78e45da5f564626d06f6278f7c.tar.gz
LegacyCamera-1c24f5161cfc6a78e45da5f564626d06f6278f7c.tar.bz2
Show review image before share.
bug:4391419 Change-Id: Id357539bfe36eb3a30742dc4f8ca267ff53ff8b7
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/Camera.java21
-rw-r--r--src/com/android/camera/Thumbnail.java9
-rw-r--r--src/com/android/camera/VideoCamera.java42
3 files changed, 47 insertions, 25 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index ae522ef..bfe6963 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -78,6 +78,7 @@ import android.view.Window;
import android.view.WindowManager;
import android.view.MenuItem.OnMenuItemClickListener;
import android.widget.Button;
+import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;
@@ -155,7 +156,6 @@ public class Camera extends ActivityBase implements View.OnClickListener,
private android.hardware.Camera mCameraDevice;
private ContentProviderClient mMediaProviderClient;
- private SurfaceView mSurfaceView;
private SurfaceHolder mSurfaceHolder = null;
private ShutterButton mShutterButton;
private ToneGenerator mFocusToneGenerator;
@@ -176,6 +176,9 @@ public class Camera extends ActivityBase implements View.OnClickListener,
// The bitmap of the last captured picture thumbnail and the URI of the
// original picture.
private Thumbnail mThumbnail;
+ // An review image having same size as preview. It is displayed when
+ // share button is pressed.
+ private ImageView mReviewImage;
// mCropValue and mSaveUri are used only if isImageCaptureIntent() is true.
private String mCropValue;
@@ -858,7 +861,11 @@ public class Camera extends ActivityBase implements View.OnClickListener,
Uri uri = Storage.addImage(mContentResolver, title, dateTaken,
loc, orientation, data);
if (uri != null) {
- mThumbnail = Thumbnail.createThumbnail(data, orientation, uri);
+ // Create a thumbnail whose size is smaller than half of the surface view.
+ int ratio = (int) Math.ceil((double) mParameters.getPictureSize().width
+ / (mPreviewFrame.getWidth() / 2));
+ int inSampleSize = Util.nextPowerOf2(ratio);
+ mThumbnail = Thumbnail.createThumbnail(data, orientation, inSampleSize, uri);
if (mThumbnail != null) {
mThumbnailButton.setBitmap(mThumbnail.getBitmap());
}
@@ -973,9 +980,9 @@ public class Camera extends ActivityBase implements View.OnClickListener,
} else {
setContentView(R.layout.camera);
}
- mSurfaceView = (SurfaceView) findViewById(R.id.camera_preview);
mFocusRectangle = (FocusRectangle) findViewById(R.id.focus_rectangle);
mThumbnailButton = (RotateImageView) findViewById(R.id.review_thumbnail);
+ mReviewImage = (ImageView) findViewById(R.id.review_image);
mPreferences = new ComboPreferences(this);
CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal());
@@ -1020,7 +1027,8 @@ public class Camera extends ActivityBase implements View.OnClickListener,
// don't set mSurfaceHolder here. We have it set ONLY within
// surfaceChanged / surfaceDestroyed, other parts of the code
// assume that when it is set, the surface is also set.
- SurfaceHolder holder = mSurfaceView.getHolder();
+ SurfaceView preview = (SurfaceView) findViewById(R.id.camera_preview);
+ SurfaceHolder holder = preview.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
@@ -1458,6 +1466,8 @@ public class Camera extends ActivityBase implements View.OnClickListener,
mJpegPictureCallbackTime = 0;
mZoomValue = 0;
+ mReviewImage.setVisibility(View.GONE);
+
// Start the preview if it is not started.
if (mCameraState == PREVIEW_STOPPED && !mStartPreviewFail) {
resetExposureCompensation();
@@ -2437,6 +2447,9 @@ public class Camera extends ActivityBase implements View.OnClickListener,
// Share the last captured picture.
if (mThumbnail != null) {
+ mReviewImage.setImageBitmap(mThumbnail.getBitmap());
+ mReviewImage.setVisibility(View.VISIBLE);
+
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, mThumbnail.getUri());
diff --git a/src/com/android/camera/Thumbnail.java b/src/com/android/camera/Thumbnail.java
index cc9290c..8479c49 100644
--- a/src/com/android/camera/Thumbnail.java
+++ b/src/com/android/camera/Thumbnail.java
@@ -143,7 +143,7 @@ class Thumbnail {
long id = cursor.getLong(0);
int orientation = cursor.getInt(1);
Bitmap bitmap = Images.Thumbnails.getThumbnail(resolver, id,
- Images.Thumbnails.MICRO_KIND, null);
+ Images.Thumbnails.MINI_KIND, null);
Uri uri = ContentUris.withAppendedId(baseUri, id);
// Ensure there's no OOM. Ensure database and storage are in sync.
if (bitmap != null && Util.isUriValid(uri, resolver)) {
@@ -172,7 +172,7 @@ class Thumbnail {
if (cursor != null && cursor.moveToFirst()) {
long id = cursor.getLong(0);
Bitmap bitmap = Video.Thumbnails.getThumbnail(resolver, id,
- Video.Thumbnails.MICRO_KIND, null);
+ Video.Thumbnails.MINI_KIND, null);
Uri uri = ContentUris.withAppendedId(baseUri, id);
// Ensure there's no OOM. Ensure database and storage are in sync.
if (bitmap != null && Util.isUriValid(uri, resolver)) {
@@ -187,10 +187,11 @@ class Thumbnail {
return null;
}
- public static Thumbnail createThumbnail(byte[] jpeg, int orientation, Uri uri) {
+ public static Thumbnail createThumbnail(byte[] jpeg, int orientation, int inSampleSize,
+ Uri uri) {
// Create the thumbnail.
BitmapFactory.Options options = new BitmapFactory.Options();
- options.inSampleSize = 16;
+ options.inSampleSize = inSampleSize;
Bitmap bitmap = BitmapFactory.decodeByteArray(jpeg, 0, jpeg.length, options);
if (bitmap == null) {
Log.e(TAG, "Failed to create thumbnail");
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index bf8f864..c1cc152 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -138,9 +138,7 @@ public class VideoCamera extends ActivityBase
private PreferenceGroup mPreferenceGroup;
private PreviewFrameLayout mPreviewFrameLayout;
- private SurfaceView mVideoPreview;
private SurfaceHolder mSurfaceHolder = null;
- private ImageView mVideoFrame;
private GLRootView mGLRootView;
// xlarge devices use indicator wheel. Other devices use head-up display.
private CamcorderHeadUpDisplay mHeadUpDisplay;
@@ -156,6 +154,9 @@ public class VideoCamera extends ActivityBase
// The bitmap of the last captured video thumbnail and the URI of the
// original video.
private Thumbnail mThumbnail;
+ // An review image having same size as preview. It is displayed when
+ // recording is stopped in capture intent or share button is pressed.
+ private ImageView mReviewImage;
private ShutterButton mShutterButton;
private TextView mRecordingTimeView;
private SwitcherSet mSwitcher;
@@ -398,13 +399,13 @@ public class VideoCamera extends ActivityBase
findViewById(R.id.frame_layout);
mPreviewFrameLayout.setOnSizeChangedListener(this);
- mVideoPreview = (SurfaceView) findViewById(R.id.camera_preview);
- mVideoFrame = (ImageView) findViewById(R.id.video_frame);
+ mReviewImage = (ImageView) findViewById(R.id.review_image);
// don't set mSurfaceHolder here. We have it set ONLY within
// surfaceCreated / surfaceDestroyed, other parts of the code
// assume that when it is set, the surface is also set.
- SurfaceHolder holder = mVideoPreview.getHolder();
+ SurfaceView preview = (SurfaceView) findViewById(R.id.camera_preview);
+ SurfaceHolder holder = preview.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
@@ -833,6 +834,8 @@ public class VideoCamera extends ActivityBase
super.onResume();
mPausing = false;
+ mReviewImage.setVisibility(View.GONE);
+
// Start orientation listener as soon as possible because it takes
// some time to get first orientation.
mOrientationListener.enable();
@@ -1480,18 +1483,20 @@ public class VideoCamera extends ActivityBase
fadeOut(findViewById(R.id.shutter_button));
}
if (mCurrentVideoFilename != null) {
- Bitmap src = ThumbnailUtils.createVideoThumbnail(
+ Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(
mCurrentVideoFilename, Video.Thumbnails.MINI_KIND);
- // MetadataRetriever already rotates the thumbnail. We should rotate
- // it back (and mirror if it is front-facing camera).
- CameraInfo[] info = CameraHolder.instance().getCameraInfo();
- if (info[mCameraId].facing == CameraInfo.CAMERA_FACING_BACK) {
- src = Util.rotateAndMirror(src, -mOrientationHint, false);
- } else {
- src = Util.rotateAndMirror(src, -mOrientationHint, true);
+ if (bitmap != null) {
+ // MetadataRetriever already rotates the thumbnail. We should rotate
+ // it back (and mirror if it is front-facing camera).
+ CameraInfo[] info = CameraHolder.instance().getCameraInfo();
+ if (info[mCameraId].facing == CameraInfo.CAMERA_FACING_BACK) {
+ bitmap = Util.rotateAndMirror(bitmap, -mOrientationHint, false);
+ } else {
+ bitmap = Util.rotateAndMirror(bitmap, -mOrientationHint, true);
+ }
+ mReviewImage.setImageBitmap(bitmap);
+ mReviewImage.setVisibility(View.VISIBLE);
}
- mVideoFrame.setImageBitmap(src);
- mVideoFrame.setVisibility(View.VISIBLE);
}
int[] pickIds = {R.id.btn_retake, R.id.btn_done, R.id.btn_play};
for (int id : pickIds) {
@@ -1506,7 +1511,7 @@ public class VideoCamera extends ActivityBase
}
private void hideAlert() {
- mVideoFrame.setVisibility(View.INVISIBLE);
+ mReviewImage.setVisibility(View.INVISIBLE);
fadeIn(findViewById(R.id.shutter_button));
mShutterButton.setEnabled(true);
enableCameraControls(true);
@@ -1542,7 +1547,7 @@ public class VideoCamera extends ActivityBase
}
private boolean isAlertVisible() {
- return this.mVideoFrame.getVisibility() == View.VISIBLE;
+ return this.mReviewImage.getVisibility() == View.VISIBLE;
}
private void stopVideoRecording() {
@@ -1894,6 +1899,9 @@ public class VideoCamera extends ActivityBase
// Share the last captured video.
if (mThumbnail != null) {
+ mReviewImage.setImageBitmap(mThumbnail.getBitmap());
+ mReviewImage.setVisibility(View.VISIBLE);
+
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("video/*");
intent.putExtra(Intent.EXTRA_STREAM, mThumbnail.getUri());