diff options
author | Wu-cheng Li <wuchengli@google.com> | 2009-06-19 20:11:44 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2009-06-19 21:54:43 +0800 |
commit | 84f96469f8c54fcdc61b6e854cd478abc15c4f52 (patch) | |
tree | 62496e08b249acceaec4368483b9434c1bf9e09d | |
parent | 46fc7aeec04021dfc2f4c947649888dbc7408f53 (diff) | |
download | LegacyCamera-84f96469f8c54fcdc61b6e854cd478abc15c4f52.zip LegacyCamera-84f96469f8c54fcdc61b6e854cd478abc15c4f52.tar.gz LegacyCamera-84f96469f8c54fcdc61b6e854cd478abc15c4f52.tar.bz2 |
Fix attach video.
-rw-r--r-- | res/layout/camera_control.xml | 3 | ||||
-rw-r--r-- | res/layout/video_camera.xml | 39 | ||||
-rw-r--r-- | src/com/android/camera/Camera.java | 6 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 73 |
4 files changed, 112 insertions, 9 deletions
diff --git a/res/layout/camera_control.xml b/res/layout/camera_control.xml index 792ad50..f1c73a5 100644 --- a/res/layout/camera_control.xml +++ b/res/layout/camera_control.xml @@ -34,7 +34,8 @@ android:focusable="false" android:background="@drawable/border_last_picture"/> - <LinearLayout android:orientation="vertical" + <LinearLayout android:id="@+id/camera_switch_set" + android:orientation="vertical" android:layout_centerInParent="true" android:layout_height="wrap_content" android:layout_width="wrap_content"> diff --git a/res/layout/video_camera.xml b/res/layout/video_camera.xml index 0e27b01..1ab2e80 100644 --- a/res/layout/video_camera.xml +++ b/res/layout/video_camera.xml @@ -34,6 +34,12 @@ android:layout_width="352dp" android:layout_height="288dp" android:layout_centerInParent="true" /> + <ImageView + android:id="@+id/video_frame" + android:layout_width="352dp" + android:layout_height="288dp" + android:layout_toLeftOf="@id/button_bar" + android:visibility="gone" /> </FrameLayout> <!-- Note: In this TextView the paddingRight="2" @@ -59,4 +65,37 @@ android:textSize="23dp" android:textStyle="bold" android:visibility="gone"/> + + + <LinearLayout + android:visibility="gone" + android:id="@+id/post_picture_panel" + android:layout_alignParentTop="true" + android:layout_toLeftOf="@id/button_bar" + android:layout_marginTop="20dp" + android:layout_marginRight="30dp" + android:layout_marginLeft="30dp" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <com.android.camera.ActionMenuButton + android:id="@+id/play" + android:drawableTop="@drawable/ic_menu_camera_play" + android:text="@string/camera_play" + style="@style/OnscreenActionIcon" + /> + <com.android.camera.ActionMenuButton + android:id="@+id/attach" + android:drawableTop="@drawable/ic_menu_attach" + android:text="@string/camera_attach" + style="@style/OnscreenActionIcon" + /> + <com.android.camera.ActionMenuButton + android:id="@+id/cancel" + android:drawableTop="@drawable/ic_menu_cancel" + android:text="@string/camera_cancel" + style="@style/OnscreenActionIcon" + /> + </LinearLayout> </RelativeLayout> diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 39c6cea..e8047d9 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -286,8 +286,6 @@ public class Camera extends Activity implements View.OnClickListener, // Update last image thumbnail. updateThumbnailButton(); } else { - findViewById(R.id.review_thumbnail).setVisibility(View.INVISIBLE); - ViewGroup cameraView = (ViewGroup) findViewById(R.id.camera); getLayoutInflater().inflate( R.layout.post_picture_panel, cameraView); @@ -833,6 +831,10 @@ public class Camera extends Activity implements View.OnClickListener, mIsImageCaptureIntent = isImageCaptureIntent(); ((Switcher) findViewById(R.id.camera_switch)).setSwitch(true); + if (mIsImageCaptureIntent) { + findViewById(R.id.review_thumbnail).setVisibility(View.INVISIBLE); + findViewById(R.id.camera_switch_set).setVisibility(View.INVISIBLE); + } // Make sure the services are loaded. try { diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index e8e98a0..2eebe64 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -51,6 +51,8 @@ import android.view.View; import android.view.Window; import android.view.WindowManager; import android.view.MenuItem.OnMenuItemClickListener; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; @@ -98,6 +100,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, private static final float VIDEO_ASPECT_RATIO = 176.0f / 144.0f; VideoPreview mVideoPreview; SurfaceHolder mSurfaceHolder = null; + ImageView mVideoFrame; private boolean mIsVideoCaptureIntent; // mLastPictureButton and mThumbController @@ -139,6 +142,8 @@ public class VideoCamera extends Activity implements View.OnClickListener, ArrayList<MenuItem> mGalleryItems = new ArrayList<MenuItem>(); + View mPostPictureAlert; + private final Handler mHandler = new MainHandler(); // This Handler is used to post message back onto the main thread of the @@ -231,22 +236,31 @@ public class VideoCamera extends Activity implements View.OnClickListener, holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); + mPostPictureAlert = findViewById(R.id.post_picture_panel); + + int[] ids = new int[]{R.id.play, R.id.cancel, R.id.attach}; + for (int id : ids) { + findViewById(id).setOnClickListener(this); + } + mShutterButton = (ShutterButton) findViewById(R.id.shutter_button); mShutterButton.setImageResource(R.drawable.btn_ic_video_record); mShutterButton.setOnShutterButtonListener(this); mShutterButton.requestFocus(); mRecordingTimeView = (TextView) findViewById(R.id.recording_time); + mVideoFrame = (ImageView) findViewById(R.id.video_frame); mIsVideoCaptureIntent = isVideoCaptureIntent(); + mLastPictureButton = (ImageView) findViewById(R.id.review_thumbnail); + mThumbController = new ThumbnailController( + mLastPictureButton, mContentResolver); if (!mIsVideoCaptureIntent) { - mLastPictureButton = (ImageView) findViewById(R.id.review_thumbnail); mLastPictureButton.setOnClickListener(this); - mThumbController = new ThumbnailController( - mLastPictureButton, mContentResolver); mThumbController.loadData(ImageManager.getLastVideoThumbPath()); findViewById(R.id.camera_switch).setOnClickListener(this); } else { - findViewById(R.id.review_thumbnail).setVisibility(View.INVISIBLE); + mLastPictureButton.setVisibility(View.INVISIBLE); + findViewById(R.id.camera_switch_set).setVisibility(View.INVISIBLE); } // Make sure the camera is opened. @@ -318,13 +332,15 @@ public class VideoCamera extends Activity implements View.OnClickListener, case R.id.shutter_button: if (mMediaRecorderRecording) { if (mIsVideoCaptureIntent) { - stopVideoRecordingAndShowReview(); + stopVideoRecordingAndShowAlert(); } else { stopVideoRecordingAndGetThumbnail(); mRecorderInitialized = false; initializeRecorder(); } - } else if (mRecorderInitialized) { + } else if (isAlertVisible()) { + discardCurrentVideoAndInitRecorder(); + } else if (mRecorderInitialized) { // If the click comes before recorder initialization, it is // ignored. If users click the button during initialization, // the event is put in the queue and record will be started @@ -742,6 +758,11 @@ public class VideoCamera extends Activity implements View.OnClickListener, Log.v(TAG, "initializeRecorder"); if (mRecorderInitialized) return true; + // We will call initializeRecorder() again when the alert is hidden. + if (isAlertVisible()) { + return false; + } + Intent intent = getIntent(); Bundle myExtras = intent.getExtras(); @@ -1031,6 +1052,45 @@ public class VideoCamera extends Activity implements View.OnClickListener, acquireVideoThumb(); } + private void stopVideoRecordingAndShowAlert() { + stopVideoRecording(); + showAlert(); + } + + private void showAlert() { + int[] ids = {R.id.attach, R.id.cancel, R.id.play}; + connectAndFadeIn(ids); + mPostPictureAlert.setVisibility(View.VISIBLE); + mVideoPreview.setVisibility(View.INVISIBLE); + + String path = mCurrentVideoFilename; + if (path != null) { + Bitmap videoFrame = Util.createVideoThumbnail(path); + mVideoFrame.setImageBitmap(videoFrame); + mVideoFrame.setVisibility(View.VISIBLE); + } + } + + private void hideAlert() { + mVideoPreview.setVisibility(View.VISIBLE); + mVideoFrame.setVisibility(View.INVISIBLE); + mPostPictureAlert.setVisibility(View.INVISIBLE); + } + + private void connectAndFadeIn(int[] connectIds) { + for (int id : connectIds) { + View view = mPostPictureAlert.findViewById(id); + view.setOnClickListener(this); + Animation animation = new AlphaAnimation(0F, 1F); + animation.setDuration(500); + view.startAnimation(animation); + } + } + + private boolean isAlertVisible() { + return mPostPictureAlert.getVisibility() == View.VISIBLE; + } + private void stopVideoRecordingAndShowReview() { stopVideoRecording(); if (mThumbController.isUriValid()) { @@ -1115,6 +1175,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, } private void hideAlertAndInitializeRecorder() { + hideAlert(); mRecorderInitialized = false; mHandler.sendEmptyMessage(INIT_RECORDER); } |