summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/video_camera.xml43
-rw-r--r--src/com/android/camera/VideoCamera.java8
-rw-r--r--src/com/android/camera/ui/RotateRecordingTime.java72
3 files changed, 103 insertions, 20 deletions
diff --git a/res/layout/video_camera.xml b/res/layout/video_camera.xml
index ea4cf51..a684a5b 100644
--- a/res/layout/video_camera.xml
+++ b/res/layout/video_camera.xml
@@ -37,27 +37,32 @@
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. -->
- <TextView android:id="@+id/recording_time"
- android:layout_width="180dp"
+ <com.android.camera.ui.RotateRecordingTime android:id="@+id/recording_time_rect"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|bottom"
- android:layout_marginBottom="13dp"
- android:layout_marginLeft="17dp"
- android:paddingRight="2dp"
- android:drawablePadding="8dp"
- android:drawableLeft="@drawable/ic_recording_indicator"
- android:shadowColor="#c0000000"
- android:shadowDx="1"
- android:shadowDy="1"
- android:shadowRadius="1"
- android:gravity="left|center_vertical"
- android:textColor="@color/recording_time_elapsed_text"
- android:textSize="23dp"
- android:textStyle="bold"
- android:visibility="gone"/>
+ android:layout_marginBottom="14dp"
+ android:layout_marginLeft="14dp">
+ <!-- Note: In this TextView the paddingRight="2"
+ attribute is required because otherwise the
+ text's drop shadow will be clipped. -->
+ <TextView android:id="@+id/recording_time"
+ android:layout_width="130dp"
+ android:layout_height="130dp"
+ android:layout_gravity="center"
+ android:paddingRight="2dp"
+ android:drawablePadding="8dp"
+ android:drawableLeft="@drawable/ic_recording_indicator"
+ android:shadowColor="#c0000000"
+ android:shadowDx="1"
+ android:shadowDy="1"
+ android:shadowRadius="1"
+ android:gravity="left|center_vertical"
+ android:textColor="@color/recording_time_elapsed_text"
+ android:textSize="23dp"
+ android:textStyle="bold"
+ android:visibility="gone"/>
+ </com.android.camera.ui.RotateRecordingTime>
</FrameLayout>
</com.android.camera.PreviewFrameLayout>
</LinearLayout>
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 1d17104..0c0a6d9 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -22,6 +22,7 @@ import com.android.camera.ui.CamcorderHeadUpDisplay;
import com.android.camera.ui.GLRootView;
import com.android.camera.ui.GLView;
import com.android.camera.ui.HeadUpDisplay;
+import com.android.camera.ui.RotateRecordingTime;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
@@ -167,6 +168,7 @@ public class VideoCamera extends NoSearchActivity
private ContentResolver mContentResolver;
private ShutterButton mShutterButton;
+ private RotateRecordingTime mRecordingTimeRect;
private TextView mRecordingTimeView;
private Switcher mSwitcher;
private boolean mRecordingTimeCountsDown = false;
@@ -183,7 +185,8 @@ public class VideoCamera extends NoSearchActivity
private MyOrientationEventListener mOrientationListener;
// The device orientation in degrees. Default is unknown.
private int mOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
- // The orientation compensation for icons and thumbnails.
+ // The orientation compensation for icons and thumbnails. Degrees are in
+ // counter-clockwise
private int mOrientationCompensation = 0;
private int mOrientationHint; // the orientation hint for video playback
@@ -336,6 +339,7 @@ public class VideoCamera extends NoSearchActivity
mIsVideoCaptureIntent = isVideoCaptureIntent();
mQuickCapture = getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE, false);
mRecordingTimeView = (TextView) findViewById(R.id.recording_time);
+ mRecordingTimeRect = (RotateRecordingTime) findViewById(R.id.recording_time_rect);
ViewGroup rootView = (ViewGroup) findViewById(R.id.video_camera);
LayoutInflater inflater = this.getLayoutInflater();
@@ -1232,6 +1236,8 @@ public class VideoCamera extends NoSearchActivity
mMediaRecorderRecording = true;
mRecordingStartTime = SystemClock.uptimeMillis();
updateRecordingIndicator(false);
+ // Rotate the recording time.
+ mRecordingTimeRect.setOrientation(mOrientationCompensation);
mRecordingTimeView.setText("");
mRecordingTimeView.setVisibility(View.VISIBLE);
updateRecordingTime();
diff --git a/src/com/android/camera/ui/RotateRecordingTime.java b/src/com/android/camera/ui/RotateRecordingTime.java
new file mode 100644
index 0000000..f5c1a82
--- /dev/null
+++ b/src/com/android/camera/ui/RotateRecordingTime.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.graphics.Canvas;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.TextView;
+
+import com.android.camera.R;
+
+// This is a rectangle that contains recording text view. Canvas is rotated
+// before passing to recording text.
+public class RotateRecordingTime extends FrameLayout {
+ private static final String TAG = "RotateRecordingTime";
+ private float mTextSize;
+ private int mOrientation;
+
+ public RotateRecordingTime(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ TextView v = (TextView) findViewById(R.id.recording_time);
+ mTextSize = (float) v.getTextSize();
+ }
+
+ // degrees in counter-clockwise
+ public void setOrientation(int degrees) {
+ if (degrees % 90 == 0) {
+ mOrientation = degrees % 360;
+ if (mOrientation < 0) mOrientation += 360;
+ } else {
+ Log.e(TAG, "Invalid orientation=" + degrees);
+ }
+ }
+
+ @Override
+ protected void dispatchDraw(Canvas canvas) {
+ canvas.save();
+ float width = (float) getWidth();
+ float height = (float) getHeight();
+ if (mOrientation == 0 || mOrientation == 180) {
+ canvas.translate(0, height / 2 - mTextSize / 2);
+ } else {
+ canvas.translate(-width / 2 + mTextSize / 2, 0);
+ }
+ // Rotate the canvas in the opposite direction to compensate.
+ canvas.rotate(-mOrientation, width / 2, height / 2);
+ super.dispatchDraw(canvas);
+ canvas.restore();
+ }
+}
+