summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ui
diff options
context:
space:
mode:
authorByunghun Jeon <bjeon@codeaurora.org>2014-06-16 17:42:26 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2014-11-17 17:49:35 -0800
commit41d18fed018678492323150c661f2b9f6c8931a8 (patch)
tree5154564878f6b61b1edc68ee8241cf0166ca210e /src/com/android/camera/ui
parent0231aab003276d2142fe745e50d6eb44e3f11c9c (diff)
downloadandroid_packages_apps_Snap-41d18fed018678492323150c661f2b9f6c8931a8.tar.gz
android_packages_apps_Snap-41d18fed018678492323150c661f2b9f6c8931a8.tar.bz2
android_packages_apps_Snap-41d18fed018678492323150c661f2b9f6c8931a8.zip
SnapdragonCamera: Modify SnapdragonCamera UI
Modified SnapdragonCamera setting menus with new icons Change-Id: I726296dfb100ac81ad6f1cd84420ae27c0ae1201
Diffstat (limited to 'src/com/android/camera/ui')
-rw-r--r--src/com/android/camera/ui/CameraControls.java611
-rw-r--r--src/com/android/camera/ui/FilmStripView.java110
-rw-r--r--src/com/android/camera/ui/ListMenu.java221
-rw-r--r--src/com/android/camera/ui/ListMenuItem.java162
-rw-r--r--src/com/android/camera/ui/ListSubMenu.java157
-rw-r--r--src/com/android/camera/ui/ModuleSwitcher.java25
-rw-r--r--src/com/android/camera/ui/PieRenderer.java3
7 files changed, 1185 insertions, 104 deletions
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
index 9e0964b4f..5c305acd8 100644
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -16,13 +16,21 @@
package com.android.camera.ui;
+import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
import android.content.Context;
+import android.util.Log;
+import android.graphics.drawable.AnimationDrawable;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
+import android.view.ViewPropertyAnimator;
import android.widget.FrameLayout;
+import java.util.ArrayList;
import org.codeaurora.snapcam.R;
+import com.android.camera.ui.ModuleSwitcher;
+import com.android.camera.ShutterButton;
public class CameraControls extends RotatableLayout {
@@ -32,8 +40,106 @@ public class CameraControls extends RotatableLayout {
private View mShutter;
private View mSwitcher;
private View mMenu;
+ private View mFrontBackSwitcher;
+ private View mFlashSwitcher;
+ private View mHdrSwitcher;
private View mIndicators;
private View mPreview;
+ private View mSceneModeSwitcher;
+ private View mFilterModeSwitcher;
+ private int mSize;
+ private static final int WIDTH_GRID = 5;
+ private static final int HEIGHT_GRID = 7;
+ private static boolean isAnimating = false;
+ private ArrayList<View> mViewList;
+ private static final int FRONT_BACK_INDEX = 0;
+ private static final int FLASH_INDEX = 1;
+ private static final int HDR_INDEX = 2;
+ private static final int SCENE_MODE_INDEX = 3;
+ private static final int FILTER_MODE_INDEX = 4;
+ private static final int SWITCHER_INDEX = 5;
+ private static final int SHUTTER_INDEX = 6;
+ private static final int MENU_INDEX = 7;
+ private static final int INDICATOR_INDEX = 8;
+ private static final int ANIME_DURATION = 300;
+ private float[][] mLocX = new float[4][9];
+ private float[][] mLocY = new float[4][9];
+ private boolean[] mTempEnabled = new boolean[9];
+ private boolean mLocSet = false;
+
+ AnimatorListener outlistener = new AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ resetLocation(0, 0);
+
+ mFrontBackSwitcher.setVisibility(View.INVISIBLE);
+ mFlashSwitcher.setVisibility(View.INVISIBLE);
+ mHdrSwitcher.setVisibility(View.INVISIBLE);
+ mSceneModeSwitcher.setVisibility(View.INVISIBLE);
+ mFilterModeSwitcher.setVisibility(View.INVISIBLE);
+
+ mSwitcher.setVisibility(View.INVISIBLE);
+ mShutter.setVisibility(View.INVISIBLE);
+ mMenu.setVisibility(View.INVISIBLE);
+ mIndicators.setVisibility(View.INVISIBLE);
+ mPreview.setVisibility(View.INVISIBLE);
+ isAnimating = false;
+ enableTouch(true);
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ resetLocation(0, 0);
+
+ mFrontBackSwitcher.setVisibility(View.INVISIBLE);
+ mFlashSwitcher.setVisibility(View.INVISIBLE);
+ mHdrSwitcher.setVisibility(View.INVISIBLE);
+ mSceneModeSwitcher.setVisibility(View.INVISIBLE);
+ mFilterModeSwitcher.setVisibility(View.INVISIBLE);
+
+ mSwitcher.setVisibility(View.INVISIBLE);
+ mShutter.setVisibility(View.INVISIBLE);
+ mMenu.setVisibility(View.INVISIBLE);
+ mIndicators.setVisibility(View.INVISIBLE);
+ mPreview.setVisibility(View.INVISIBLE);
+ isAnimating = false;
+ enableTouch(true);
+ }
+ };
+
+ AnimatorListener inlistener = new AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ isAnimating = false;
+ resetLocation(0, 0);
+ enableTouch(true);
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ isAnimating = false;
+ resetLocation(0, 0);
+ enableTouch(true);
+ }
+ };
public CameraControls(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -45,15 +151,68 @@ public class CameraControls extends RotatableLayout {
setMeasureAllChildren(true);
}
+ public static boolean isAnimating() {
+ return isAnimating;
+ }
+
+ public void enableTouch(boolean enable) {
+ if (enable) {
+ ((ShutterButton) mShutter).setPressed(false);
+ mSwitcher.setPressed(false);
+ mMenu.setPressed(false);
+ mFrontBackSwitcher.setPressed(false);
+ mFlashSwitcher.setPressed(false);
+ mHdrSwitcher.setPressed(false);
+ mSceneModeSwitcher.setPressed(false);
+ mFilterModeSwitcher.setPressed(false);
+ } else {
+ mTempEnabled[FLASH_INDEX] = mFlashSwitcher.isEnabled();
+ mTempEnabled[FILTER_MODE_INDEX] = mFilterModeSwitcher.isEnabled();
+ }
+ ((ShutterButton) mShutter).enableTouch(enable);
+ ((ModuleSwitcher) mSwitcher).enableTouch(enable);
+ mMenu.setEnabled(enable);
+ mFrontBackSwitcher.setEnabled(enable);
+ mFlashSwitcher.setEnabled(enable && mTempEnabled[FLASH_INDEX]);
+ mHdrSwitcher.setEnabled(enable);
+ mSceneModeSwitcher.setEnabled(enable);
+ mFilterModeSwitcher.setEnabled(enable && mTempEnabled[FILTER_MODE_INDEX]);
+ }
+
+ private void markVisibility() {
+ mViewList = new ArrayList<View>();
+ if (mFrontBackSwitcher.getVisibility() == View.VISIBLE)
+ mViewList.add(mFrontBackSwitcher);
+ if (mFlashSwitcher.getVisibility() == View.VISIBLE)
+ mViewList.add(mFlashSwitcher);
+ if (mHdrSwitcher.getVisibility() == View.VISIBLE)
+ mViewList.add(mHdrSwitcher);
+ if (mSceneModeSwitcher.getVisibility() == View.VISIBLE)
+ mViewList.add(mSceneModeSwitcher);
+ if (mFilterModeSwitcher.getVisibility() == View.VISIBLE)
+ mViewList.add(mFilterModeSwitcher);
+ if (mShutter.getVisibility() == View.VISIBLE)
+ mViewList.add(mShutter);
+ if (mMenu.getVisibility() == View.VISIBLE)
+ mViewList.add(mMenu);
+ if (mIndicators.getVisibility() == View.VISIBLE)
+ mViewList.add(mIndicators);
+ }
+
@Override
public void onFinishInflate() {
super.onFinishInflate();
mBackgroundView = findViewById(R.id.blocker);
mSwitcher = findViewById(R.id.camera_switcher);
mShutter = findViewById(R.id.shutter_button);
+ mFrontBackSwitcher = findViewById(R.id.front_back_switcher);
+ mFlashSwitcher = findViewById(R.id.flash_switcher);
+ mHdrSwitcher = findViewById(R.id.hdr_switcher);
mMenu = findViewById(R.id.menu);
mIndicators = findViewById(R.id.on_screen_indicators);
mPreview = findViewById(R.id.preview_thumb);
+ mSceneModeSwitcher = findViewById(R.id.scene_mode_switcher);
+ mFilterModeSwitcher = findViewById(R.id.filter_mode_switcher);
}
@Override
@@ -74,26 +233,12 @@ public class CameraControls extends RotatableLayout {
}
Rect shutter = new Rect();
topRight(mPreview, l, t, r, b);
- if (size > 0) {
- // restrict controls to size
- switch (rotation) {
- case 0:
- case 180:
- l = (l + r - size) / 2;
- r = l + size;
- break;
- case 90:
- case 270:
- t = (t + b - size) / 2;
- b = t + size;
- break;
- }
- }
- center(mShutter, l, t, r, b, orientation, rotation, shutter);
- center(mBackgroundView, l, t, r, b, orientation, rotation, new Rect());
- toLeft(mSwitcher, shutter, rotation);
- toRight(mMenu, shutter, rotation);
- toRight(mIndicators, shutter, rotation);
+ center(mShutter, l, t, r, b, orientation, rotation, shutter, SHUTTER_INDEX);
+ mSize = Math.max(shutter.right - shutter.left, shutter.bottom - shutter.top);
+ center(mBackgroundView, l, t, r, b, orientation, rotation, new Rect(), -1);
+ mBackgroundView.setVisibility(View.GONE);
+ setLocation(r - l, b - t);
+
View retake = findViewById(R.id.btn_retake);
if (retake != null) {
center(retake, shutter, rotation);
@@ -104,41 +249,240 @@ public class CameraControls extends RotatableLayout {
}
}
- private void center(View v, int l, int t, int r, int b, int orientation, int rotation, Rect result) {
+ private void setLocation(int w, int h) {
+ int rotation = getUnifiedRotation();
+ toIndex(mSwitcher, w, h, rotation, 4, 6, SWITCHER_INDEX);
+ toIndex(mMenu, w, h, rotation, 0, 6, MENU_INDEX);
+ toIndex(mIndicators, w, h, rotation, 0, 6, INDICATOR_INDEX);
+ toIndex(mFrontBackSwitcher, w, h, rotation, 2, 0, FRONT_BACK_INDEX);
+ toIndex(mFlashSwitcher, w, h, rotation, 3, 0, FLASH_INDEX);
+ toIndex(mHdrSwitcher, w, h, rotation, 4, 0, HDR_INDEX);
+ toIndex(mFilterModeSwitcher, w, h, rotation, 1, 0, FILTER_MODE_INDEX);
+ toIndex(mSceneModeSwitcher, w, h, rotation, 0, 0, SCENE_MODE_INDEX);
+ }
+
+ private void center(View v, int l, int t, int r, int b, int orientation, int rotation,
+ Rect result, int idx) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
int tw = lp.leftMargin + v.getMeasuredWidth() + lp.rightMargin;
int th = lp.topMargin + v.getMeasuredHeight() + lp.bottomMargin;
switch (rotation) {
- case 0:
- // phone portrait; controls bottom
- result.left = (r + l) / 2 - tw / 2 + lp.leftMargin;
- result.right = (r + l) / 2 + tw / 2 - lp.rightMargin;
- result.bottom = b - lp.bottomMargin;
- result.top = b - th + lp.topMargin;
- break;
- case 90:
- // phone landscape: controls right
- result.right = r - lp.rightMargin;
- result.left = r - tw + lp.leftMargin;
- result.top = (b + t) / 2 - th / 2 + lp.topMargin;
- result.bottom = (b + t) / 2 + th / 2 - lp.bottomMargin;
- break;
- case 180:
- // phone upside down: controls top
- result.left = (r + l) / 2 - tw / 2 + lp.leftMargin;
- result.right = (r + l) / 2 + tw / 2 - lp.rightMargin;
- result.top = t + lp.topMargin;
- result.bottom = t + th - lp.bottomMargin;
- break;
- case 270:
- // reverse landscape: controls left
- result.left = l + lp.leftMargin;
- result.right = l + tw - lp.rightMargin;
- result.top = (b + t) / 2 - th / 2 + lp.topMargin;
- result.bottom = (b + t) / 2 + th / 2 - lp.bottomMargin;
- break;
+ case 0:
+ // phone portrait; controls bottom
+ result.left = (r + l) / 2 - tw / 2 + lp.leftMargin;
+ result.right = (r + l) / 2 + tw / 2 - lp.rightMargin;
+ result.bottom = b - lp.bottomMargin;
+ result.top = b - th + lp.topMargin;
+ break;
+ case 90:
+ // phone landscape: controls right
+ result.right = r - lp.rightMargin;
+ result.left = r - tw + lp.leftMargin;
+ result.top = (b + t) / 2 - th / 2 + lp.topMargin;
+ result.bottom = (b + t) / 2 + th / 2 - lp.bottomMargin;
+ break;
+ case 180:
+ // phone upside down: controls top
+ result.left = (r + l) / 2 - tw / 2 + lp.leftMargin;
+ result.right = (r + l) / 2 + tw / 2 - lp.rightMargin;
+ result.top = t + lp.topMargin;
+ result.bottom = t + th - lp.bottomMargin;
+ break;
+ case 270:
+ // reverse landscape: controls left
+ result.left = l + lp.leftMargin;
+ result.right = l + tw - lp.rightMargin;
+ result.top = (b + t) / 2 - th / 2 + lp.topMargin;
+ result.bottom = (b + t) / 2 + th / 2 - lp.bottomMargin;
+ break;
}
v.layout(result.left, result.top, result.right, result.bottom);
+ if (idx != -1) {
+ int idx1 = rotation / 90;
+ int idx2 = idx;
+ mLocX[idx1][idx2] = result.left;
+ mLocY[idx1][idx2] = result.top;
+ }
+ }
+
+ private void resetLocation(float x, float y) {
+ int rotation = getUnifiedRotation();
+ int idx1 = rotation / 90;
+
+ mFrontBackSwitcher.setX(mLocX[idx1][FRONT_BACK_INDEX] + x);
+ mFlashSwitcher.setX(mLocX[idx1][FLASH_INDEX] + x);
+ mHdrSwitcher.setX(mLocX[idx1][HDR_INDEX] + x);
+ mSceneModeSwitcher.setX(mLocX[idx1][SCENE_MODE_INDEX] + x);
+ mFilterModeSwitcher.setX(mLocX[idx1][FILTER_MODE_INDEX] + x);
+ mSwitcher.setX(mLocX[idx1][SWITCHER_INDEX] - x);
+ mShutter.setX(mLocX[idx1][SHUTTER_INDEX] - x);
+ mMenu.setX(mLocX[idx1][MENU_INDEX] - x);
+ mIndicators.setX(mLocX[idx1][INDICATOR_INDEX] - x);
+
+ mFrontBackSwitcher.setY(mLocY[idx1][FRONT_BACK_INDEX] + y);
+ mFlashSwitcher.setY(mLocY[idx1][FLASH_INDEX] + y);
+ mHdrSwitcher.setY(mLocY[idx1][HDR_INDEX] + y);
+ mSceneModeSwitcher.setY(mLocY[idx1][SCENE_MODE_INDEX] + y);
+ mFilterModeSwitcher.setY(mLocY[idx1][FILTER_MODE_INDEX] + y);
+ mSwitcher.setY(mLocY[idx1][SWITCHER_INDEX] - y);
+ mShutter.setY(mLocY[idx1][SHUTTER_INDEX] - y);
+ mMenu.setY(mLocY[idx1][MENU_INDEX] - y);
+ mIndicators.setY(mLocY[idx1][INDICATOR_INDEX] - y);
+ }
+
+ public void hideUI() {
+ isAnimating = true;
+ enableTouch(false);
+ int rotation = getUnifiedRotation();
+ mFrontBackSwitcher.animate().cancel();
+ mFlashSwitcher.animate().cancel();
+ mHdrSwitcher.animate().cancel();
+ mSceneModeSwitcher.animate().cancel();
+ mFilterModeSwitcher.animate().cancel();
+ mSwitcher.animate().cancel();
+ mShutter.animate().cancel();
+ mMenu.animate().cancel();
+ mIndicators.animate().cancel();
+ mFrontBackSwitcher.animate().setListener(outlistener);
+ ((ModuleSwitcher) mSwitcher).removePopup();
+ resetLocation(0, 0);
+ markVisibility();
+ switch (rotation) {
+ case 0:
+ mFrontBackSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mFlashSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mHdrSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mSceneModeSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mFilterModeSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+
+ mSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mShutter.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mMenu.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mIndicators.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ break;
+ case 90:
+ mFrontBackSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mFlashSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mHdrSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mSceneModeSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mFilterModeSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+
+ mSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mShutter.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mMenu.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mIndicators.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ break;
+ case 180:
+ mFrontBackSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mFlashSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mHdrSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mSceneModeSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mFilterModeSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+
+ mSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mShutter.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mMenu.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mIndicators.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ break;
+ case 270:
+ mFrontBackSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mFlashSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mHdrSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mSceneModeSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mFilterModeSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+
+ mSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mShutter.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mMenu.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mIndicators.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ break;
+ }
+ }
+
+ public void showUI() {
+ isAnimating = true;
+ enableTouch(false);
+ int rotation = getUnifiedRotation();
+ mFrontBackSwitcher.animate().cancel();
+ mFlashSwitcher.animate().cancel();
+ mHdrSwitcher.animate().cancel();
+ mSceneModeSwitcher.animate().cancel();
+ mFilterModeSwitcher.animate().cancel();
+ mSwitcher.animate().cancel();
+ mShutter.animate().cancel();
+ mMenu.animate().cancel();
+ mIndicators.animate().cancel();
+ if (mViewList != null)
+ for (View v : mViewList) {
+ v.setVisibility(View.VISIBLE);
+ }
+ ((ModuleSwitcher) mSwitcher).removePopup();
+ AnimationDrawable shutterAnim = (AnimationDrawable) mShutter.getBackground();
+ if (shutterAnim != null)
+ shutterAnim.stop();
+
+ mMenu.setVisibility(View.VISIBLE);
+ mIndicators.setVisibility(View.VISIBLE);
+
+ mFrontBackSwitcher.animate().setListener(inlistener);
+ switch (rotation) {
+ case 0:
+ resetLocation(0, -mSize);
+
+ mFrontBackSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mFlashSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mHdrSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mSceneModeSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mFilterModeSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+
+ mSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mShutter.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mMenu.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mIndicators.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ break;
+ case 90:
+ resetLocation(-mSize, 0);
+
+ mFrontBackSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mFlashSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mHdrSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mSceneModeSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mFilterModeSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+
+ mSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mShutter.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mMenu.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mIndicators.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ break;
+ case 180:
+ resetLocation(0, mSize);
+
+ mFrontBackSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mFlashSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mHdrSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mSceneModeSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ mFilterModeSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+
+ mSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mShutter.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mMenu.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ mIndicators.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ break;
+ case 270:
+ resetLocation(mSize, 0);
+
+ mFrontBackSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mFlashSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mHdrSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mSceneModeSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ mFilterModeSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+
+ mSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mShutter.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mMenu.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ mIndicators.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ break;
+ }
}
private void center(View v, Rect other, int rotation) {
@@ -153,6 +497,65 @@ public class CameraControls extends RotatableLayout {
cy + th / 2 - lp.bottomMargin);
}
+ private void toIndex(View v, int w, int h, int rotation, int index, int index2, int index3) {
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
+ int tw = v.getMeasuredWidth();
+ int th = v.getMeasuredHeight();
+ int l = 0, r = 0, t = 0, b = 0;
+
+ int wnumber = WIDTH_GRID;
+ int hnumber = HEIGHT_GRID;
+ int windex = 0;
+ int hindex = 0;
+ switch (rotation) {
+ case 0:
+ // portrait, to left of anchor at bottom
+ wnumber = WIDTH_GRID;
+ hnumber = HEIGHT_GRID;
+ windex = index;
+ hindex = index2;
+ break;
+ case 90:
+ // phone landscape: below anchor on right
+ wnumber = HEIGHT_GRID;
+ hnumber = WIDTH_GRID;
+ windex = index2;
+ hindex = hnumber - index - 1;
+ break;
+ case 180:
+ // phone upside down: right of anchor at top
+ wnumber = WIDTH_GRID;
+ hnumber = HEIGHT_GRID;
+ windex = wnumber - index - 1;
+ hindex = hnumber - index2 - 1;
+ break;
+ case 270:
+ // reverse landscape: above anchor on left
+ wnumber = HEIGHT_GRID;
+ hnumber = WIDTH_GRID;
+ windex = wnumber - index2 - 1;
+ hindex = index;
+ break;
+ }
+ int boxh = h / hnumber;
+ int boxw = w / wnumber;
+ int cx = (2 * windex + 1) * boxw / 2;
+ int cy = (2 * hindex + 1) * boxh / 2;
+
+ l = cx - tw / 2;
+ r = cx + tw / 2;
+ t = cy - th / 2;
+ b = cy + th / 2;
+
+ if (index3 != -1) {
+ int idx1 = rotation / 90;
+ int idx2 = index3;
+ mLocX[idx1][idx2] = l;
+ mLocY[idx1][idx2] = t;
+ }
+ v.layout(l, t, r, b);
+ }
+
private void toLeft(View v, Rect other, int rotation) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
int tw = lp.leftMargin + v.getMeasuredWidth() + lp.rightMargin;
@@ -161,34 +564,34 @@ public class CameraControls extends RotatableLayout {
int cy = (other.top + other.bottom) / 2;
int l = 0, r = 0, t = 0, b = 0;
switch (rotation) {
- case 0:
- // portrait, to left of anchor at bottom
- l = other.left - tw + lp.leftMargin;
- r = other.left - lp.rightMargin;
- t = cy - th / 2 + lp.topMargin;
- b = cy + th / 2 - lp.bottomMargin;
- break;
- case 90:
- // phone landscape: below anchor on right
- l = cx - tw / 2 + lp.leftMargin;
- r = cx + tw / 2 - lp.rightMargin;
- t = other.bottom + lp.topMargin;
- b = other.bottom + th - lp.bottomMargin;
- break;
- case 180:
- // phone upside down: right of anchor at top
- l = other.right + lp.leftMargin;
- r = other.right + tw - lp.rightMargin;
- t = cy - th / 2 + lp.topMargin;
- b = cy + th / 2 - lp.bottomMargin;
- break;
- case 270:
- // reverse landscape: above anchor on left
- l = cx - tw / 2 + lp.leftMargin;
- r = cx + tw / 2 - lp.rightMargin;
- t = other.top - th + lp.topMargin;
- b = other.top - lp.bottomMargin;
- break;
+ case 0:
+ // portrait, to left of anchor at bottom
+ l = other.left - tw + lp.leftMargin;
+ r = other.left - lp.rightMargin;
+ t = cy - th / 2 + lp.topMargin;
+ b = cy + th / 2 - lp.bottomMargin;
+ break;
+ case 90:
+ // phone landscape: below anchor on right
+ l = cx - tw / 2 + lp.leftMargin;
+ r = cx + tw / 2 - lp.rightMargin;
+ t = other.bottom + lp.topMargin;
+ b = other.bottom + th - lp.bottomMargin;
+ break;
+ case 180:
+ // phone upside down: right of anchor at top
+ l = other.right + lp.leftMargin;
+ r = other.right + tw - lp.rightMargin;
+ t = cy - th / 2 + lp.topMargin;
+ b = cy + th / 2 - lp.bottomMargin;
+ break;
+ case 270:
+ // reverse landscape: above anchor on left
+ l = cx - tw / 2 + lp.leftMargin;
+ r = cx + tw / 2 - lp.rightMargin;
+ t = other.top - th + lp.topMargin;
+ b = other.top - lp.bottomMargin;
+ break;
}
v.layout(l, t, r, b);
}
@@ -201,36 +604,37 @@ public class CameraControls extends RotatableLayout {
int cy = (other.top + other.bottom) / 2;
int l = 0, r = 0, t = 0, b = 0;
switch (rotation) {
- case 0:
- l = other.right + lp.leftMargin;
- r = other.right + tw - lp.rightMargin;
- t = cy - th / 2 + lp.topMargin;
- b = cy + th / 2 - lp.bottomMargin;
- break;
- case 90:
- l = cx - tw / 2 + lp.leftMargin;
- r = cx + tw / 2 - lp.rightMargin;
- t = other.top - th + lp.topMargin;
- b = other.top - lp.bottomMargin;
- break;
- case 180:
- l = other.left - tw + lp.leftMargin;
- r = other.left - lp.rightMargin;
- t = cy - th / 2 + lp.topMargin;
- b = cy + th / 2 - lp.bottomMargin;
- break;
- case 270:
- l = cx - tw / 2 + lp.leftMargin;
- r = cx + tw / 2 - lp.rightMargin;
- t = other.bottom + lp.topMargin;
- b = other.bottom + th - lp.bottomMargin;
- break;
+ case 0:
+ l = other.right + lp.leftMargin;
+ r = other.right + tw - lp.rightMargin;
+ t = cy - th / 2 + lp.topMargin;
+ b = cy + th / 2 - lp.bottomMargin;
+ break;
+ case 90:
+ l = cx - tw / 2 + lp.leftMargin;
+ r = cx + tw / 2 - lp.rightMargin;
+ t = other.top - th + lp.topMargin;
+ b = other.top - lp.bottomMargin;
+ break;
+ case 180:
+ l = other.left - tw + lp.leftMargin;
+ r = other.left - lp.rightMargin;
+ t = cy - th / 2 + lp.topMargin;
+ b = cy + th / 2 - lp.bottomMargin;
+ break;
+ case 270:
+ l = cx - tw / 2 + lp.leftMargin;
+ r = cx + tw / 2 - lp.rightMargin;
+ t = other.bottom + lp.topMargin;
+ b = other.bottom + th - lp.bottomMargin;
+ break;
}
v.layout(l, t, r, b);
}
private void topRight(View v, int l, int t, int r, int b) {
- // layout using the specific margins; the rotation code messes up the others
+ // layout using the specific margins; the rotation code messes up the
+ // others
int mt = getContext().getResources().getDimensionPixelSize(R.dimen.capture_margin_top);
int mr = getContext().getResources().getDimensionPixelSize(R.dimen.capture_margin_right);
v.layout(r - v.getMeasuredWidth() - mr, t + mt, r - mr, t + mt + v.getMeasuredHeight());
@@ -242,7 +646,8 @@ public class CameraControls extends RotatableLayout {
mBackgroundView.setBackgroundDrawable(null);
mBackgroundView.setRotationX(0);
mBackgroundView.setRotationY(0);
- // if the switcher background is top aligned we need to flip the background
+ // if the switcher background is top aligned we need to flip the
+ // background
// drawable vertically; if left aligned, flip horizontally
switch (rotation) {
case 180:
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java
index f892934e2..8da49a10a 100644
--- a/src/com/android/camera/ui/FilmStripView.java
+++ b/src/com/android/camera/ui/FilmStripView.java
@@ -37,10 +37,14 @@ import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.widget.Scroller;
+import com.android.camera.CustomPhotoMenu;
+import com.android.camera.CustomVideoMenu;
+import com.android.camera.PreviewGestures;
import com.android.camera.CameraActivity;
import com.android.camera.data.LocalData;
import com.android.camera.ui.FilmStripView.ImageData.PanoramaSupportCallback;
import com.android.camera.ui.FilmstripBottomControls.BottomControlsListener;
+import com.android.camera.ui.RenderOverlay;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.PhotoSphereHelper.PanoramaViewHelper;
import com.android.camera.util.UsageStatistics;
@@ -97,7 +101,11 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
private float mOverScaleFactor = 1f;
private int mLastTotalNumber = 0;
-
+ private RenderOverlay mRenderOverlay;
+ private PreviewGestures mPreviewGestures;
+ private boolean mSendToPreviewMenu;
+ private boolean mSendToMenu;
+ private boolean mReset;
/**
* Common interface for all images in the filmstrip.
*/
@@ -705,6 +713,13 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
}
}
+ public void setRenderOverlay(RenderOverlay renderOverlay) {
+ mRenderOverlay = renderOverlay;
+ }
+ public void setPreviewGestures(PreviewGestures previewGestures) {
+ mPreviewGestures = previewGestures;
+ }
+
/**
* Returns the controller.
*
@@ -1807,6 +1822,95 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
return true;
}
+ public boolean checkSendToModeView(MotionEvent ev) {
+ if (mSendToPreviewMenu || mSendToMenu || mPreviewGestures == null)
+ return true;
+ CustomPhotoMenu pMenu = mPreviewGestures.getCustomPhotoMenu();
+ CustomVideoMenu vMenu = mPreviewGestures.getCustomVideoMenu();
+ if (pMenu != null) {
+ if (pMenu.isMenuBeingShown()) {
+ if (pMenu.isMenuBeingAnimated()) {
+ if (pMenu.isOverMenu(ev)) {
+ mSendToMenu = true;
+ return true;
+ }
+ }
+ }
+
+ if (pMenu.isPreviewMenuBeingShown()) {
+ if (pMenu.isOverPreviewMenu(ev)) {
+ mSendToPreviewMenu = true;
+ return true;
+ }
+ }
+ }
+ if (vMenu != null) {
+ if (vMenu.isMenuBeingShown()) {
+ if (vMenu.isMenuBeingAnimated()) {
+ if (vMenu.isOverMenu(ev)) {
+ mSendToMenu = true;
+ return true;
+ }
+ }
+ }
+
+ if (vMenu.isPreviewMenuBeingShown()) {
+ if (vMenu.isOverPreviewMenu(ev)) {
+ mSendToPreviewMenu = true;
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public boolean sendToModeView(MotionEvent ev) {
+ if (mPreviewGestures == null) {
+ return false;
+ }
+ if (mReset) {
+ mSendToPreviewMenu = false;
+ mSendToMenu = false;
+ mReset = false;
+ }
+ if (mSendToPreviewMenu || mSendToMenu) {
+ if (MotionEvent.ACTION_UP == ev.getActionMasked()
+ || MotionEvent.ACTION_CANCEL == ev.getActionMasked())
+ mReset = true;
+ }
+ CustomPhotoMenu pMenu = mPreviewGestures.getCustomPhotoMenu();
+ CustomVideoMenu vMenu = mPreviewGestures.getCustomVideoMenu();
+
+ if (pMenu != null) {
+ if (mSendToPreviewMenu)
+ return pMenu.sendTouchToPreviewMenu(ev);
+ if (mSendToMenu)
+ return pMenu.sendTouchToMenu(ev);
+ if (pMenu.isMenuBeingShown()) {
+ return pMenu.sendTouchToMenu(ev);
+ }
+
+ if (pMenu.isPreviewMenuBeingShown()) {
+ return pMenu.sendTouchToPreviewMenu(ev);
+ }
+ }
+
+ if (vMenu != null) {
+ if (mSendToPreviewMenu)
+ return vMenu.sendTouchToPreviewMenu(ev);
+ if (mSendToMenu)
+ return vMenu.sendTouchToMenu(ev);
+ if (vMenu.isMenuBeingShown()) {
+ return vMenu.sendTouchToMenu(ev);
+ }
+
+ if (vMenu.isPreviewMenuBeingShown()) {
+ return vMenu.sendTouchToPreviewMenu(ev);
+ }
+ }
+ return false;
+ }
+
private void updateViewItem(int itemID) {
ViewItem item = mViewItem[itemID];
if (item == null) {
@@ -2714,6 +2818,8 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
@Override
public boolean onScroll(float x, float y, float dx, float dy) {
+ if (mPreviewGestures != null && mPreviewGestures.waitUntilNextDown())
+ return false;
ViewItem currItem = mViewItem[mCurrentItem];
if (currItem == null) {
return false;
@@ -2779,6 +2885,8 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
@Override
public boolean onFling(float velocityX, float velocityY) {
+ if (mPreviewGestures != null && mPreviewGestures.waitUntilNextDown())
+ return false;
final ViewItem currItem = mViewItem[mCurrentItem];
if (currItem == null) {
return false;
diff --git a/src/com/android/camera/ui/ListMenu.java b/src/com/android/camera/ui/ListMenu.java
new file mode 100644
index 000000000..53cd48d9c
--- /dev/null
+++ b/src/com/android/camera/ui/ListMenu.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
+ * Copyright (C) 2010 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 java.util.ArrayList;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+import com.android.camera.ListPreference;
+import com.android.camera.PreferenceGroup;
+import org.codeaurora.snapcam.R;
+
+/* A popup window that contains several camera settings. */
+public class ListMenu extends ListView
+ implements ListMenuItem.Listener,
+ AdapterView.OnItemClickListener {
+ @SuppressWarnings("unused")
+ private static final String TAG = "ListMenu";
+ private Listener mListener;
+ private ArrayList<ListPreference> mListItem = new ArrayList<ListPreference>();
+
+ // Keep track of which setting items are disabled
+ // e.g. White balance will be disabled when scene mode is set to non-auto
+ private boolean[] mEnabled;
+
+ static public interface Listener {
+ public void onSettingChanged(ListPreference pref);
+
+ public void onPreferenceClicked(ListPreference pref);
+
+ public void onPreferenceClicked(ListPreference pref, int y);
+
+ public void onListMenuTouched();
+ }
+
+ private class MoreSettingAdapter extends ArrayAdapter<ListPreference> {
+ LayoutInflater mInflater;
+ String mOnString;
+ String mOffString;
+
+ MoreSettingAdapter() {
+ super(ListMenu.this.getContext(), 0, mListItem);
+ Context context = getContext();
+ mInflater = LayoutInflater.from(context);
+ mOnString = context.getString(R.string.setting_on);
+ mOffString = context.getString(R.string.setting_off);
+ }
+
+ private int getSettingLayoutId(ListPreference pref) {
+ return R.layout.list_menu_item;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ListPreference pref = mListItem.get(position);
+ int viewLayoutId = getSettingLayoutId(pref);
+ ListMenuItem view = (ListMenuItem) convertView;
+
+ view = (ListMenuItem)
+ mInflater.inflate(viewLayoutId, parent, false);
+
+ view.initialize(pref); // no init for restore one
+ view.setSettingChangedListener(ListMenu.this);
+ if (position >= 0 && position < mEnabled.length) {
+ view.setEnabled(mEnabled[position]);
+ } else {
+ Log.w(TAG, "Invalid input: enabled list length, " + mEnabled.length
+ + " position " + position);
+ }
+ return view;
+ }
+
+ @Override
+ public boolean isEnabled(int position) {
+ if (position >= 0 && position < mEnabled.length) {
+ return mEnabled[position];
+ }
+ return true;
+ }
+ }
+
+ public void setSettingChangedListener(Listener listener) {
+ mListener = listener;
+ }
+
+ public ListMenu(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public void initialize(PreferenceGroup group, String[] keys) {
+ // Prepare the setting items.
+ for (int i = 0; i < keys.length; ++i) {
+ ListPreference pref = group.findPreference(keys[i]);
+ if (pref != null)
+ mListItem.add(pref);
+ }
+
+ ArrayAdapter<ListPreference> mListItemAdapter = new MoreSettingAdapter();
+ setAdapter(mListItemAdapter);
+ setOnItemClickListener(this);
+ setSelector(android.R.color.transparent);
+ // Initialize mEnabled
+ mEnabled = new boolean[mListItem.size()];
+ for (int i = 0; i < mEnabled.length; i++) {
+ mEnabled[i] = true;
+ }
+ }
+
+ // When preferences are disabled, we will display them grayed out. Users
+ // will not be able to change the disabled preferences, but they can still
+ // see
+ // the current value of the preferences
+ public void setPreferenceEnabled(String key, boolean enable) {
+ int count = mEnabled == null ? 0 : mEnabled.length;
+ for (int j = 0; j < count; j++) {
+ ListPreference pref = mListItem.get(j);
+ if (pref != null && key.equals(pref.getKey())) {
+ mEnabled[j] = enable;
+ break;
+ }
+ }
+ }
+
+ public void onSettingChanged(ListPreference pref) {
+ if (mListener != null) {
+ mListener.onSettingChanged(pref);
+ }
+ }
+
+ // Scene mode can override other camera settings (ex: flash mode).
+ public void overrideSettings(final String... keyvalues) {
+ int count = mEnabled == null ? 0 : mEnabled.length;
+ for (int i = 0; i < keyvalues.length; i += 2) {
+ String key = keyvalues[i];
+ String value = keyvalues[i + 1];
+ for (int j = 0; j < count; j++) {
+ ListPreference pref = mListItem.get(j);
+ if (pref != null && key.equals(pref.getKey())) {
+ // Change preference
+ if (value != null)
+ pref.setValue(value);
+ // If the preference is overridden, disable the preference
+ boolean enable = value == null;
+ mEnabled[j] = enable;
+ if (getChildCount() > j) {
+ getChildAt(j).setEnabled(enable);
+ }
+ }
+ }
+ }
+ reloadPreference();
+ }
+
+ public void resetHighlight() {
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ View v = getChildAt(i);
+ v.setBackground(null);
+ }
+
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent ev) {
+ if (ev.getAction() == MotionEvent.ACTION_MOVE) {
+ mListener.onListMenuTouched();
+ resetHighlight();
+ }
+ return super.onTouchEvent(ev);
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position,
+ long id) {
+ if (mListener != null) {
+ resetHighlight();
+ ListPreference pref = mListItem.get(position);
+ view.setBackgroundColor(getContext().getResources().getColor(R.color.setting_color));
+ mListener.onPreferenceClicked(pref, (int) view.getY());
+ }
+
+ }
+
+ public void reloadPreference() {
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ ListPreference pref = mListItem.get(i);
+ if (pref != null) {
+ ListMenuItem listMenuItem =
+ (ListMenuItem) getChildAt(i);
+ listMenuItem.reloadPreference();
+ }
+ }
+ }
+}
diff --git a/src/com/android/camera/ui/ListMenuItem.java b/src/com/android/camera/ui/ListMenuItem.java
new file mode 100644
index 000000000..f3c7f017e
--- /dev/null
+++ b/src/com/android/camera/ui/ListMenuItem.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
+ * 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.view.accessibility.AccessibilityEvent;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+import android.widget.ImageView;
+
+import com.android.camera.ListPreference;
+import com.android.camera.IconListPreference;
+import org.codeaurora.snapcam.R;
+
+/**
+ * A one-line camera setting could be one of three types: knob, switch or
+ * restore preference button. The setting includes a title for showing the
+ * preference title which is initialized in the SimpleAdapter. A knob also
+ * includes (ex: Picture size), a previous button, the current value (ex: 5MP),
+ * and a next button. A switch, i.e. the preference RecordLocationPreference,
+ * has only two values on and off which will be controlled in a switch button.
+ * Other setting popup window includes several InLineSettingItem items with
+ * different types if possible.
+ */
+public class ListMenuItem extends RelativeLayout {
+ private static final String TAG = "ListMenuItem";
+ private Listener mListener;
+ protected ListPreference mPreference;
+ protected int mIndex;
+ // Scene mode can override the original preference value.
+ protected String mOverrideValue;
+ protected TextView mTitle;
+ private TextView mEntry;
+ private ImageView mIcon;
+
+ static public interface Listener {
+ public void onSettingChanged(ListPreference pref);
+ }
+
+ public ListMenuItem(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mEntry = (TextView) findViewById(R.id.current_setting);
+ mIcon = (ImageView) findViewById(R.id.list_image);
+ }
+
+ protected void setTitle(ListPreference preference) {
+ mTitle = ((TextView) findViewById(R.id.title));
+ mTitle.setText(preference.getTitle());
+ }
+
+ protected void setIcon(ListPreference preference) {
+ if (preference instanceof IconListPreference) {
+ int resId = ((IconListPreference) preference).getSingleIcon();
+ mIcon.setImageResource(resId);
+ }
+
+ }
+
+ public void initialize(ListPreference preference) {
+ setTitle(preference);
+ if (preference == null)
+ return;
+ setIcon(preference);
+ mPreference = preference;
+ reloadPreference();
+ }
+
+ protected void updateView() {
+ if (mOverrideValue == null) {
+ mEntry.setText(mPreference.getEntry());
+ } else {
+ int index = mPreference.findIndexOfValue(mOverrideValue);
+ if (index != -1) {
+ mEntry.setText(mPreference.getEntries()[index]);
+ } else {
+ // Avoid the crash if camera driver has bugs.
+ Log.e(TAG, "Fail to find override value=" + mOverrideValue);
+ mPreference.print();
+ }
+ }
+ }
+
+ protected boolean changeIndex(int index) {
+ if (index >= mPreference.getEntryValues().length || index < 0)
+ return false;
+ mIndex = index;
+ mPreference.setValueIndex(mIndex);
+ if (mListener != null) {
+ mListener.onSettingChanged(mPreference);
+ }
+ updateView();
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
+ return true;
+ }
+
+ // The value of the preference may have changed. Update the UI.
+ public void reloadPreference() {
+ mIndex = mPreference.findIndexOfValue(mPreference.getValue());
+ updateView();
+ }
+
+ public void setSettingChangedListener(Listener listener) {
+ mListener = listener;
+ }
+
+ public void overrideSettings(String value) {
+ mOverrideValue = value;
+ updateView();
+ }
+
+ @Override
+ public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+ event.getText().add(mPreference.getTitle() + mPreference.getEntry());
+ return true;
+ }
+
+ @Override
+ public void setEnabled(boolean enable) {
+ super.setEnabled(enable);
+ if (enable)
+ setAlpha(1f);
+ else
+ setAlpha(0.3f);
+ if (mTitle != null) {
+ mTitle.setEnabled(enable);
+ if (enable)
+ setAlpha(1f);
+ else
+ setAlpha(0.3f);
+ }
+ if (mEntry != null) {
+ mEntry.setEnabled(enable);
+ if (enable)
+ setAlpha(1f);
+ else
+ setAlpha(0.3f);
+ }
+ }
+}
diff --git a/src/com/android/camera/ui/ListSubMenu.java b/src/com/android/camera/ui/ListSubMenu.java
new file mode 100644
index 000000000..af38b162a
--- /dev/null
+++ b/src/com/android/camera/ui/ListSubMenu.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
+ * Copyright (C) 2010 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 java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+
+import com.android.camera.IconListPreference;
+import com.android.camera.ListPreference;
+import org.codeaurora.snapcam.R;
+
+// A popup window that shows one camera setting. The title is the name of the
+// setting (ex: white-balance). The entries are the supported values (ex:
+// daylight, incandescent, etc). If initialized with an IconListPreference,
+// the entries will contain both text and icons. Otherwise, entries will be
+// shown in text.
+public class ListSubMenu extends ListView implements
+ AdapterView.OnItemClickListener {
+ private static final String TAG = "ListPrefSettingPopup";
+ private ListPreference mPreference;
+ private Listener mListener;
+ private int mY;
+
+ static public interface Listener {
+ public void onListPrefChanged(ListPreference pref);
+ }
+
+ public ListSubMenu(Context context, int listRes) {
+ super(context);
+ }
+
+ public ListSubMenu(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ private class ListPrefSettingAdapter extends SimpleAdapter {
+ ListPrefSettingAdapter(Context context, List<? extends Map<String, ?>> data,
+ int resource, String[] from, int[] to) {
+ super(context, data, resource, from, to);
+ }
+
+ @Override
+ public void setViewImage(ImageView v, String value) {
+ if ("".equals(value)) {
+ // Some settings have no icons. Ex: exposure compensation.
+ v.setVisibility(View.GONE);
+ } else {
+ super.setViewImage(v, value);
+ }
+ }
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ int screenHeight = ((LinearLayout) getParent()).getHeight();
+ super.onLayout(changed, l, t, r, b);
+ setY(Math.max(0, mY));
+ if (mY + (b - t) > screenHeight) {
+ setY(Math.max(0, mY - (mY + (b - t) - screenHeight)));
+ }
+ }
+
+ public void initialize(ListPreference preference, int y) {
+ mPreference = preference;
+ Context context = getContext();
+ CharSequence[] entries = mPreference.getEntries();
+ int[] iconIds = null;
+ if (preference instanceof IconListPreference) {
+ iconIds = ((IconListPreference) mPreference).getImageIds();
+ if (iconIds == null) {
+ iconIds = ((IconListPreference) mPreference).getLargeIconIds();
+ }
+ }
+ mY = y;
+
+ // Prepare the ListView.
+ ArrayList<HashMap<String, Object>> listItem =
+ new ArrayList<HashMap<String, Object>>();
+ for (int i = 0; i < entries.length; ++i) {
+ HashMap<String, Object> map = new HashMap<String, Object>();
+ map.put("text", entries[i].toString());
+ if (iconIds != null)
+ map.put("image", iconIds[i]);
+ listItem.add(map);
+ }
+ SimpleAdapter listItemAdapter = new ListPrefSettingAdapter(context, listItem,
+ R.layout.list_sub_menu_item,
+ new String[] {
+ "text", "image"
+ },
+ new int[] {
+ R.id.text, R.id.image
+ });
+ setAdapter(listItemAdapter);
+ setOnItemClickListener(this);
+ reloadPreference();
+ }
+
+ // The value of the preference may have changed. Update the UI.
+ // @Override
+ public void reloadPreference() {
+ int index = mPreference.findIndexOfValue(mPreference.getValue());
+ if (index != -1) {
+ setItemChecked(index, true);
+ } else {
+ Log.e(TAG, "Invalid preference value.");
+ mPreference.print();
+ }
+ }
+
+ public void setSettingChangedListener(Listener listener) {
+ mListener = listener;
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int index, long id) {
+ mPreference.setValueIndex(index);
+ if (mListener != null)
+ mListener.onListPrefChanged(mPreference);
+ }
+
+ @Override
+ protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
+ super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
+ }
+}
diff --git a/src/com/android/camera/ui/ModuleSwitcher.java b/src/com/android/camera/ui/ModuleSwitcher.java
index 60fed24ad..3f9ccd5ec 100644
--- a/src/com/android/camera/ui/ModuleSwitcher.java
+++ b/src/com/android/camera/ui/ModuleSwitcher.java
@@ -52,6 +52,7 @@ public class ModuleSwitcher extends RotateImageView
public static final int WIDE_ANGLE_PANO_MODULE_INDEX = 2;
public static final int LIGHTCYCLE_MODULE_INDEX = 3;
public static final int GCAM_MODULE_INDEX = 4;
+ private boolean mTouchEnabled = true;
private static final int[] DRAW_IDS = {
R.drawable.ic_switch_camera,
@@ -146,6 +147,20 @@ public class ModuleSwitcher extends RotateImageView
}
@Override
+ public boolean dispatchTouchEvent(MotionEvent m) {
+ if (mTouchEnabled) {
+ return super.dispatchTouchEvent(m);
+ } else {
+ setBackground(null);
+ return false;
+ }
+ }
+
+ public void enableTouch(boolean enable) {
+ mTouchEnabled = enable;
+ }
+
+ @Override
public void onClick(View v) {
showSwitcher();
mListener.onShowSwitcherPopup();
@@ -254,6 +269,16 @@ public class ModuleSwitcher extends RotateImageView
mParent.setOnTouchListener(null);
}
+ public void removePopup() {
+ mShowingPopup = false;
+ setVisibility(View.VISIBLE);
+ if (mPopup != null) {
+ ((ViewGroup) mParent).removeView(mPopup);
+ mPopup = null;
+ }
+ setAlpha(1f);
+ }
+
@Override
public void onConfigurationChanged(Configuration config) {
if (showsPopup()) {
diff --git a/src/com/android/camera/ui/PieRenderer.java b/src/com/android/camera/ui/PieRenderer.java
index 13ead421e..324e0fe98 100644
--- a/src/com/android/camera/ui/PieRenderer.java
+++ b/src/com/android/camera/ui/PieRenderer.java
@@ -36,6 +36,7 @@ import android.view.ViewConfiguration;
import android.view.animation.Animation;
import android.view.animation.Transformation;
+import com.android.camera.CameraActivity;
import com.android.camera.drawable.TextDrawable;
import com.android.camera.ui.ProgressRenderer.VisibilityListener;
import org.codeaurora.snapcam.R;
@@ -636,6 +637,8 @@ public class PieRenderer extends OverlayRenderer
@Override
public boolean onTouchEvent(MotionEvent evt) {
+ if (!CameraActivity.isPieMenuEnabled())
+ return false;
float x = evt.getX();
float y = evt.getY();
int action = evt.getActionMasked();