From 36e56fba281292255a01ee00b4bee067fa09ab59 Mon Sep 17 00:00:00 2001 From: Doris Liu Date: Wed, 11 Sep 2013 17:38:08 -0700 Subject: Show captured image rather than frozen preview for capture intent Bug: 10570887 Change-Id: Ie986c865bdf452973b833efcdcb397c27bef2420 --- src/com/android/camera/PhotoModule.java | 6 +++--- src/com/android/camera/PhotoUI.java | 31 ++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'src/com') diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index 789446dcd..d00da1935 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -722,11 +722,11 @@ public class PhotoModule } } + ExifInterface exif = Exif.getExif(jpegData); + int orientation = Exif.getOrientation(exif); if (!mIsImageCaptureIntent) { // Calculate the width and the height of the jpeg. Size s = mParameters.getPictureSize(); - ExifInterface exif = Exif.getExif(jpegData); - int orientation = Exif.getOrientation(exif); int width, height; if ((mJpegRotation + orientation) % 180 == 0) { width = s.width; @@ -761,7 +761,7 @@ public class PhotoModule } else { mJpegImageData = jpegData; if (!mQuickCapture) { - mUI.showPostCaptureAlert(); + mUI.showCapturedImageForReview(jpegData, orientation, mMirror); } else { onCaptureDone(); } diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java index de555485c..41847ed1c 100644 --- a/src/com/android/camera/PhotoUI.java +++ b/src/com/android/camera/PhotoUI.java @@ -85,6 +85,8 @@ public class PhotoUI implements PieListener, private View mReviewCancelButton; private View mReviewDoneButton; private View mReviewRetakeButton; + private ImageView mReviewImage; + private DecodeImageForReview mDecodeTaskForReview = null; private View mMenuButton; private PhotoMenu mMenu; @@ -141,7 +143,7 @@ public class PhotoUI implements PieListener, } }; - private class DecodeTask extends AsyncTask { + private class DecodeTask extends AsyncTask { private final byte [] mData; private int mOrientation; private boolean mMirror; @@ -153,7 +155,7 @@ public class PhotoUI implements PieListener, } @Override - protected Bitmap doInBackground(Integer... params) { + protected Bitmap doInBackground(Void... params) { // Decode image in background. Bitmap bitmap = CameraUtil.downSample(mData, DOWN_SAMPLE_FACTOR); if (mOrientation != 0 || mMirror) { @@ -176,6 +178,22 @@ public class PhotoUI implements PieListener, } } + private class DecodeImageForReview extends DecodeTask { + public DecodeImageForReview(byte[] data, int orientation, boolean mirror) { + super(data, orientation, mirror); + } + + @Override + protected void onPostExecute(Bitmap bitmap) { + if (isCancelled()) { + return; + } + mReviewImage.setImageBitmap(bitmap); + mReviewImage.setVisibility(View.VISIBLE); + mDecodeTaskForReview = null; + } + } + public PhotoUI(CameraActivity activity, PhotoController controller, View parent) { mActivity = activity; mController = controller; @@ -351,6 +369,7 @@ public class PhotoUI implements PieListener, mReviewDoneButton = mRootView.findViewById(R.id.btn_done); mReviewCancelButton = mRootView.findViewById(R.id.btn_cancel); mReviewRetakeButton = mRootView.findViewById(R.id.btn_retake); + mReviewImage = (ImageView) mRootView.findViewById(R.id.review_image); mReviewCancelButton.setVisibility(View.VISIBLE); mReviewDoneButton.setOnClickListener(new OnClickListener() { @@ -598,7 +617,9 @@ public class PhotoUI implements PieListener, return ret; } - protected void showPostCaptureAlert() { + protected void showCapturedImageForReview(byte[] jpegData, int orientation, boolean mirror) { + mDecodeTaskForReview = new DecodeImageForReview(jpegData, orientation, mirror); + mDecodeTaskForReview.execute(); mOnScreenIndicators.setVisibility(View.GONE); mMenuButton.setVisibility(View.GONE); CameraUtil.fadeIn(mReviewDoneButton); @@ -608,6 +629,10 @@ public class PhotoUI implements PieListener, } protected void hidePostCaptureAlert() { + if (mDecodeTaskForReview != null) { + mDecodeTaskForReview.cancel(true); + } + mReviewImage.setVisibility(View.GONE); mOnScreenIndicators.setVisibility(View.VISIBLE); mMenuButton.setVisibility(View.VISIBLE); CameraUtil.fadeOut(mReviewDoneButton); -- cgit v1.2.3