From 2a7f44cac888de5683d05bef5708f846ee950f43 Mon Sep 17 00:00:00 2001 From: Doris Liu Date: Mon, 12 Aug 2013 15:18:53 -0700 Subject: Fix video capture intent handling Bug: 10296343 Change-Id: I55fb6c71b59a1559ebb58c65e71d510379367435 --- src/com/android/camera/VideoModule.java | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'src/com/android/camera/VideoModule.java') diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index 90915334e..b28b66ffd 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -198,6 +198,8 @@ public class VideoModule implements CameraModule, @Override public void onMediaSaved(Uri uri) { if (uri != null) { + mCurrentVideoUri = uri; + onVideoSaved(); mActivity.notifyNewMedia(uri); } } @@ -550,6 +552,12 @@ public class VideoModule implements CameraModule, } } + public void onVideoSaved() { + if (mIsVideoCaptureIntent) { + showCaptureResult(); + } + } + public void onProtectiveCurtainClick(View v) { // Consume clicks } @@ -1488,9 +1496,15 @@ public class VideoModule implements CameraModule, if (mVideoFileDescriptor != null) { bitmap = Thumbnail.createVideoThumbnailBitmap(mVideoFileDescriptor.getFileDescriptor(), mDesiredPreviewWidth); - } else if (mCurrentVideoFilename != null) { - bitmap = Thumbnail.createVideoThumbnailBitmap(mCurrentVideoFilename, - mDesiredPreviewWidth); + } else if (mCurrentVideoUri != null) { + try { + mVideoFileDescriptor = mContentResolver.openFileDescriptor(mCurrentVideoUri, "r"); + bitmap = Thumbnail.createVideoThumbnailBitmap( + mVideoFileDescriptor.getFileDescriptor(), mDesiredPreviewWidth); + } catch (java.io.FileNotFoundException ex) { + // invalid uri + Log.e(TAG, ex.toString()); + } } if (bitmap != null) { // MetadataRetriever already rotates the thumbnail. We should rotate @@ -1524,7 +1538,9 @@ public class VideoModule implements CameraModule, private boolean stopVideoRecording() { Log.v(TAG, "stopVideoRecording"); mUI.setSwipingEnabled(true); - mUI.showSwitcher(); + if (!isVideoCaptureIntent()) { + mUI.showSwitcher(); + } boolean fail = false; if (mMediaRecorderRecording) { @@ -1580,8 +1596,13 @@ public class VideoModule implements CameraModule, // reflect the device orientation as video recording is stopped. mUI.setOrientationIndicator(0, true); keepScreenOnAwhile(); - if (shouldAddToMediaStoreNow) { - saveVideo(); + if (shouldAddToMediaStoreNow && !fail) { + if (mVideoFileDescriptor == null) { + saveVideo(); + } else if (mIsVideoCaptureIntent) { + // if no file save is needed, we can show the post capture UI now + showCaptureResult(); + } } } // always release media recorder if no effects running -- cgit v1.2.3