summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSu Liu <suliu@codeaurora.org>2013-09-04 18:16:50 +0800
committerMichael Bestas <mikeioannina@gmail.com>2015-09-17 23:26:02 +0300
commit81b41090d9538992c125fec37069ba961fc15bec (patch)
tree06e5f9b8966aaed4fc7cba66368736a589a81045
parent461a8209d21a834ac5ba20dbca6fd90da144cffa (diff)
downloadandroid_packages_apps_Snap-81b41090d9538992c125fec37069ba961fc15bec.zip
android_packages_apps_Snap-81b41090d9538992c125fec37069ba961fc15bec.tar.gz
android_packages_apps_Snap-81b41090d9538992c125fec37069ba961fc15bec.tar.bz2
Camera: Change volume hard key button to zoom function
Able to capture image through volume hard key button in camera application, change the function to zoom function. Change-Id: Iab9fc2492b2e2ff89cd58c21bac2f147f47b77e2
-rw-r--r--src/com/android/camera/PhotoModule.java16
-rw-r--r--src/com/android/camera/PhotoUI.java17
-rw-r--r--src/com/android/camera/PreviewGestures.java16
-rw-r--r--src/com/android/camera/ui/ZoomRenderer.java36
4 files changed, 80 insertions, 5 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index d40f0d2..c23c41f 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -2469,7 +2469,17 @@ public class PhotoModule
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
+ if (/*TODO: mActivity.isInCameraApp() &&*/ mFirstTimeInitialized
+ && (mUI.mMenuInitialized)) {
+ mUI.onScaleStepResize(true);
+ }
+ return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
+ if (/*TODO: mActivity.isInCameraApp() &&*/ mFirstTimeInitialized
+ && (mUI.mMenuInitialized)) {
+ mUI.onScaleStepResize(false);
+ }
+ return true;
case KeyEvent.KEYCODE_FOCUS:
if (/*TODO: mActivity.isInCameraApp() &&*/ mFirstTimeInitialized) {
if (event.getRepeatCount() == 0) {
@@ -2503,11 +2513,7 @@ public class PhotoModule
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_VOLUME_DOWN:
- if (/*mActivity.isInCameraApp() && */ mFirstTimeInitialized) {
- onShutterButtonClick();
- return true;
- }
- return false;
+ return true;
case KeyEvent.KEYCODE_FOCUS:
if (mFirstTimeInitialized) {
onShutterButtonFocus(false);
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index 33e0cc7..49707d8 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -53,6 +53,7 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.Toast;
+import android.graphics.Canvas;
import com.android.camera.CameraPreference.OnPreferenceChangedListener;
import com.android.camera.FocusOverlayManager.FocusUI;
@@ -1248,6 +1249,22 @@ public class PhotoUI implements PieListener,
mFaceView.setFaces(faces);
}
+
+ public boolean onScaleStepResize(boolean direction)
+ {
+ if(mGestures != null){
+ return mGestures.onScaleStepResize(direction);
+ }
+ return false;
+ }
+
+ public void onScaleChangeDraw(Canvas canvas)
+ {
+ if(mGestures != null){
+ mGestures.onScaleChangeDraw(canvas);
+ }
+ }
+
@Override
public void onDisplayChanged() {
Log.d(TAG, "Device flip detected.");
diff --git a/src/com/android/camera/PreviewGestures.java b/src/com/android/camera/PreviewGestures.java
index 70a094c..4a1eae0 100644
--- a/src/com/android/camera/PreviewGestures.java
+++ b/src/com/android/camera/PreviewGestures.java
@@ -20,6 +20,7 @@ import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
+import android.graphics.Canvas;
import com.android.camera.PhotoMenu;
import com.android.camera.VideoMenu;
@@ -290,5 +291,20 @@ public class PreviewGestures
public void onScaleEnd(ScaleGestureDetector detector) {
mZoom.onScaleEnd(detector);
}
+
+ public boolean onScaleStepResize(boolean direction)
+ {
+ if(mZoom != null){
+ return mZoom.onScaleStepResize(direction);
+ }
+ return false;
+ }
+
+ public void onScaleChangeDraw(Canvas canvas)
+ {
+ if(mZoom != null){
+ mZoom.onScaleChangeDraw(canvas);
+ }
+ }
}
diff --git a/src/com/android/camera/ui/ZoomRenderer.java b/src/com/android/camera/ui/ZoomRenderer.java
index 9943b1c..be4996b 100644
--- a/src/com/android/camera/ui/ZoomRenderer.java
+++ b/src/com/android/camera/ui/ZoomRenderer.java
@@ -49,6 +49,7 @@ public class ZoomRenderer extends OverlayRenderer
private int mZoomFraction;
private Rect mTextBounds;
private int mOrientation;
+ private Canvas mCanvas;
public interface OnZoomChangedListener {
void onZoomStart();
@@ -110,6 +111,7 @@ public class ZoomRenderer extends OverlayRenderer
@Override
public void onDraw(Canvas canvas) {
+ mCanvas = canvas;
canvas.rotate(mOrientation, mCenterX, mCenterY);
mPaint.setStrokeWidth(mInnerStroke);
canvas.drawCircle(mCenterX, mCenterY, mMinCircle, mPaint);
@@ -125,6 +127,13 @@ public class ZoomRenderer extends OverlayRenderer
mTextPaint);
}
+ public void onScaleChangeDraw(Canvas canvas) {
+ if(mCanvas != null){
+ onDraw(mCanvas);
+ }
+ }
+
+
@Override
public boolean onScale(ScaleGestureDetector detector) {
final float sf = detector.getScaleFactor();
@@ -139,6 +148,33 @@ public class ZoomRenderer extends OverlayRenderer
return true;
}
+ public boolean onScaleStepResize(boolean direction) {
+ int zoom;
+ float circle;
+ float circleStep = (mMaxCircle - mMinCircle)/10;
+ if(direction){
+ circle = (int) (mCircleSize + circleStep);
+ } else {
+ circle = (int) (mCircleSize - circleStep);
+ }
+ circle = Math.max(mMinCircle, circle);
+ circle = Math.min(mMaxCircle, circle);
+ if (mListener != null && (int) circle != mCircleSize
+ && ((mMaxCircle - mMinCircle) != 0)) {
+ mCircleSize = (int) circle;
+ zoom = mMinZoom + (int) ((mCircleSize - mMinCircle)
+ * (mMaxZoom - mMinZoom) / (mMaxCircle - mMinCircle));
+ if (mListener != null) {
+ mListener.onZoomStart();
+ mListener.onZoomValueChanged(zoom);
+ mListener.onZoomEnd();
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
setVisible(true);