diff options
author | Su Liu <suliu@codeaurora.org> | 2013-09-04 18:16:50 +0800 |
---|---|---|
committer | Chippa-a <vusal1372@gmail.com> | 2019-10-25 15:55:25 +0300 |
commit | f5fcd13376b152d2ddfa5860f49f1ac9d6eb096a (patch) | |
tree | 7f2a6b3706313cfcb472b85f406b70410d0fa5e6 /src/com/android/camera/ui | |
parent | 00ef53613ee536c6d52ea47c4c995801270fe142 (diff) | |
download | android_packages_apps_Snap-f5fcd13376b152d2ddfa5860f49f1ac9d6eb096a.tar.gz android_packages_apps_Snap-f5fcd13376b152d2ddfa5860f49f1ac9d6eb096a.tar.bz2 android_packages_apps_Snap-f5fcd13376b152d2ddfa5860f49f1ac9d6eb096a.zip |
Camera: Change volume hard key button to zoom function
Author: Su Liu <suliu@codeaurora.org>
Date: Wed Sep 4 18:16:50 2013 +0800
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
Author: jt1134 <jt1134@gmail.com>
Date: Sat Jan 4 20:52:27 2014 -0600
Camera2: implement volume key zoom in video mode
Change-Id: I140e8cfb3e39700f60e40c35b38e92c83a3c26de
Author: Lars Greiss <kufikugel@googlemail.com>
Date: Sun Feb 2 03:09:22 2014 +0100
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
Change-Id: I99dd2fffc92985156eece67c19435a71d14cd928
Diffstat (limited to 'src/com/android/camera/ui')
-rwxr-xr-x | src/com/android/camera/ui/ZoomRenderer.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/com/android/camera/ui/ZoomRenderer.java b/src/com/android/camera/ui/ZoomRenderer.java index fac429a17..5c31cf570 100755 --- 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,6 +50,7 @@ public class ZoomRenderer extends OverlayRenderer private int mOuterStroke; private int mZoomSig; private int mZoomFraction; + private boolean mInZoom; private Rect mTextBounds; private int mOrientation; private boolean mCamera2 = false; @@ -165,6 +169,48 @@ public class ZoomRenderer extends OverlayRenderer return true; } + public boolean onScaleStepResize(boolean direction) { + int zoom; + float circle; + float circleStep = (mMaxCircle - mMinCircle) / 18; + 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) { + mHandler.removeCallbacks(mOnZoomEnd); + if (!mInZoom) { + mInZoom = true; + setVisible(true); + mListener.onZoomStart(); + update(); + } + mListener.onZoomValueChanged(zoom); + mHandler.postDelayed(mOnZoomEnd, 300); + } + return true; + } else { + return false; + } + } + + Runnable mOnZoomEnd = new Runnable() { + public void run() { + mInZoom = false; + setVisible(false); + if (mListener != null) { + mListener.onZoomEnd(); + } + } + }; + @Override public boolean onScaleBegin(ScaleGestureDetector detector) { setVisible(true); |