summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/ui')
-rw-r--r--src/com/android/camera/ui/CameraControls.java1
-rwxr-xr-x[-rw-r--r--]src/com/android/camera/ui/CountDownView.java11
-rwxr-xr-x[-rw-r--r--]src/com/android/camera/ui/OneUICameraControls.java217
-rw-r--r--src/com/android/camera/ui/PanoCaptureProcessView.java30
-rw-r--r--src/com/android/camera/ui/ProMode.java378
5 files changed, 609 insertions, 28 deletions
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
index 9039a9dce..b85d7f1ca 100644
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -247,7 +247,6 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.setEnabled(enable);
}
- mSceneModeSwitcher.setEnabled(enable);
mPreview.setEnabled(enable);
}
diff --git a/src/com/android/camera/ui/CountDownView.java b/src/com/android/camera/ui/CountDownView.java
index 6420fd2c3..7e1f28d52 100644..100755
--- a/src/com/android/camera/ui/CountDownView.java
+++ b/src/com/android/camera/ui/CountDownView.java
@@ -153,16 +153,21 @@ public class CountDownView extends FrameLayout {
public void setOrientation(int orientation) {
mRemainingSecondsView.setRotation(-orientation);
-
mCountDownTitle.setRotation(-orientation);
+ int width = getResources().getDisplayMetrics().widthPixels;
+ int height = mCountDownTitle.getMeasuredHeight();
+ if (height == 0) {
+ measure(MeasureSpec.UNSPECIFIED,MeasureSpec.UNSPECIFIED);
+ height = mCountDownTitle.getMeasuredHeight();
+ }
int dx = 0, dy = 0;
switch (orientation) {
case 90:
- dy = (mCountDownTitle.getWidth() - mCountDownTitle.getHeight()) / 2;
+ dy = (width - height) / 2;
dx = -dy;
break;
case 270:
- dx = dy = (mCountDownTitle.getWidth() - mCountDownTitle.getHeight()) / 2;
+ dx = dy = (width - height) / 2;
break;
case 180:
break;
diff --git a/src/com/android/camera/ui/OneUICameraControls.java b/src/com/android/camera/ui/OneUICameraControls.java
index 63e1b5b4d..3dce60d22 100644..100755
--- a/src/com/android/camera/ui/OneUICameraControls.java
+++ b/src/com/android/camera/ui/OneUICameraControls.java
@@ -24,24 +24,28 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
+import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
-import org.codeaurora.snapcam.R;
-
import com.android.camera.Storage;
import com.android.camera.imageprocessor.filter.BeautificationFilter;
+import org.codeaurora.snapcam.R;
+
public class OneUICameraControls extends RotatableLayout {
private static final String TAG = "CAM_Controls";
private View mShutter;
private View mVideoShutter;
+ private View mPauseButton;
private View mFlashButton;
private View mMute;
private View mFrontBackSwitcher;
@@ -53,6 +57,8 @@ public class OneUICameraControls extends RotatableLayout {
private View mMakeupSeekBarLowText;
private View mMakeupSeekBarHighText;
private View mMakeupSeekBarLayout;
+ private ViewGroup mProModeLayout;
+ private View mProModeCloseButton;
private ArrowTextView mRefocusToast;
@@ -75,10 +81,31 @@ public class OneUICameraControls extends RotatableLayout {
private int mWidth;
private int mHeight;
private boolean mVisible;
+ private boolean mIsVideoMode = false;
+ private int mBottomLargeSize;
+ private int mBottomSmallSize;
+
+ private ProMode mProMode;
+ private ImageView mExposureIcon;
+ private ImageView mManualIcon;
+ private ImageView mWhiteBalanceIcon;
+ private ImageView mIsoIcon;
+ private TextView mExposureText;
+ private TextView mManualText;
+ private TextView mWhiteBalanceText;
+ private TextView mIsoText;
+ private boolean mProModeOn = false;
+ private LinearLayout mExposureLayout;
+ private LinearLayout mManualLayout;
+ private LinearLayout mWhiteBalanceLayout;
+ private LinearLayout mIsoLayout;
+ private RotateLayout mExposureRotateLayout;
+ private RotateLayout mManualRotateLayout;
+ private RotateLayout mWhiteBalanceRotateLayout;
+ private RotateLayout mIsoRotateLayout;
public OneUICameraControls(Context context, AttributeSet attrs) {
super(context, attrs);
-
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
setWillNotDraw(false);
@@ -103,6 +130,7 @@ public class OneUICameraControls extends RotatableLayout {
super.onFinishInflate();
mShutter = findViewById(R.id.shutter_button);
mVideoShutter = findViewById(R.id.video_button);
+ mPauseButton = findViewById(R.id.video_pause);
mFrontBackSwitcher = findViewById(R.id.front_back_switcher);
mTsMakeupSwitcher = findViewById(R.id.ts_makeup_switcher);
mMakeupSeekBarLowText = findViewById(R.id.makeup_low_text);
@@ -117,11 +145,92 @@ public class OneUICameraControls extends RotatableLayout {
mFilterModeSwitcher = findViewById(R.id.filter_mode_switcher);
mRemainingPhotos = (LinearLayout) findViewById(R.id.remaining_photos);
mRemainingPhotosText = (TextView) findViewById(R.id.remaining_photos_text);
+ mProModeLayout = (ViewGroup) findViewById(R.id.pro_mode_layout);
+ mProModeCloseButton = findViewById(R.id.promode_close_button);
+
+ mExposureIcon = (ImageView) findViewById(R.id.exposure);
+ mManualIcon = (ImageView) findViewById(R.id.manual);
+ mWhiteBalanceIcon = (ImageView) findViewById(R.id.white_balance);
+ mIsoIcon = (ImageView) findViewById(R.id.iso);
+ mExposureText = (TextView) findViewById(R.id.exposure_value);
+ mManualText = (TextView) findViewById(R.id.manual_value);
+ mWhiteBalanceText = (TextView) findViewById(R.id.white_balance_value);
+ mIsoText = (TextView) findViewById(R.id.iso_value);
+ mProMode = (ProMode) findViewById(R.id.promode_slider);
+ mProMode.initialize(this);
+
+ mExposureLayout = (LinearLayout) findViewById(R.id.exposure_layout);
+ mManualLayout = (LinearLayout) findViewById(R.id.manual_layout);
+ mWhiteBalanceLayout = (LinearLayout) findViewById(R.id.white_balance_layout);
+ mIsoLayout = (LinearLayout) findViewById(R.id.iso_layout);
+
+ mExposureRotateLayout = (RotateLayout) findViewById(R.id.exposure_rotate_layout);
+ mManualRotateLayout = (RotateLayout) findViewById(R.id.manual_rotate_layout);
+ mWhiteBalanceRotateLayout = (RotateLayout) findViewById(R.id.white_balance_rotate_layout);
+ mIsoRotateLayout = (RotateLayout) findViewById(R.id.iso_rotate_layout);
+
+ mExposureLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetProModeIcons();
+ int mode = mProMode.getMode();
+ if (mode == ProMode.EXPOSURE_MODE) {
+ mProMode.setMode(ProMode.NO_MODE);
+ } else {
+ mExposureIcon.setImageResource(R.drawable.icon_exposure_blue);
+ mProMode.setMode(ProMode.EXPOSURE_MODE);
+ }
+ }
+ });
+ mManualLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetProModeIcons();
+ int mode = mProMode.getMode();
+ if (mode == ProMode.MANUAL_MODE) {
+ mProMode.setMode(ProMode.NO_MODE);
+ } else {
+ mManualIcon.setImageResource(R.drawable.icon_manual_blue);
+ mProMode.setMode(ProMode.MANUAL_MODE);
+ }
+ }
+ });
+ mWhiteBalanceLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetProModeIcons();
+ int mode = mProMode.getMode();
+ if (mode == ProMode.WHITE_BALANCE_MODE) {
+ mProMode.setMode(ProMode.NO_MODE);
+ } else {
+ mWhiteBalanceIcon.setImageResource(R.drawable.icon_white_balance_blue);
+ mProMode.setMode(ProMode.WHITE_BALANCE_MODE);
+ }
+ }
+ });
+ mIsoLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetProModeIcons();
+ int mode = mProMode.getMode();
+ if (mode == ProMode.ISO_MODE) {
+ mProMode.setMode(ProMode.NO_MODE);
+ } else {
+ mIsoIcon.setImageResource(R.drawable.icon_iso_blue);
+ mProMode.setMode(ProMode.ISO_MODE);
+ }
+ }
+ });
+
mViews = new View[]{
mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher,
- mTsMakeupSwitcher, mFlashButton, mShutter, mPreview, mVideoShutter
+ mTsMakeupSwitcher, mFlashButton, mShutter, mPreview, mVideoShutter,
+ mPauseButton
};
-
+ mBottomLargeSize = getResources().getDimensionPixelSize(
+ R.dimen.one_ui_bottom_large);
+ mBottomSmallSize = getResources().getDimensionPixelSize(
+ R.dimen.one_ui_bottom_small);
if(!BeautificationFilter.isSupportedStatic()) {
mTsMakeupSwitcher.setVisibility(View.GONE);
mTsMakeupSwitcher = null;
@@ -142,6 +251,14 @@ public class OneUICameraControls extends RotatableLayout {
if(mMakeupSeekBar != null) {
mMakeupSeekBar.setMinimumWidth(mWidth/2);
}
+
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(mWidth/ 4,mWidth/4);
+ mExposureLayout.setLayoutParams(lp);
+
+ mManualLayout.setLayoutParams(lp);
+ mWhiteBalanceLayout.setLayoutParams(lp);
+ mIsoLayout.setLayoutParams(lp);
+ initializeProMode(mProModeOn);
}
public boolean isControlRegion(int x, int y) {
@@ -205,17 +322,34 @@ public class OneUICameraControls extends RotatableLayout {
int rotation = getUnifiedRotation();
setLocation(mSceneModeSwitcher, true, 0);
setLocation(mFilterModeSwitcher, true, 1);
- setLocation(mFrontBackSwitcher, true, 2);
- setLocation(mTsMakeupSwitcher, true, 3);
- setLocation(mFlashButton, true, 4);
- setLocation(mPreview, false, 0);
- setLocation(mShutter, false, 2);
- setLocation(mVideoShutter, false, 3.15f);
+ if (mIsVideoMode) {
+ setLocation(mMute, true, 2);
+ setLocation(mTsMakeupSwitcher, true, 3);
+ setLocation(mFlashButton, true, 4);
+ setLocation(mPauseButton, false, 3.15f);
+ setLocation(mShutter, false , 0.85f);
+ setLocation(mVideoShutter, false, 2);
+ } else {
+ setLocation(mFrontBackSwitcher, true, 2);
+ setLocation(mTsMakeupSwitcher, true, 3);
+ setLocation(mFlashButton, true, 4);
+ setLocation(mPreview, false, 0);
+ setLocation(mShutter, false, 2);
+ setLocation(mVideoShutter, false, 3.15f);
+ }
setLocationCustomBottom(mMakeupSeekBarLayout, 0, 1);
+ setLocation(mProModeCloseButton, false, 4);
layoutToast(mRefocusToast, w, h, rotation);
}
+ private void setBottomButtionSize(View view, int width, int height) {
+ FrameLayout.LayoutParams layout = (FrameLayout.LayoutParams)view.getLayoutParams();
+ layout.height = height;
+ layout.width = width;
+ view.setLayoutParams(layout);
+ }
+
private void layoutToast(final View v, int w, int h, int rotation) {
int tw = v.getMeasuredWidth();
int th = v.getMeasuredHeight();
@@ -271,6 +405,17 @@ public class OneUICameraControls extends RotatableLayout {
mVisible = true;
}
+ public void setVideoMode(boolean videoMode) {
+ mIsVideoMode = videoMode;
+ if (mIsVideoMode) {
+ setBottomButtionSize(mVideoShutter, mBottomLargeSize, mBottomLargeSize);
+ setBottomButtionSize(mShutter, mBottomSmallSize, mBottomSmallSize);
+ } else {
+ setBottomButtionSize(mShutter, mBottomLargeSize, mBottomLargeSize);
+ setBottomButtionSize(mVideoShutter, mBottomSmallSize, mBottomSmallSize);
+ }
+ }
+
private void layoutRemaingPhotos() {
int rl = mPreview.getLeft();
int rt = mPreview.getTop();
@@ -324,7 +469,7 @@ public class OneUICameraControls extends RotatableLayout {
View[] views = {
mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher,
mTsMakeupSwitcher, mFlashButton, mPreview, mMute, mShutter, mVideoShutter,
- mMakeupSeekBarLowText, mMakeupSeekBarHighText
+ mMakeupSeekBarLowText, mMakeupSeekBarHighText, mPauseButton
};
for (View v : views) {
@@ -332,6 +477,11 @@ public class OneUICameraControls extends RotatableLayout {
((Rotatable) v).setOrientation(orientation, animation);
}
}
+ mExposureRotateLayout.setOrientation(orientation, animation);
+ mManualRotateLayout.setOrientation(orientation, animation);
+ mWhiteBalanceRotateLayout.setOrientation(orientation, animation);
+ mIsoRotateLayout.setOrientation(orientation, animation);
+ mProMode.setOrientation(orientation);
layoutRemaingPhotos();
}
@@ -377,4 +527,47 @@ public class OneUICameraControls extends RotatableLayout {
mPath.lineTo(x1, y1);
}
}
+
+ public void setProMode(boolean promode) {
+ mProModeOn = promode;
+ initializeProMode(mProModeOn);
+ resetProModeIcons();
+ mProMode.reinit();
+ }
+
+ private void resetProModeIcons() {
+ mExposureIcon.setImageResource(R.drawable.icon_exposure);
+ mManualIcon.setImageResource(R.drawable.icon_manual);
+ mWhiteBalanceIcon.setImageResource(R.drawable.icon_white_balance);
+ mIsoIcon.setImageResource(R.drawable.icon_iso);
+ }
+
+ public void initializeProMode(boolean promode) {
+ if (!promode) {
+ mProMode.setMode(ProMode.NO_MODE);
+ mProModeLayout.setVisibility(INVISIBLE);
+ mProModeCloseButton.setVisibility(INVISIBLE);
+ return;
+ }
+ mProModeLayout.setVisibility(VISIBLE);
+ mProModeCloseButton.setVisibility(VISIBLE);
+ mProModeLayout.setY(mHeight - mBottom - mProModeLayout.getHeight());
+ }
+
+ public void updateProModeText(int mode, String value) {
+ switch (mode) {
+ case ProMode.EXPOSURE_MODE:
+ mExposureText.setText(value);
+ break;
+ case ProMode.MANUAL_MODE:
+ mManualText.setText(value);
+ break;
+ case ProMode.WHITE_BALANCE_MODE:
+ mWhiteBalanceText.setText(value);
+ break;
+ case ProMode.ISO_MODE:
+ mIsoText.setText(value);
+ break;
+ }
+ }
}
diff --git a/src/com/android/camera/ui/PanoCaptureProcessView.java b/src/com/android/camera/ui/PanoCaptureProcessView.java
index 2b37fd61e..95e9a095f 100644
--- a/src/com/android/camera/ui/PanoCaptureProcessView.java
+++ b/src/com/android/camera/ui/PanoCaptureProcessView.java
@@ -120,6 +120,7 @@ public class PanoCaptureProcessView extends View implements SensorEventListener
private static final boolean DEBUG = false; //TODO: This has to be false before release
private BitmapArrayOutputStream mBitmapStream;
private static boolean mIsSupported = false;
+ private Object mBitmapStreamLock = new Object();
private boolean mIsFrameProcessing = false;
enum PANO_STATUS {
@@ -337,13 +338,15 @@ public class PanoCaptureProcessView extends View implements SensorEventListener
public void onPause() {
mSensorManager.unregisterListener(this, mRotationSensor);
- if(mBitmapStream != null) {
- try {
- mBitmapStream.close();
- } catch (IOException e) {
- //Ignore
+ synchronized (mBitmapStreamLock) {
+ if(mBitmapStream != null) {
+ try {
+ mBitmapStream.close();
+ } catch (IOException e) {
+ //Ignore
+ }
+ mBitmapStream = null;
}
- mBitmapStream = null;
}
}
@@ -510,13 +513,16 @@ public class PanoCaptureProcessView extends View implements SensorEventListener
}
private void doTask(BitmapTask bitmapTask) {
- if(mBitmapStream == null) {
- mBitmapStream = new BitmapArrayOutputStream(1024*1204);
+ int rtv = -1;
+ synchronized (mBitmapStreamLock) {
+ if(mBitmapStream == null) {
+ mBitmapStream = new BitmapArrayOutputStream(1024*1204);
+ }
+ mBitmapStream.reset();
+ bitmapTask.bitmap.compress(Bitmap.CompressFormat.JPEG, 100, mBitmapStream);
+ rtv = callNativeProcessKeyFrame(mBitmapStream.toByteArray(), mBitmapStream.size(),
+ bitmapTask.x, bitmapTask.y, 0, bitmapTask.dir);
}
- mBitmapStream.reset();
- bitmapTask.bitmap.compress(Bitmap.CompressFormat.JPEG, 100, mBitmapStream);
- int rtv = callNativeProcessKeyFrame(mBitmapStream.toByteArray(), mBitmapStream.size(),
- bitmapTask.x, bitmapTask.y, 0, bitmapTask.dir);
if(rtv < 0) {
mShouldFinish = true;
stopPano(false, mActivity.getResources().getString(R.string.panocapture_direction_is_changed));
diff --git a/src/com/android/camera/ui/ProMode.java b/src/com/android/camera/ui/ProMode.java
new file mode 100644
index 000000000..b55d0c425
--- /dev/null
+++ b/src/com/android/camera/ui/ProMode.java
@@ -0,0 +1,378 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.camera.ui;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.PathMeasure;
+import android.graphics.Point;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.android.camera.SettingsManager;
+
+import org.codeaurora.snapcam.R;
+
+import java.util.ArrayList;
+
+public class ProMode extends View {
+ public static final int NO_MODE = -1;
+ public static final int EXPOSURE_MODE = 0;
+ public static final int MANUAL_MODE = 1;
+ public static final int WHITE_BALANCE_MODE = 2;
+ public static final int ISO_MODE = 3;
+ private static final int DRAG_Y_THRESHOLD = 100;
+ private static final int DRAG_X_THRESHOLD = 30;
+ private static final int BLUE = 0xff4693fb;
+ private static final int SELECTED_DOT_SIZE = 20;
+ private static final int DOT_SIZE = 10;
+ private static final int[] wbIcons = {R.drawable.auto, R.drawable.incandecent,
+ R.drawable.fluorescent, R.drawable.sunlight, R.drawable.cloudy};
+ private static final int[] wbIconsBlue = {R.drawable.auto_blue, R.drawable.incandecent_blue,
+ R.drawable.fluorescent_blue, R.drawable.sunlight_blue, R.drawable.cloudy_blue};
+ private static final int WB_ICON_SIZE = 80;
+ private PathMeasure mCurveMeasure;
+ private int mCurveLeft;
+ private int mCurveRight;
+ private float mSlider = -1;
+ private Paint mPaint = new Paint();
+ private int mNums;
+ private int mIndex;
+ private Point[] mPoints;
+ private float mClickThreshold;
+ private int mStride;
+ private SettingsManager mSettingsManager;
+ private int mMode = NO_MODE;
+ private Context mContext;
+ private ViewGroup mParent;
+ private float minFocus;
+ private OneUICameraControls mUI;
+ private int mWidth;
+ private int mHeight;
+ private int mCurveY;
+ private ArrayList<View> mAddedViews;
+ private float curveCoordinate[] = new float[2];
+ private Path mCurvePath = new Path();
+ private int mCurveHeight;
+ private int mOrientation;
+
+ public ProMode(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mContext = context;
+ mPaint.setStrokeWidth(7f);
+ mSettingsManager = SettingsManager.getInstance();
+ }
+
+ private void init() {
+ init(EXPOSURE_MODE);
+ init(WHITE_BALANCE_MODE);
+ init(ISO_MODE);
+ mUI.updateProModeText(MANUAL_MODE, "Manual");
+ }
+
+ private void init(int mode) {
+ String key = getKey(mode);
+ if (key == null) return;
+ int index = mSettingsManager.getValueIndex(key);
+ CharSequence[] cc = mSettingsManager.getEntries(key);
+ mUI.updateProModeText(mode, cc[index].toString());
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ if (mMode != NO_MODE) {
+ mPaint.setColor(Color.WHITE);
+ mPaint.setStyle(Paint.Style.STROKE);
+ canvas.drawPath(mCurvePath, mPaint);
+ }
+ mPaint.setStyle(Paint.Style.FILL);
+ if (mMode == MANUAL_MODE) {
+ mPaint.setColor(Color.WHITE);
+ canvas.drawCircle(mCurveLeft, mCurveY, DOT_SIZE, mPaint);
+ canvas.drawCircle(mCurveRight, mCurveY, DOT_SIZE, mPaint);
+ mPaint.setColor(BLUE);
+ if (mSlider >= 0f) {
+ mCurveMeasure.getPosTan(mCurveMeasure.getLength() * mSlider, curveCoordinate, null);
+ canvas.drawCircle(curveCoordinate[0], curveCoordinate[1], SELECTED_DOT_SIZE,
+ mPaint);
+ }
+ } else {
+ for (int i = 0; i < mNums; i++) {
+ if (i == mIndex) {
+ mPaint.setColor(BLUE);
+ canvas.drawCircle(mPoints[i].x, mPoints[i].y, SELECTED_DOT_SIZE, mPaint);
+ } else {
+ mPaint.setColor(Color.WHITE);
+ canvas.drawCircle(mPoints[i].x, mPoints[i].y, DOT_SIZE, mPaint);
+ }
+ }
+ }
+ }
+
+ public void initialize(OneUICameraControls ui) {
+ mParent = (ViewGroup) getParent();
+ mUI = ui;
+ init();
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ mWidth = right - left;
+ mHeight = bottom - top;
+
+ mCurveLeft = mWidth / 10;
+ mCurveRight = mWidth - mCurveLeft;
+ mCurveHeight = mWidth / 7;
+ mCurveY = (int) (mHeight * 0.67);
+
+ float cx = (mCurveLeft + mCurveRight) / 2;
+ mCurvePath.reset();
+ mCurvePath.moveTo(mCurveLeft, mCurveY);
+ mCurvePath.quadTo(cx, mCurveY - mCurveHeight, mCurveRight, mCurveY);
+ mCurveMeasure = new PathMeasure(mCurvePath, false);
+ }
+
+ public void reinit() {
+ init();
+ }
+
+ public void setOrientation(int orientation) {
+ mOrientation = orientation;
+ if (mAddedViews != null) {
+ int rotation = mOrientation;
+ if (rotation == 90 || rotation == 270) rotation += 180;
+ rotation %= 360;
+ for (View v : mAddedViews) {
+ v.setRotation(rotation);
+ }
+ }
+ }
+
+ public int getMode() {
+ return mMode;
+ }
+
+ public void setMode(int mode) {
+ mMode = mode;
+ removeViews();
+ if (mMode == NO_MODE) {
+ setVisibility(INVISIBLE);
+ return;
+ } else {
+ setVisibility(VISIBLE);
+ }
+ mIndex = -1;
+ String key = currentKey();
+ if (mMode == MANUAL_MODE) {
+ minFocus = mSettingsManager
+ .getMinimumFocusDistance(mSettingsManager.getCurrentCameraId());
+ float value = mSettingsManager.getFocusValue(SettingsManager.KEY_FOCUS_DISTANCE);
+ setSlider(value);
+ int stride = mCurveRight - mCurveLeft;
+ for (int i = 0; i < 2; i++) {
+ TextView v = new TextView(mContext);
+ String s = "infinity";
+ if (i == 1) s = "macro";
+ v.setText(s);
+ v.setTextColor(Color.WHITE);
+ v.measure(0, 0);
+ ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(v.getMeasuredWidth(),
+ v.getMeasuredHeight());
+ v.setLayoutParams(lp);
+ v.setX(mCurveLeft + i * stride - v.getMeasuredWidth() / 2);
+ v.setY(mCurveY - 2 * v.getMeasuredHeight());
+ mParent.addView(v);
+ mAddedViews.add(v);
+ }
+ } else {
+ if (key == null) return;
+ CharSequence[] cc = mSettingsManager.getEntries(key);
+ int length = mSettingsManager.getEntryValues(key).length;
+ int index = mSettingsManager.getValueIndex(key);
+ updateSlider(length);
+
+ for (int i = 0; i < length; i++) {
+ View v;
+ if (mMode == WHITE_BALANCE_MODE) {
+ v = new ImageView(mContext);
+ ((ImageView) v).setImageResource(wbIcons[i]);
+ ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(
+ WB_ICON_SIZE, WB_ICON_SIZE);
+ v.setLayoutParams(lp);
+ v.setX(mPoints[i].x - WB_ICON_SIZE / 2);
+ v.setY(mPoints[i].y - 2 * WB_ICON_SIZE);
+ } else {
+ v = new TextView(mContext);
+ ((TextView) v).setText(cc[i]);
+ ((TextView) v).setTextColor(Color.WHITE);
+ v.measure(0, 0);
+ ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(v.getMeasuredWidth(),
+ v.getMeasuredHeight());
+ v.setLayoutParams(lp);
+ v.setX(mPoints[i].x - v.getMeasuredWidth() / 2);
+ v.setY(mPoints[i].y - 2 * v.getMeasuredHeight());
+ }
+
+
+ mParent.addView(v);
+ mAddedViews.add(v);
+ }
+ setIndex(index, true);
+ }
+ setOrientation(mOrientation);
+ }
+
+ private String getKey(int mode) {
+ switch (mode) {
+ case EXPOSURE_MODE:
+ return SettingsManager.KEY_EXPOSURE;
+ case WHITE_BALANCE_MODE:
+ return SettingsManager.KEY_WHITE_BALANCE;
+ case ISO_MODE:
+ return SettingsManager.KEY_ISO;
+ }
+ return null;
+ }
+
+ private String currentKey() {
+ return getKey(mMode);
+ }
+
+ private void updateSlider(int n) {
+ mNums = n;
+ mStride = (mCurveRight - mCurveLeft) / (mNums - 1);
+ mClickThreshold = mStride * 0.45f;
+ mPoints = new Point[mNums];
+
+ float slide = 1f / (mNums - 1);
+ for (int i = 0; i < mNums; i++) {
+ mCurveMeasure.getPosTan(mCurveMeasure.getLength() * (slide * i), curveCoordinate, null);
+ mPoints[i] = new Point((int) curveCoordinate[0], (int) curveCoordinate[1]);
+ }
+
+ invalidate();
+ }
+
+ public void setSlider(float slider) {
+ mSlider = slider;
+ mSettingsManager.setFocusDistance(SettingsManager.KEY_FOCUS_DISTANCE, mSlider, minFocus);
+ mUI.updateProModeText(mMode, "Manual");
+ invalidate();
+ }
+
+ private void setIndex(int index, boolean force) {
+ if (mIndex == index && !force) return;
+ if (mIndex != -1) {
+ View v = mAddedViews.get(mIndex);
+ if (v instanceof TextView) {
+ ((TextView) v).setTextColor(Color.WHITE);
+ } else if (v instanceof ImageView) {
+ if (mMode == WHITE_BALANCE_MODE) {
+ ((ImageView) v).setImageResource(wbIcons[mIndex]);
+ }
+ }
+ }
+
+ mIndex = index;
+ String key = currentKey();
+ View v = mAddedViews.get(mIndex);
+ if (v instanceof TextView) {
+ ((TextView) v).setTextColor(BLUE);
+ } else if (v instanceof ImageView) {
+ if (mMode == WHITE_BALANCE_MODE) {
+ ((ImageView) v).setImageResource(wbIconsBlue[mIndex]);
+ }
+ }
+ if (key != null) mSettingsManager.setValueIndex(key, mIndex);
+ CharSequence[] cc = mSettingsManager.getEntries(key);
+ mUI.updateProModeText(mMode, cc[mIndex].toString());
+ invalidate();
+ }
+
+ private void removeViews() {
+ ViewGroup vg = (ViewGroup) getParent();
+ if (mAddedViews != null) {
+ for (int i = 0; i < mAddedViews.size(); i++) {
+ vg.removeView(mAddedViews.get(i));
+ }
+ }
+ mAddedViews = new ArrayList<View>();
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (mMode == MANUAL_MODE) {
+ float slider = getSlider(event.getX(), event.getY());
+ if (slider >= 0) {
+ setSlider(slider);
+ }
+ } else {
+ int idx = findButton(event.getX(), event.getY());
+ if (idx != -1) {
+ setIndex(idx, false);
+ }
+ return true;
+ }
+ return true;
+ }
+
+ private int findButton(float x, float y) {
+ for (int i = 0; i < mNums; i++) {
+ float xdiff = Math.abs(mPoints[i].x - x);
+ float ydiff = Math.abs(mPoints[i].y - y);
+ float dist = xdiff * xdiff + ydiff * ydiff;
+ if (dist < mClickThreshold * mClickThreshold) return i;
+ }
+ return -1;
+ }
+
+ private float getSlider(float x, float y) {
+ if (x > mCurveLeft - DRAG_X_THRESHOLD && x < mCurveRight + DRAG_X_THRESHOLD
+ && y > mCurveY - mCurveHeight - DRAG_Y_THRESHOLD
+ && y < mCurveY + DRAG_Y_THRESHOLD) {
+ if (x < mCurveLeft) x = mCurveLeft;
+ if (x > mCurveRight) x = mCurveRight;
+ return (x - mCurveLeft) / (mCurveRight - mCurveLeft);
+ } else {
+ return -1;
+ }
+ }
+
+}