summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoris Liu <tianliu@google.com>2013-08-13 18:26:09 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-08-13 18:26:09 +0000
commit0a08b3a280bf7934d362c94a49e43646c9b3bc4f (patch)
tree4dc305b7ac0c8e2efd3222ced9b84ddef1fb3cb1
parentc27d21bc3b9322936004827ab005fb7d1facfacf (diff)
parent2a7f44cac888de5683d05bef5708f846ee950f43 (diff)
downloadandroid_packages_apps_Snap-0a08b3a280bf7934d362c94a49e43646c9b3bc4f.tar.gz
android_packages_apps_Snap-0a08b3a280bf7934d362c94a49e43646c9b3bc4f.tar.bz2
android_packages_apps_Snap-0a08b3a280bf7934d362c94a49e43646c9b3bc4f.zip
Merge "Fix video capture intent handling" into gb-ub-photos-carlsbad
-rw-r--r--AndroidManifest.xml8
-rw-r--r--res/layout/video_module.xml1
-rw-r--r--src/com/android/camera/CameraActivity.java9
-rw-r--r--src/com/android/camera/VideoModule.java33
-rw-r--r--src/com/android/camera/VideoUI.java18
5 files changed, 54 insertions, 15 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6079b9fb2..b7748dfe3 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -64,6 +64,14 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
+ <action android:name="android.media.action.VIDEO_CAMERA" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.media.action.VIDEO_CAPTURE" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/res/layout/video_module.xml b/res/layout/video_module.xml
index 2df1adc9b..0f4857965 100644
--- a/res/layout/video_module.xml
+++ b/res/layout/video_module.xml
@@ -51,6 +51,7 @@
style="@style/ReviewControlIcon"
android:layout_centerInParent="true"
android:src="@drawable/ic_gallery_play_big"
+ android:scaleType="center"
android:visibility="gone"
android:onClick="onReviewPlayClicked"/>
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 9ffebc2a6..c1b04683a 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -32,6 +32,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
+import android.provider.MediaStore;
import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;
@@ -386,7 +387,13 @@ public class CameraActivity extends Activity
mFilmStripView.setPanoramaViewHelper(mPanoramaViewHelper);
// Set up the camera preview first so the preview shows up ASAP.
mFilmStripView.setListener(mFilmStripListener);
- mCurrentModule = new PhotoModule();
+ if (MediaStore.INTENT_ACTION_VIDEO_CAMERA.equals(getIntent().getAction())
+ || MediaStore.ACTION_VIDEO_CAPTURE.equals(getIntent().getAction())) {
+ mCurrentModule = new VideoModule();
+ mCurrentModuleIndex = CameraSwitcher.VIDEO_MODULE_INDEX;
+ } else {
+ mCurrentModule = new PhotoModule();
+ }
mCurrentModule.init(this, mRootView);
mOrientationListener = new MyOrientationEventListener(this);
mMainHandler = new Handler(getMainLooper());
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
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index 5c7eca214..684179698 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -189,7 +189,7 @@ public class VideoUI implements PieRenderer.PieListener,
}
private void initializeControlByIntent() {
- mMenuButton = mActivity.findViewById(R.id.menu);
+ mMenuButton = mRootView.findViewById(R.id.menu);
mMenuButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@@ -199,9 +199,9 @@ public class VideoUI implements PieRenderer.PieListener,
}
});
- mCameraControls = (CameraControls) mActivity.findViewById(R.id.camera_controls);
+ mCameraControls = (CameraControls) mRootView.findViewById(R.id.camera_controls);
mOnScreenIndicators = new OnScreenIndicators(mActivity,
- mActivity.findViewById(R.id.on_screen_indicators));
+ mRootView.findViewById(R.id.on_screen_indicators));
mOnScreenIndicators.resetToDefault();
if (mController.isVideoCaptureIntent()) {
hideSwitcher();
@@ -210,9 +210,9 @@ public class VideoUI implements PieRenderer.PieListener,
// Cannot use RotateImageView for "done" and "cancel" button because
// the tablet layout uses RotateLayout, which cannot be cast to
// RotateImageView.
- mReviewDoneButton = mActivity.findViewById(R.id.btn_done);
- mReviewCancelButton = mActivity.findViewById(R.id.btn_cancel);
- mReviewPlayButton = mActivity.findViewById(R.id.btn_play);
+ mReviewDoneButton = mRootView.findViewById(R.id.btn_done);
+ mReviewCancelButton = mRootView.findViewById(R.id.btn_cancel);
+ mReviewPlayButton = mRootView.findViewById(R.id.btn_play);
mReviewCancelButton.setVisibility(View.VISIBLE);
mReviewDoneButton.setOnClickListener(new OnClickListener() {
@Override
@@ -414,7 +414,7 @@ public class VideoUI implements PieRenderer.PieListener,
}
mGestures.setRenderOverlay(mRenderOverlay);
- mPreviewThumb = mActivity.findViewById(R.id.preview_thumb);
+ mPreviewThumb = mRootView.findViewById(R.id.preview_thumb);
mPreviewThumb.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@@ -555,7 +555,9 @@ public class VideoUI implements PieRenderer.PieListener,
}
} else {
mShutterButton.setImageResource(R.drawable.btn_new_shutter_video);
- showSwitcher();
+ if (!mController.isVideoCaptureIntent()) {
+ showSwitcher();
+ }
mRecordingTimeView.setVisibility(View.GONE);
if (!ApiHelper.HAS_ZOOM_WHEN_RECORDING && zoomSupported) {
// TODO: enable zoom UI here.