summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout-xlarge/preview_frame.xml5
-rw-r--r--res/layout-xlarge/preview_frame_video.xml9
-rw-r--r--res/layout/preview_frame.xml5
-rw-r--r--res/layout/preview_frame_video.xml9
-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
7 files changed, 67 insertions, 33 deletions
diff --git a/res/layout-xlarge/preview_frame.xml b/res/layout-xlarge/preview_frame.xml
index bd176da..96f133d 100644
--- a/res/layout-xlarge/preview_frame.xml
+++ b/res/layout-xlarge/preview_frame.xml
@@ -51,6 +51,11 @@
android:visibility="invisible"/>
<include layout="@layout/review_thumbnail"/>
<include layout="@layout/review_control"/>
+ <ImageView android:id="@+id/review_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ 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.
diff --git a/res/layout-xlarge/preview_frame_video.xml b/res/layout-xlarge/preview_frame_video.xml
index ce97ee6..e8edb41 100644
--- a/res/layout-xlarge/preview_frame_video.xml
+++ b/res/layout-xlarge/preview_frame_video.xml
@@ -27,10 +27,6 @@
<SurfaceView android:id="@+id/camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
- <ImageView android:id="@+id/video_frame"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone" />
<include layout="@layout/review_thumbnail"/>
<TextView android:id="@+id/recording_time"
style="@style/OnViewfinderLabel"
@@ -60,6 +56,11 @@
android:paddingBottom="10dp"
android:src="@drawable/btn_ic_review_play"/>
</LinearLayout>
+ <ImageView android:id="@+id/review_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ 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.
diff --git a/res/layout/preview_frame.xml b/res/layout/preview_frame.xml
index 0459919..904ef20 100644
--- a/res/layout/preview_frame.xml
+++ b/res/layout/preview_frame.xml
@@ -35,5 +35,10 @@
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_centerInParent="true"/>
+ <ImageView android:id="@+id/review_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone"
+ android:background="@android:color/black"/>
</RelativeLayout>
</com.android.camera.PreviewFrameLayout>
diff --git a/res/layout/preview_frame_video.xml b/res/layout/preview_frame_video.xml
index 1088b94..ec0dbb5 100644
--- a/res/layout/preview_frame_video.xml
+++ b/res/layout/preview_frame_video.xml
@@ -30,10 +30,6 @@
<SurfaceView android:id="@+id/camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
- <ImageView android:id="@+id/video_frame"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone" />
<!-- Note: In this TextView the paddingRight="2"
attribute is required because otherwise the
text's drop shadow will be clipped. -->
@@ -48,5 +44,10 @@
android:layout_marginLeft="17dp"
android:paddingRight="2dp"
android:visibility="gone" />
+ <ImageView android:id="@+id/review_image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone"
+ android:background="@android:color/black" />
</RelativeLayout>
</com.android.camera.PreviewFrameLayout>
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());