summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Greiss <kufikugel@googlemail.com>2014-02-02 03:09:22 +0100
committerMichael Bestas <mikeioannina@gmail.com>2015-09-17 23:26:03 +0300
commit2db625e1748d222bb2459f2eed286d16c8cffe12 (patch)
tree140a21b28384a77f470cb99e5c3b62964e774c70
parentcea0604f347b07d51d48b14b6c6b7d43ba1b0377 (diff)
downloadandroid_packages_apps_Snap-2db625e1748d222bb2459f2eed286d16c8cffe12.zip
android_packages_apps_Snap-2db625e1748d222bb2459f2eed286d16c8cffe12.tar.gz
android_packages_apps_Snap-2db625e1748d222bb2459f2eed286d16c8cffe12.tar.bz2
Camera2: tweak volume key zoom and cleanup
- cleanup unused code - cleanup codestyle - add more zoom steps for smother zooming - show zoom circle indicator during zoom Change-Id: I5214fc2620a0c5167bfdc8e85f7115966c3b8bcf
-rw-r--r--src/com/android/camera/PhotoUI.java12
-rw-r--r--src/com/android/camera/PreviewGestures.java10
-rw-r--r--src/com/android/camera/VideoUI.java11
-rw-r--r--src/com/android/camera/ui/ZoomRenderer.java37
4 files changed, 27 insertions, 43 deletions
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index 49707d8..6e116f9 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -53,7 +53,6 @@ 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;
@@ -1249,22 +1248,13 @@ public class PhotoUI implements PieListener,
mFaceView.setFaces(faces);
}
-
- public boolean onScaleStepResize(boolean direction)
- {
+ 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 4a1eae0..42d64bb 100644
--- a/src/com/android/camera/PreviewGestures.java
+++ b/src/com/android/camera/PreviewGestures.java
@@ -20,7 +20,6 @@ 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;
@@ -292,19 +291,12 @@ public class PreviewGestures
mZoom.onScaleEnd(detector);
}
- public boolean onScaleStepResize(boolean direction)
- {
+ 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/VideoUI.java b/src/com/android/camera/VideoUI.java
index 69dd4c6..69a2315 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -22,7 +22,6 @@ import org.codeaurora.snapcam.R;
import android.content.res.Configuration;
import android.graphics.Bitmap;
-import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
@@ -990,21 +989,13 @@ public class VideoUI implements PieRenderer.PieListener,
return mCameraControls.getVisibility() == View.VISIBLE;
}
- public boolean onScaleStepResize(boolean direction)
- {
+ 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() {
mCameraControls.checkLayoutFlip();
diff --git a/src/com/android/camera/ui/ZoomRenderer.java b/src/com/android/camera/ui/ZoomRenderer.java
index be4996b..bddd5cc 100644
--- a/src/com/android/camera/ui/ZoomRenderer.java
+++ b/src/com/android/camera/ui/ZoomRenderer.java
@@ -22,6 +22,7 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
+import android.os.Handler;
import android.view.ScaleGestureDetector;
import org.codeaurora.snapcam.R;
@@ -35,6 +36,8 @@ public class ZoomRenderer extends OverlayRenderer
private int mMinZoom;
private OnZoomChangedListener mListener;
+ private final Handler mHandler = new Handler();
+
private ScaleGestureDetector mDetector;
private Paint mPaint;
private Paint mTextPaint;
@@ -47,9 +50,9 @@ public class ZoomRenderer extends OverlayRenderer
private int mOuterStroke;
private int mZoomSig;
private int mZoomFraction;
+ private boolean mInZoom;
private Rect mTextBounds;
private int mOrientation;
- private Canvas mCanvas;
public interface OnZoomChangedListener {
void onZoomStart();
@@ -111,7 +114,6 @@ 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);
@@ -127,13 +129,6 @@ 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();
@@ -151,7 +146,7 @@ public class ZoomRenderer extends OverlayRenderer
public boolean onScaleStepResize(boolean direction) {
int zoom;
float circle;
- float circleStep = (mMaxCircle - mMinCircle)/10;
+ float circleStep = (mMaxCircle - mMinCircle)/18;
if(direction){
circle = (int) (mCircleSize + circleStep);
} else {
@@ -160,14 +155,20 @@ public class ZoomRenderer extends OverlayRenderer
circle = Math.max(mMinCircle, circle);
circle = Math.min(mMaxCircle, circle);
if (mListener != null && (int) circle != mCircleSize
- && ((mMaxCircle - mMinCircle) != 0)) {
+ && ((mMaxCircle - mMinCircle) > 0)) {
mCircleSize = (int) circle;
zoom = mMinZoom + (int) ((mCircleSize - mMinCircle)
* (mMaxZoom - mMinZoom) / (mMaxCircle - mMinCircle));
if (mListener != null) {
- mListener.onZoomStart();
+ mHandler.removeCallbacks(mOnZoomEnd);
+ if (!mInZoom) {
+ mInZoom = true;
+ setVisible(true);
+ mListener.onZoomStart();
+ update();
+ }
mListener.onZoomValueChanged(zoom);
- mListener.onZoomEnd();
+ mHandler.postDelayed(mOnZoomEnd, 300);
}
return true;
} else {
@@ -175,6 +176,16 @@ public class ZoomRenderer extends OverlayRenderer
}
}
+ Runnable mOnZoomEnd = new Runnable() {
+ public void run() {
+ mInZoom = false;
+ setVisible(false);
+ if (mListener != null) {
+ mListener.onZoomEnd();
+ }
+ }
+ };
+
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
setVisible(true);