summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/camera/VideoCamera.java8
-rw-r--r--src/com/android/camera/ui/RotateRecordingTime.java72
2 files changed, 79 insertions, 1 deletions
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();
+ }
+}
+