summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-08-08 18:42:21 +0800
committerWu-cheng Li <wuchengli@google.com>2011-08-09 15:00:06 +0800
commit16ca94d73bfe07f280e381595709b56c2681b2bc (patch)
treed0d396467484bfef1cfb7a6a31ed6ea88fdbdb20 /src/com
parent0ee420642b42dd9d300eea2e8019bf3dda48f610 (diff)
downloadLegacyCamera-16ca94d73bfe07f280e381595709b56c2681b2bc.zip
LegacyCamera-16ca94d73bfe07f280e381595709b56c2681b2bc.tar.gz
LegacyCamera-16ca94d73bfe07f280e381595709b56c2681b2bc.tar.bz2
Use new background and shutter button.
bug:5024054 Change-Id: I2def331433b0db66efc0d38f1e9537c0980441bb
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/Util.java13
-rw-r--r--src/com/android/camera/VideoCamera.java11
-rw-r--r--src/com/android/camera/ui/ControlPanelLayout.java67
-rw-r--r--src/com/android/camera/ui/IndicatorWheel.java50
4 files changed, 101 insertions, 40 deletions
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java
index 2b39b3d..3023565 100644
--- a/src/com/android/camera/Util.java
+++ b/src/com/android/camera/Util.java
@@ -34,10 +34,12 @@ import android.net.Uri;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.telephony.TelephonyManager;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.Surface;
import android.view.View;
+import android.view.WindowManager;
import java.io.Closeable;
import java.io.IOException;
@@ -62,18 +64,29 @@ public class Util {
"android.intent.extras.CAMERA_FACING";
private static boolean sIsTabletUI;
+ private static float sPixelDensity = 1;
private Util() {
}
public static void initialize(Context context) {
sIsTabletUI = (context.getResources().getConfiguration().screenWidthDp >= 1024);
+
+ DisplayMetrics metrics = new DisplayMetrics();
+ WindowManager wm = (WindowManager)
+ context.getSystemService(Context.WINDOW_SERVICE);
+ wm.getDefaultDisplay().getMetrics(metrics);
+ sPixelDensity = metrics.density;
}
public static boolean isTabletUI() {
return sIsTabletUI;
}
+ public static int dpToPixel(int dp) {
+ return Math.round(sPixelDensity * dp);
+ }
+
// 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) {
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index b730e0d..18c0764 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -60,7 +60,6 @@ import android.view.OrientationEventListener;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
-import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
@@ -428,7 +427,7 @@ public class VideoCamera extends ActivityBase
mQuickCapture = getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE, false);
mShutterButton = (ShutterButton) findViewById(R.id.shutter_button);
- mShutterButton.setImageResource(R.drawable.btn_ic_video_record);
+ mShutterButton.setBackgroundResource(R.drawable.btn_shutter_video);
mShutterButton.setOnShutterButtonListener(this);
mShutterButton.requestFocus();
@@ -1414,9 +1413,7 @@ public class VideoCamera extends ActivityBase
private void showRecordingUI(boolean recording) {
if (recording) {
- mShutterButton.setImageDrawable(getResources().getDrawable(
- R.drawable.btn_ic_video_record_stop));
- mShutterButton.setBackgroundResource(R.drawable.btn_shutter_recording);
+ mShutterButton.setBackgroundResource(R.drawable.btn_shutter_video);
mRecordingTimeView.setText("");
mRecordingTimeView.setVisibility(View.VISIBLE);
if (mReviewControl != null) mReviewControl.setVisibility(View.GONE);
@@ -1428,9 +1425,7 @@ public class VideoCamera extends ActivityBase
}
}
} else {
- mShutterButton.setImageDrawable(getResources().getDrawable(
- R.drawable.btn_ic_video_record));
- mShutterButton.setBackgroundResource(R.drawable.btn_shutter);
+ mShutterButton.setBackgroundResource(R.drawable.btn_shutter_video);
mRecordingTimeView.setVisibility(View.GONE);
if (mReviewControl != null) mReviewControl.setVisibility(View.VISIBLE);
if (mCaptureTimeLapse) {
diff --git a/src/com/android/camera/ui/ControlPanelLayout.java b/src/com/android/camera/ui/ControlPanelLayout.java
new file mode 100644
index 0000000..f85d955
--- /dev/null
+++ b/src/com/android/camera/ui/ControlPanelLayout.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 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.widget.RelativeLayout;
+
+/**
+ * A layout which handles the the width of the control panel, which contains
+ * the shutter button, thumbnail, front/back camera picker, and mode picker.
+ * The purpose of this is to have a consistent width of control panel in camera,
+ * camcorder, and panorama modes. The control panel can also be GONE and the
+ * preview can expand to full-screen in panorama.
+ */
+public class ControlPanelLayout extends RelativeLayout {
+ private static final String TAG = "ControlPanelLayout";
+
+ public ControlPanelLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onMeasure(int widthSpec, int heightSpec) {
+ int widthSpecSize = MeasureSpec.getSize(widthSpec);
+ int heightSpecSize = MeasureSpec.getSize(heightSpec);
+ int widthMode = MeasureSpec.getMode(widthSpec);
+ int measuredWidth = 0;
+
+ if (widthSpecSize > 0 && heightSpecSize > 0 && widthMode == MeasureSpec.AT_MOST) {
+ // Calculate how big 4:3 preview occupies. Then deduct it from the
+ // width of the parent.
+ measuredWidth = (int) (widthSpecSize - heightSpecSize / 3.0 * 4.0 - 16);
+ } else {
+ Log.e(TAG, "layout_width of ControlPanelLayout should be wrap_content");
+ }
+
+ // Make sure the width is bigger than the minimum width.
+ int minWidth = getSuggestedMinimumWidth();
+ if (minWidth > measuredWidth) {
+ measuredWidth = minWidth;
+ }
+
+ // The width cannot be bigger than the constraint.
+ if (widthMode == MeasureSpec.AT_MOST && measuredWidth > widthSpecSize) {
+ measuredWidth = widthSpecSize;
+ }
+
+ super.onMeasure(MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY),
+ heightSpec);
+ }
+}
diff --git a/src/com/android/camera/ui/IndicatorWheel.java b/src/com/android/camera/ui/IndicatorWheel.java
index fa2a1d3..ac1305e 100644
--- a/src/com/android/camera/ui/IndicatorWheel.java
+++ b/src/com/android/camera/ui/IndicatorWheel.java
@@ -17,6 +17,7 @@
package com.android.camera.ui;
import com.android.camera.R;
+import com.android.camera.Util;
import android.content.Context;
import android.content.res.Resources;
@@ -79,39 +80,27 @@ public class IndicatorWheel extends IndicatorControl {
mBackgroundRect = new RectF();
}
- private boolean isInsideShutterButton(MotionEvent ev) {
- float x = ev.getX();
- float y = ev.getY();
- float shutterButtonX = mShutterButton.getX();
- float shutterButtonY = mShutterButton.getY();
- if (x >= shutterButtonX && y >= shutterButtonY
- && (x < shutterButtonX + mShutterButton.getWidth())
- && (y < shutterButtonY + mShutterButton.getHeight())) {
- return true;
- }
- return false;
- }
-
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (!onFilterTouchEventForSecurity(event)) return false;
int action = event.getAction();
+ double dx = event.getX() - mCenterX;
+ double dy = mCenterY - event.getY();
+ double radius = Math.sqrt(dx * dx + dy * dy);
+
// Check if the event should be dispatched to the shutter button.
- if (isInsideShutterButton(event)) {
+ if (radius <= mShutterButtonRadius) {
if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) {
return mShutterButton.dispatchTouchEvent(event);
}
return false;
}
- double dx = event.getX() - mCenterX;
- double dy = mCenterY - event.getY();
- double radius = Math.sqrt(dx * dx + dy * dy);
// Ignore the event if it's too near to the shutter button or too far
// from the shutter button.
- if (radius >= mShutterButtonRadius && radius <= mWheelRadius + mStrokeWidth) {
+ if (radius <= mWheelRadius + mStrokeWidth) {
double delta = Math.atan2(dy, dx);
if (delta < 0) delta += Math.PI * 2;
// Check which sector is pressed.
@@ -195,9 +184,9 @@ public class IndicatorWheel extends IndicatorControl {
getChildAt(i).measure(freeSpec, freeSpec);
}
- // Measure myself.
- int desiredWidth = mShutterButton.getMeasuredWidth() * 3;
- int desiredHeight = (int)(mShutterButton.getMeasuredHeight() * 4.5) + 2;
+ // Measure myself. Add some buffer for highlight arc.
+ int desiredWidth = mShutterButton.getMeasuredWidth() + HIGHLIGHT_WIDTH * 4;
+ int desiredHeight = mShutterButton.getMeasuredHeight() + HIGHLIGHT_WIDTH * 4;
int widthMode = MeasureSpec.getMode(widthSpec);
int heightMode = MeasureSpec.getMode(heightSpec);
int measuredWidth, measuredHeight;
@@ -226,24 +215,21 @@ public class IndicatorWheel extends IndicatorControl {
// Layout the shutter button.
int shutterButtonWidth = mShutterButton.getMeasuredWidth();
- mShutterButtonRadius = shutterButtonWidth / 2.0;
int shutterButtonHeight = mShutterButton.getMeasuredHeight();
- mStrokeWidth = (int) (mShutterButtonRadius * 1.05);
- int innerRadius = (int) (mShutterButtonRadius + mStrokeWidth * 0.84);
- // 64 is the requirement by UI design. The distance between the center
- // and the border is 64 pixels. This has to be consistent with the
- // background.
- mCenterX = right - left - 64;
+ // These numbers have to sync with the background of the shutter button.
+ mShutterButtonRadius = Util.dpToPixel(74);
+ mStrokeWidth = Util.dpToPixel(87);
+ mCenterX = right - left - Util.dpToPixel(93);
mCenterY = (bottom - top) / 2;
- mShutterButton.layout(mCenterX - shutterButtonWidth / 2,
+ mShutterButton.layout(right - left - shutterButtonWidth,
mCenterY - shutterButtonHeight / 2,
- mCenterX + shutterButtonWidth / 2,
- mCenterY + shutterButtonHeight / 2);
+ right - left,
+ mCenterY + shutterButtonHeight - shutterButtonHeight / 2);
// Layout the settings. The icons are spreaded on the left side of the
// shutter button. So the angle starts from 90 to 270 degrees.
if (count == 1) return;
- mWheelRadius = innerRadius + mStrokeWidth * 0.5;
+ mWheelRadius = mShutterButtonRadius + mStrokeWidth * 0.5;
double intervalDegrees = (count == 2) ? 90.0 : 180.0 / (count - 2);
double initialDegrees = 90.0;
int index = 0;