summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2010-03-15 14:08:13 +0800
committerOwen Lin <owenlin@google.com>2010-03-16 14:20:33 +0800
commit6988d4e2ef8d14d8bf3ee81c8eb3175bbf1b88ec (patch)
treead890b87333bd67dd33027718f547def10760e1a /src/com/android/camera
parent9ae7d027bb8f55b85a158cddeb7ed84c5a0a7983 (diff)
downloadLegacyCamera-6988d4e2ef8d14d8bf3ee81c8eb3175bbf1b88ec.tar.gz
LegacyCamera-6988d4e2ef8d14d8bf3ee81c8eb3175bbf1b88ec.tar.bz2
LegacyCamera-6988d4e2ef8d14d8bf3ee81c8eb3175bbf1b88ec.zip
Fix several UI issues.
1. Remove the cross in border_last_picture 2. Remove the gripper in VideoCamera 3. Solve the popup triangle locate in wrong position 4. Remove the top and bottom borders of the preview frame in Camera 5. Rotate the on-screen indicators when orientation changed 6. Add the checking for the flash mode in VideoCamera Change-Id: I304ea3582d08c5e46ed750b7371588635a4d8009
Diffstat (limited to 'src/com/android/camera')
-rw-r--r--src/com/android/camera/CameraSettings.java8
-rw-r--r--src/com/android/camera/PreviewFrameLayout.java81
-rw-r--r--src/com/android/camera/RotateImageView.java61
-rw-r--r--src/com/android/camera/ui/AbstractIndicator.java39
-rw-r--r--src/com/android/camera/ui/GLRootView.java7
-rw-r--r--src/com/android/camera/ui/HeadUpDisplay.java34
-rw-r--r--src/com/android/camera/ui/IndicatorBar.java6
7 files changed, 104 insertions, 132 deletions
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 774bc5a5..1e7cec24 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -26,8 +26,6 @@ import android.media.CamcorderProfile;
import android.preference.PreferenceManager;
import android.util.Log;
-import com.android.camera.R;
-
import java.util.ArrayList;
import java.util.List;
@@ -138,6 +136,8 @@ public class CameraSettings {
ListPreference flashMode = group.findPreference(KEY_FLASH_MODE);
ListPreference focusMode = group.findPreference(KEY_FOCUS_MODE);
ListPreference exposure = group.findPreference(KEY_EXPOSURE);
+ ListPreference videoFlashMode =
+ group.findPreference(KEY_VIDEOCAMERA_FLASH_MODE);
// Since the screen could be loaded from different resources, we need
// to check if the preference is available here
@@ -181,6 +181,10 @@ public class CameraSettings {
filterUnsupportedOptions(group,
focusMode, mParameters.getSupportedFocusModes());
}
+ if (videoFlashMode != null) {
+ filterUnsupportedOptions(group,
+ videoFlashMode, mParameters.getSupportedFlashModes());
+ }
if (exposure != null) {
buildExposureCompensation(group, exposure);
diff --git a/src/com/android/camera/PreviewFrameLayout.java b/src/com/android/camera/PreviewFrameLayout.java
index 09081bb6..d30f6c84 100644
--- a/src/com/android/camera/PreviewFrameLayout.java
+++ b/src/com/android/camera/PreviewFrameLayout.java
@@ -20,13 +20,9 @@ import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
-import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
import android.widget.FrameLayout;
-import com.android.camera.R;
-
/**
* A layout which handles the preview aspect ratio and the position of
* the gripper.
@@ -40,10 +36,12 @@ public class PreviewFrameLayout extends ViewGroup {
}
private double mAspectRatio = 4.0 / 3.0;
- private ImageView mGripper;
private FrameLayout mFrame;
private OnSizeChangedListener mSizeListener;
- private DisplayMetrics mMetrics = new DisplayMetrics();
+ private final DisplayMetrics mMetrics = new DisplayMetrics();
+
+ private int mPreviewWidth;
+ private int mPreviewHeight;
public PreviewFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -57,7 +55,6 @@ public class PreviewFrameLayout extends ViewGroup {
@Override
protected void onFinishInflate() {
- mGripper = (ImageView) findViewById(R.id.btn_gripper);
mFrame = (FrameLayout) findViewById(R.id.frame);
if (mFrame == null) {
throw new IllegalStateException(
@@ -75,29 +72,26 @@ public class PreviewFrameLayout extends ViewGroup {
}
@Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
- int gripperWidth = 0;
- int gripperHeight = 0;
-
- if (mGripper != null) {
- measureChild(mGripper, widthMeasureSpec, heightMeasureSpec);
- gripperWidth = mGripper.getMeasuredWidth();
- gripperHeight = mGripper.getMeasuredHeight();
- }
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ // Try to layout the "frame" in the center of the area, and put
+ // "gripper" just to the left of it. If there is no enough space for
+ // the gripper, the "frame" will be moved a little right so that
+ // they won't overlap with each other.
- int frameWidth = getMeasuredWidth() - (int) Math.max(
- gripperWidth, MIN_HORIZONTAL_MARGIN * mMetrics.density);
- int frameHeight = getMeasuredHeight();
+ int frameWidth = getWidth();
+ int frameHeight = getHeight();
FrameLayout f = mFrame;
- int horizontalPadding = f.getPaddingLeft() + f.getPaddingRight();
+ int horizontalPadding = Math.max(
+ f.getPaddingLeft() + f.getPaddingRight(),
+ (int) (MIN_HORIZONTAL_MARGIN * mMetrics.density));
int verticalPadding = f.getPaddingBottom() + f.getPaddingTop();
+ // Ignore the vertical paddings, so that we won't draw the frame on the
+ // top and bottom sides
+ int previewHeight = frameHeight;
int previewWidth = frameWidth - horizontalPadding;
- int previewHeight = frameHeight - verticalPadding;
// resize frame and preview for aspect ratio
if (previewWidth > previewHeight * mAspectRatio) {
@@ -105,46 +99,19 @@ public class PreviewFrameLayout extends ViewGroup {
} else {
previewHeight = (int) (previewWidth / mAspectRatio + .5);
}
+
frameWidth = previewWidth + horizontalPadding;
frameHeight = previewHeight + verticalPadding;
- measureChild(mFrame,
- MeasureSpec.makeMeasureSpec(MeasureSpec.EXACTLY, frameWidth),
- MeasureSpec.makeMeasureSpec(MeasureSpec.EXACTLY, frameHeight));
- }
-
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- // Try to layout the "frame" in the center of the area, and put
- // "gripper" just to the left of it. If there is no enough space for
- // the gripper, the "frame" will be moved a little right so that
- // they won't overlap with each other.
-
- int frameWidth = mFrame.getMeasuredWidth();
- int frameHeight = mFrame.getMeasuredHeight();
-
- int leftSpace = ((r - l) - frameWidth) / 2;
- int topSpace = ((b - t) - frameHeight) / 2;
-
- int gripperWidth = 0;
- int gripperHeight = 0;
- if (mGripper != null) {
- gripperWidth = mGripper.getMeasuredWidth();
- gripperHeight = mGripper.getMeasuredHeight();
- myLayoutChild(mGripper,
- Math.max(l, l + (leftSpace - gripperWidth)),
- t + ((b - t) - gripperHeight) / 2,
- gripperWidth, gripperHeight);
- }
- myLayoutChild(mFrame, Math.max(l + leftSpace, l + gripperWidth),
- t + topSpace, frameWidth, frameHeight);
+ int hSpace = ((r - l) - frameWidth) / 2;
+ int vSpace = ((b - t) - frameHeight) / 2;
+ mFrame.measure(
+ MeasureSpec.makeMeasureSpec(frameWidth, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(frameHeight, MeasureSpec.EXACTLY));
+ mFrame.layout(l + hSpace, t + vSpace, r - hSpace, b - vSpace);
if (mSizeListener != null) {
mSizeListener.onSizeChanged();
}
}
-
- private static void myLayoutChild(View child, int l, int t, int w, int h) {
- child.layout(l, t, l + w, t + h);
- }
}
diff --git a/src/com/android/camera/RotateImageView.java b/src/com/android/camera/RotateImageView.java
index 14d16283..dcec5e4c 100644
--- a/src/com/android/camera/RotateImageView.java
+++ b/src/com/android/camera/RotateImageView.java
@@ -21,7 +21,6 @@ import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
-import android.view.animation.AnimationUtils;
import android.widget.ImageView;
/**
@@ -32,16 +31,7 @@ public class RotateImageView extends ImageView {
@SuppressWarnings("unused")
private static final String TAG = "RotateImageView";
- private static final int ANIMATION_SPEED = 180; // 180 deg/sec
-
- private int mCurrentDegree = 0; // [0, 359]
- private int mStartDegree = 0;
- private int mTargetDegree = 0;
-
- private boolean mClockwise = false;
-
- private long mAnimationStartTime = 0;
- private long mAnimationEndTime = 0;
+ private int mDegree = 0; // [0, 359]
public RotateImageView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -50,23 +40,8 @@ public class RotateImageView extends ImageView {
public void setDegree(int degree) {
// make sure in the range of [0, 359]
degree = degree >= 0 ? degree % 360 : degree % 360 + 360;
- if (degree == mTargetDegree) return;
-
- mTargetDegree = degree;
- mStartDegree = mCurrentDegree;
- mAnimationStartTime = AnimationUtils.currentAnimationTimeMillis();
-
- int diff = mTargetDegree - mCurrentDegree;
- diff = diff >= 0 ? diff : 360 + diff; // make it in range [0, 359]
-
- // Make it in range [-179, 180]. That's the shorted distance between the
- // two angles
- diff = diff > 180 ? diff - 360 : diff;
-
- mClockwise = diff >= 0;
- mAnimationEndTime = mAnimationStartTime
- + Math.abs(diff) * 1000 / ANIMATION_SPEED;
-
+ if (degree == mDegree) return;
+ mDegree = degree;
invalidate();
}
@@ -74,31 +49,27 @@ public class RotateImageView extends ImageView {
protected void onDraw(Canvas canvas) {
Drawable drawable = getDrawable();
- if (drawable == null) return;
+ if (drawable == null) return;
Rect bounds = drawable.getBounds();
int w = bounds.right - bounds.left;
int h = bounds.bottom - bounds.top;
if (w == 0 || h == 0) return; // nothing to draw
- if (mCurrentDegree != mTargetDegree) {
- long time = AnimationUtils.currentAnimationTimeMillis();
- if (time < mAnimationEndTime) {
- int deltaTime = (int)(time - mAnimationStartTime);
- int degree = mStartDegree + ANIMATION_SPEED
- * (mClockwise ? deltaTime : -deltaTime) / 1000;
- degree = degree >= 0 ? degree % 360 : degree % 360 + 360;
- mCurrentDegree = degree;
- invalidate();
- } else {
- mCurrentDegree = mTargetDegree;
- }
- }
-
int saveCount = canvas.getSaveCount();
- canvas.translate(getPaddingLeft(), getPaddingTop());
- canvas.rotate(-mCurrentDegree, w / 2, h / 2);
+
+ int left = getPaddingLeft();
+ int top = getPaddingTop();
+ int right = getPaddingRight();
+ int bottom = getPaddingBottom();
+
+ int width = getWidth() - left - right;
+ int height = getHeight() - top - bottom;
+
+ canvas.translate(left + width / 2, top + height / 2);
+ canvas.rotate(-mDegree);
+ canvas.translate(-w / 2, -h / 2);
drawable.draw(canvas);
canvas.restoreToCount(saveCount);
}
diff --git a/src/com/android/camera/ui/AbstractIndicator.java b/src/com/android/camera/ui/AbstractIndicator.java
index 7b932059..7c6df7c6 100644
--- a/src/com/android/camera/ui/AbstractIndicator.java
+++ b/src/com/android/camera/ui/AbstractIndicator.java
@@ -2,12 +2,16 @@
package com.android.camera.ui;
import android.content.Context;
+import android.graphics.Matrix;
import android.graphics.Rect;
+import android.view.animation.AlphaAnimation;
+import android.view.animation.Transformation;
import javax.microedition.khronos.opengles.GL11;
public abstract class AbstractIndicator extends GLView {
private static final int DEFAULT_PADDING = 3;
+ private int mOrientation = 0;
abstract protected Texture getIcon();
@@ -27,18 +31,37 @@ public abstract class AbstractIndicator extends GLView {
@Override
protected void render(GLRootView root, GL11 gl) {
Texture icon = getIcon();
-
- Rect p = mPaddings;
- int width = getWidth() - p.left - p.right;
- int height = getHeight() - p.top - p.bottom;
-
if (icon != null) {
- icon.draw(root,
- p.left + (width - icon.getWidth()) / 2,
- p.top + (height - icon.getHeight()) / 2);
+ Rect p = mPaddings;
+ int width = getWidth() - p.left - p.right;
+ int height = getHeight() - p.top - p.bottom;
+ if (mOrientation != 0) {
+ Transformation trans = root.pushTransform();
+ Matrix matrix = trans.getMatrix();
+ matrix.preTranslate(p.left + width / 2, p.top + height / 2);
+ matrix.preRotate(-mOrientation);
+ icon.draw(root, -icon.getWidth() / 2, -icon.getHeight() / 2);
+ root.popTransform();
+ } else {
+ icon.draw(root,
+ p.left + (width - icon.getWidth()) / 2,
+ p.top + (height - icon.getHeight()) / 2);
+ }
}
}
+ public void setOrientation(int orientation) {
+ if (orientation % 90 != 0) throw new IllegalArgumentException();
+ orientation = orientation % 360;
+ if (orientation < 0) orientation += 360;
+
+ if (mOrientation == orientation) return;
+ mOrientation = orientation;
+ AlphaAnimation anim = new AlphaAnimation(0.2f, 1);
+ anim.setDuration(200);
+ startAnimation(anim);
+ }
+
abstract public GLView getPopupContent();
abstract public void overrideSettings(String key, String settings);
diff --git a/src/com/android/camera/ui/GLRootView.java b/src/com/android/camera/ui/GLRootView.java
index 84eea06c..92c0f351 100644
--- a/src/com/android/camera/ui/GLRootView.java
+++ b/src/com/android/camera/ui/GLRootView.java
@@ -118,10 +118,11 @@ public class GLRootView extends GLSurfaceView
return mTransformation;
}
- public void pushTransform() {
+ public Transformation pushTransform() {
Transformation trans = obtainTransformation();
trans.set(mTransformation);
mTransformStack.push(trans);
+ return mTransformation;
}
public void popTransform() {
@@ -400,14 +401,14 @@ public class GLRootView extends GLSurfaceView
}
if ((mFlags & FLAG_NEED_LAYOUT) != 0) layoutContentPane();
-
+ clearClip();
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
gl.glEnable(GL11.GL_BLEND);
gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
/*gl.glDisable(GL11.GL_TEXTURE_2D);
gl.glColor4f(0, 0, 0.5f, 0.4f);
- drawRect(30, 30, 30, 30);
+ drawRect(0, 0, 725, 480);
gl.glEnable(GL11.GL_TEXTURE_2D);*/
mAnimationTime = SystemClock.uptimeMillis();
diff --git a/src/com/android/camera/ui/HeadUpDisplay.java b/src/com/android/camera/ui/HeadUpDisplay.java
index fc2628ec..561bd5ba 100644
--- a/src/com/android/camera/ui/HeadUpDisplay.java
+++ b/src/com/android/camera/ui/HeadUpDisplay.java
@@ -17,12 +17,11 @@ import android.view.View.MeasureSpec;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
-import com.android.camera.R;
-
import com.android.camera.CameraSettings;
import com.android.camera.IconListPreference;
import com.android.camera.ListPreference;
import com.android.camera.PreferenceGroup;
+import com.android.camera.R;
import java.util.ArrayList;
import java.util.concurrent.Callable;
@@ -58,8 +57,7 @@ public class HeadUpDisplay extends GLView {
private PopupWindow mPopupWindow;
- private int mAnchorX;
- private int mAnchorY;
+ private GLView mAnchorView;
private int mOrientation = 0;
protected Listener mListener;
@@ -178,7 +176,7 @@ public class HeadUpDisplay extends GLView {
if(mPopupWindow != null
&& mPopupWindow.getVisibility() == GLView.VISIBLE) {
- layoutPopupWindow(mAnchorX, mAnchorY);
+ layoutPopupWindow(mAnchorView);
}
}
@@ -190,9 +188,14 @@ public class HeadUpDisplay extends GLView {
initializeIndicatorBar(context, preferenceGroup);
}
- private void layoutPopupWindow(int anchorX, int anchorY) {
- mAnchorX = anchorX;
- mAnchorY = anchorY;
+ private void layoutPopupWindow(GLView anchorView) {
+
+ mAnchorView = anchorView;
+ Rect rect = new Rect();
+ getBoundsOf(anchorView, rect);
+
+ int anchorX = rect.left + sPopupWindowOverlap;
+ int anchorY = (rect.top + rect.bottom) / 2;
int width = (int) (getWidth() * MAX_WIDTH_RATIO + .5);
int height = (int) (getHeight() * MAX_HEIGHT_RATIO + .5);
@@ -215,8 +218,8 @@ public class HeadUpDisplay extends GLView {
xoffset, yoffset, xoffset + width, yoffset + height);
}
- private void showPopupWindow(int anchorX, int anchorY) {
- layoutPopupWindow(anchorX, anchorY);
+ private void showPopupWindow(GLView anchorView) {
+ layoutPopupWindow(anchorView);
mPopupWindow.popup();
mSharedPrefs.registerOnSharedPreferenceChangeListener(
mSharedPreferenceChangeListener);
@@ -248,9 +251,10 @@ public class HeadUpDisplay extends GLView {
public void setOrientation(int orientation) {
mOrientation = orientation;
+ mIndicatorBar.setOrientation(orientation);
if (mPopupWindow == null) return;
if (mPopupWindow.getVisibility() == GLView.VISIBLE) {
- Animation alpha = new AlphaAnimation(0, 1);
+ Animation alpha = new AlphaAnimation(0.2f, 1);
alpha.setDuration(250);
mPopupWindow.startAnimation(alpha);
scheduleDeactiviateIndicatorBar();
@@ -333,10 +337,6 @@ public class HeadUpDisplay extends GLView {
implements IndicatorBar.OnItemSelectedListener {
public void onItemSelected(GLView view, int position) {
- Rect rect = new Rect();
- getBoundsOf(view, rect);
- int anchorX = rect.left + sPopupWindowOverlap;
- int anchorY = (rect.top + rect.bottom) / 2;
AbstractIndicator indicator = (AbstractIndicator) view;
if (mPopupWindow == null) {
@@ -345,9 +345,9 @@ public class HeadUpDisplay extends GLView {
mPopupWindow.setContent(indicator.getPopupContent());
if (mPopupWindow.getVisibility() == GLView.VISIBLE) {
- layoutPopupWindow(anchorX, anchorY);
+ layoutPopupWindow(indicator);
} else {
- showPopupWindow(anchorX, anchorY);
+ showPopupWindow(indicator);
}
}
diff --git a/src/com/android/camera/ui/IndicatorBar.java b/src/com/android/camera/ui/IndicatorBar.java
index 5ea9261e..090a71ac 100644
--- a/src/com/android/camera/ui/IndicatorBar.java
+++ b/src/com/android/camera/ui/IndicatorBar.java
@@ -175,4 +175,10 @@ public class IndicatorBar extends GLView {
((AbstractIndicator) getComponent(i)).reloadPreferences();
}
}
+
+ public void setOrientation(int orientation) {
+ for (int i = 1, n = getComponentCount(); i < n; ++i) {
+ ((AbstractIndicator) getComponent(i)).setOrientation(orientation);
+ }
+ }
}