diff options
| -rw-r--r-- | res/layout-xlarge/attach_camera_control.xml | 14 | ||||
| -rw-r--r-- | src/com/android/camera/Util.java | 20 | ||||
| -rw-r--r-- | src/com/android/camera/VideoCamera.java | 16 |
3 files changed, 45 insertions, 5 deletions
diff --git a/res/layout-xlarge/attach_camera_control.xml b/res/layout-xlarge/attach_camera_control.xml index b33085b..c84e7a6 100644 --- a/res/layout-xlarge/attach_camera_control.xml +++ b/res/layout-xlarge/attach_camera_control.xml @@ -18,11 +18,22 @@ xmlns:camera="http://schemas.android.com/apk/res/com.android.camera" android:id="@+id/control_bar" android:layout_height="match_parent" - android:layout_width="90dp" + android:layout_width="120dp" android:layout_marginTop="20dp" android:layout_marginBottom="20dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp"> + <TextView android:id="@+id/recording_time" + style="@style/RecordingTime" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true" + android:layout_marginTop="90dp" + android:drawablePadding="8dp" + android:drawableLeft="@drawable/ic_recording_indicator" + android:visibility="gone" /> + <LinearLayout android:orientation="vertical" android:gravity="top|center_horizontal" android:layout_alignParentTop="true" @@ -56,6 +67,7 @@ android:text="@string/review_play" /> </LinearLayout> </LinearLayout> + <com.android.camera.ShutterButton android:id="@+id/shutter_button" android:layout_centerInParent="true" android:layout_centerHorizontal="true" diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java index 71d0c21..ac99956 100644 --- a/src/com/android/camera/Util.java +++ b/src/com/android/camera/Util.java @@ -54,10 +54,28 @@ public class Util { // Rotates the bitmap by the specified degree. // If a new bitmap is created, the original bitmap is recycled. public static Bitmap rotate(Bitmap b, int degrees) { - if (degrees != 0 && b != null) { + return rotateAndMirror(b, degrees, false); + } + + // Rotates and/or mirrors the bitmap. If a new bitmap is created, the + // original bitmap is recycled. + public static Bitmap rotateAndMirror(Bitmap b, int degrees, boolean mirror) { + if ((degrees != 0 || mirror) && b != null) { Matrix m = new Matrix(); m.setRotate(degrees, (float) b.getWidth() / 2, (float) b.getHeight() / 2); + if (mirror) { + m.postScale(-1, 1); + degrees = (degrees + 360) % 360; + if (degrees == 0 || degrees == 180) { + m.postTranslate((float) b.getWidth(), 0); + } else if (degrees == 90 || degrees == 270) { + m.postTranslate((float) b.getHeight(), 0); + } else { + throw new IllegalArgumentException("Invalid degrees=" + degrees); + } + } + try { Bitmap b2 = Bitmap.createBitmap( b, 0, 0, b.getWidth(), b.getHeight(), m, true); diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 0bda10d..c4ab942 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -206,6 +206,7 @@ public class VideoCamera extends NoSearchActivity private int mOrientation = OrientationEventListener.ORIENTATION_UNKNOWN; // The orientation compensation for icons and thumbnails. private int mOrientationCompensation = 0; + private int mOrientationHint; // the orientation hint for video playback // This Handler is used to post message back onto the main thread of the // application @@ -1124,6 +1125,7 @@ public class VideoCamera extends NoSearchActivity } } mMediaRecorder.setOrientationHint(rotation); + mOrientationHint = rotation; try { mMediaRecorder.prepare(); @@ -1413,9 +1415,17 @@ public class VideoCamera extends NoSearchActivity private void showAlert() { fadeOut(findViewById(R.id.shutter_button)); if (mCurrentVideoFilename != null) { - mVideoFrame.setImageBitmap( - ThumbnailUtils.createVideoThumbnail(mCurrentVideoFilename, - Video.Thumbnails.MINI_KIND)); + Bitmap src = 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); + } + mVideoFrame.setImageBitmap(src); mVideoFrame.setVisibility(View.VISIBLE); } int[] pickIds = {R.id.btn_retake, R.id.btn_done, R.id.btn_play}; |
