summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2010-11-16 19:15:44 +0800
committerWu-cheng Li <wuchengli@google.com>2010-11-17 23:11:26 +0800
commit80715aae46e5a7a9aa378002301ba9d76f093776 (patch)
tree15715610e9cf3c6402bd71f0246750360c96249b
parent53514599c5c11b6fa772f5c577d0be6f6355e3e7 (diff)
downloadLegacyCamera-80715aae46e5a7a9aa378002301ba9d76f093776.zip
LegacyCamera-80715aae46e5a7a9aa378002301ba9d76f093776.tar.gz
LegacyCamera-80715aae46e5a7a9aa378002301ba9d76f093776.tar.bz2
Add background for indicator wheel.
bug:3156688 Change-Id: I91465730cc2ac9c586122573c1ac73ba48cc0cc9
-rw-r--r--res/layout-xlarge/basic_setting_popup.xml1
-rw-r--r--res/layout-xlarge/camera_control.xml11
-rw-r--r--res/layout-xlarge/other_setting_popup.xml1
-rw-r--r--src/com/android/camera/PreviewFrameLayout.java1
-rw-r--r--src/com/android/camera/ui/ControlPanel.java9
-rw-r--r--src/com/android/camera/ui/IndicatorWheel.java105
6 files changed, 96 insertions, 32 deletions
diff --git a/res/layout-xlarge/basic_setting_popup.xml b/res/layout-xlarge/basic_setting_popup.xml
index 862533c..a58d835 100644
--- a/res/layout-xlarge/basic_setting_popup.xml
+++ b/res/layout-xlarge/basic_setting_popup.xml
@@ -22,6 +22,7 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
+ android:layout_marginRight="40dp"
android:background="@drawable/menu_popup"
android:orientation="vertical" />
diff --git a/res/layout-xlarge/camera_control.xml b/res/layout-xlarge/camera_control.xml
index dcf4f88..18fbcde 100644
--- a/res/layout-xlarge/camera_control.xml
+++ b/res/layout-xlarge/camera_control.xml
@@ -18,11 +18,10 @@
xmlns:camera="http://schemas.android.com/apk/res/com.android.camera"
android:id="@+id/control_panel"
android:layout_height="match_parent"
- android:layout_width="220dp"
+ android:layout_width="230dp"
android:layout_marginTop="30dp"
- android:layout_marginLeft="-26dp"
- android:layout_marginBottom="25dp"
- android:layout_marginRight="0dp">
+ android:layout_marginLeft="-46dp"
+ android:layout_marginBottom="25dp">
<ViewStub android:id="@+id/zoom_stub"
android:inflatedId="@+id/zoom_picker"
@@ -31,7 +30,7 @@
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginLeft="6dp"
+ android:layout_marginLeft="7dp"
android:layout_marginTop="10dp" />
<TextView android:id="@+id/recording_time"
@@ -75,7 +74,7 @@
android:layout_width="45dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
- android:layout_marginLeft="1dp"
+ android:layout_marginLeft="21dp"
android:background="@drawable/mode_switch_bg_v2">
<com.android.camera.RotateImageView android:id="@+id/video_switch_icon"
android:layout_height="wrap_content"
diff --git a/res/layout-xlarge/other_setting_popup.xml b/res/layout-xlarge/other_setting_popup.xml
index 6244044..3f67477 100644
--- a/res/layout-xlarge/other_setting_popup.xml
+++ b/res/layout-xlarge/other_setting_popup.xml
@@ -23,6 +23,7 @@
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
+ android:layout_marginRight="40dp"
android:background="@drawable/menu_popup">
<TableRow style="@style/OtherSettingTableRow">
diff --git a/src/com/android/camera/PreviewFrameLayout.java b/src/com/android/camera/PreviewFrameLayout.java
index 2eda53f..ee12c39 100644
--- a/src/com/android/camera/PreviewFrameLayout.java
+++ b/src/com/android/camera/PreviewFrameLayout.java
@@ -51,6 +51,7 @@ public class PreviewFrameLayout extends ViewGroup {
@Override
protected void onFinishInflate() {
+ super.onFinishInflate();
mFrame = (View) findViewById(R.id.frame);
if (mFrame == null) {
throw new IllegalStateException(
diff --git a/src/com/android/camera/ui/ControlPanel.java b/src/com/android/camera/ui/ControlPanel.java
index 6ac7a98..4026bd3 100644
--- a/src/com/android/camera/ui/ControlPanel.java
+++ b/src/com/android/camera/ui/ControlPanel.java
@@ -31,6 +31,7 @@ import android.view.LayoutInflater;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewGroup.MarginLayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
@@ -85,8 +86,11 @@ public class ControlPanel extends RelativeLayout
@Override
protected void onFinishInflate() {
+ super.onFinishInflate();
mIndicatorWheel = (IndicatorWheel) findViewById(R.id.indicator_wheel);
mIndicatorWheel.setListener(this);
+ MarginLayoutParams params = (MarginLayoutParams) getLayoutParams();
+ mIndicatorWheel.setOverlapWidth(-params.leftMargin);
}
public void initialize(Context context, PreferenceGroup group,
@@ -151,11 +155,6 @@ public class ControlPanel extends RelativeLayout
mBasicSettingPopups[index] = popup;
popup.setSettingChangedListener(this);
popup.initialize(pref);
- RelativeLayout.LayoutParams params =
- (RelativeLayout.LayoutParams) popup.getLayoutParams();
- params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- params.addRule(RelativeLayout.CENTER_VERTICAL);
- popup.setLayoutParams(params);
root.addView(popup);
}
diff --git a/src/com/android/camera/ui/IndicatorWheel.java b/src/com/android/camera/ui/IndicatorWheel.java
index e967017..e2ff028 100644
--- a/src/com/android/camera/ui/IndicatorWheel.java
+++ b/src/com/android/camera/ui/IndicatorWheel.java
@@ -21,6 +21,9 @@ import com.android.camera.PreferenceGroup;
import com.android.camera.R;
import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.Button;
@@ -31,15 +34,28 @@ import android.view.View;
import java.lang.Math;
/**
- * A view that contains camera settings and shutter buttons. The settings are
- * spreaded around the shutter button.
+ * A view that contains shutter button and camera setting indicators. The
+ * indicators are spreaded around the shutter button. The first child is always
+ * the shutter button.
*/
public class IndicatorWheel extends ViewGroup {
private static final String TAG = "IndicatorWheel";
private Listener mListener;
+ // The center of the shutter button.
private int mCenterX, mCenterY;
+ // The width of the wheel stroke.
+ private int mStrokeWidth = 40;
+ private final int STROKE_COLOR = 0x50000000;
+ // The width of the edges on both sides of the wheel, which has less alpha.
+ private final int EDGE_STROKE_WIDTH = 4, EDGE_STROKE_COLOR = 0x30000000;
+ private View mShutterButton;
private double mShutterButtonRadius;
+ private double mWheelRadius;
private double mSectorInitialRadians[];
+ private Paint mBackgroundPaint;
+ private RectF mBackgroundRect;
+ // The overlapping width between control panel and indicator wheel.
+ private int mOverlapWidth;
static public interface Listener {
public void onIndicatorClicked(int index);
@@ -49,6 +65,21 @@ public class IndicatorWheel extends ViewGroup {
mListener = listener;
}
+ public IndicatorWheel(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setWillNotDraw(false);
+
+ mBackgroundPaint = new Paint();
+ mBackgroundPaint.setStyle(Paint.Style.STROKE);
+ mBackgroundPaint.setAntiAlias(true);
+
+ mBackgroundRect = new RectF();
+ }
+
+ public void setOverlapWidth(int width) {
+ mOverlapWidth = width;
+ }
+
@Override
public boolean onTouchEvent(MotionEvent event) {
int count = getChildCount();
@@ -80,8 +111,11 @@ public class IndicatorWheel extends ViewGroup {
return false;
}
- public IndicatorWheel(Context context, AttributeSet attrs) {
- super(context, attrs);
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ // The first view is shutter button.
+ mShutterButton = getChildAt(0);
}
public void removeIndicators() {
@@ -95,15 +129,19 @@ public class IndicatorWheel extends ViewGroup {
@Override
protected void onMeasure(int widthSpec, int heightSpec) {
// Measure all children.
+ int childCount = getChildCount();
int freeSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- for (int i = 0; i < getChildCount(); i++) {
+ for (int i = 0; i < childCount; i++) {
getChildAt(i).measure(freeSpec, freeSpec);
}
+ if (childCount > 1) {
+ mStrokeWidth = (int) (getChildAt(1).getMeasuredWidth() * 1.3);
+ }
+
// Measure myself.
- View shutterButton = getChildAt(0);
- int desiredWidth = (int)(shutterButton.getMeasuredWidth() * 2.5);
- int desiredHeight = (int)(shutterButton.getMeasuredHeight() * 2.5);
+ int desiredWidth = (int)(mShutterButton.getMeasuredWidth() * 2.5);
+ int desiredHeight = (int)(mShutterButton.getMeasuredHeight() * 4.5);
int widthMode = MeasureSpec.getMode(widthSpec);
int heightMode = MeasureSpec.getMode(heightSpec);
int measuredWidth, measuredHeight;
@@ -131,31 +169,33 @@ public class IndicatorWheel extends ViewGroup {
if (count == 0) return;
// Layout the shutter button.
- View shutterButton = findViewById(R.id.shutter_button);
- int width = shutterButton.getMeasuredWidth();
- mShutterButtonRadius = width / 2.0 + 10;
- int height = shutterButton.getMeasuredHeight();
- mCenterX = (right - left) - width / 2;
+ int shutterButtonWidth = mShutterButton.getMeasuredWidth();
+ mShutterButtonRadius = shutterButtonWidth / 2.0 + 10;
+ int shutterButtonHeight = mShutterButton.getMeasuredHeight();
+ mCenterX = (right - left + mOverlapWidth) / 2;
mCenterY = (bottom - top) / 2;
- shutterButton.layout(mCenterX - width / 2, mCenterY - height / 2,
- mCenterX + width / 2, mCenterY + height / 2);
+ mShutterButton.layout(mCenterX - shutterButtonWidth / 2,
+ mCenterY - shutterButtonHeight / 2,
+ mCenterX + shutterButtonWidth / 2,
+ mCenterY + 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;
- double radius = shutterButton.getMeasuredWidth();
+ mWheelRadius = (right - left - mOverlapWidth) / 2.0
+ + EDGE_STROKE_WIDTH + mStrokeWidth / 2.0;
double intervalDegrees = 180.0 / (count - 2);
double initialDegrees = 90.0;
int index = 0;
for (int i = 0; i < count; i++) {
View view = getChildAt(i);
- if (view == shutterButton) continue;
+ if (view == mShutterButton) continue;
double degree = initialDegrees + intervalDegrees * index;
double radian = Math.toRadians(degree);
- int x = mCenterX + (int)(radius * Math.cos(radian));
- int y = mCenterY - (int)(radius * Math.sin(radian));
- width = view.getMeasuredWidth();
- height = view.getMeasuredHeight();
+ int x = mCenterX + (int)(mWheelRadius * Math.cos(radian));
+ int y = mCenterY - (int)(mWheelRadius * Math.sin(radian));
+ int width = view.getMeasuredWidth();
+ int height = view.getMeasuredHeight();
view.layout(x - width / 2, y - height / 2, x + width / 2,
y + height / 2);
index++;
@@ -171,6 +211,29 @@ public class IndicatorWheel extends ViewGroup {
}
}
+ @Override
+ protected void onDraw(Canvas canvas) {
+ // Draw the dark background.
+ mBackgroundPaint.setStrokeWidth(mStrokeWidth);
+ mBackgroundPaint.setColor(STROKE_COLOR);
+ mBackgroundRect.set((float)(mCenterX - mWheelRadius),
+ (float)(mCenterY - mWheelRadius),
+ (float)(mCenterX + mWheelRadius),
+ (float)(mCenterY + mWheelRadius));
+ canvas.drawArc(mBackgroundRect, 0, 360, false, mBackgroundPaint);
+
+ // Draw a lighter background on the both sides of the arc.
+ mBackgroundPaint.setStrokeWidth(EDGE_STROKE_WIDTH);
+ mBackgroundPaint.setColor(EDGE_STROKE_COLOR);
+ float delta = (mStrokeWidth + EDGE_STROKE_WIDTH) / 2.0f;
+ mBackgroundRect.inset(-delta, -delta);
+ canvas.drawArc(mBackgroundRect, 0, 360, false, mBackgroundPaint);
+ mBackgroundRect.inset(delta * 2, delta * 2);
+ canvas.drawArc(mBackgroundRect, 0, 360, false, mBackgroundPaint);
+
+ super.onDraw(canvas);
+ }
+
public void updateIndicator(int index) {
IndicatorButton indicator = (IndicatorButton) getChildAt(index + 1);
indicator.reloadPreference();