diff options
author | Angus Kong <shkong@google.com> | 2011-09-14 02:36:21 +0800 |
---|---|---|
committer | Angus Kong <shkong@google.com> | 2011-09-14 06:25:57 +0800 |
commit | 6108e0ed3a6b03deed2a8586d98607a6756637b1 (patch) | |
tree | 4e4a898819f4b5e98f836dffbc9a4732aef0fb1b /src/com | |
parent | 65e43e98f03cd260ce316df6ce22885abc8cc3b1 (diff) | |
download | LegacyCamera-6108e0ed3a6b03deed2a8586d98607a6756637b1.zip LegacyCamera-6108e0ed3a6b03deed2a8586d98607a6756637b1.tar.gz LegacyCamera-6108e0ed3a6b03deed2a8586d98607a6756637b1.tar.bz2 |
Direction indicator before panorama panning added.
bug:5141666
Change-Id: I2ede83f9a5d31544db6d8ea2a269f50da4a3bb7a
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/camera/panorama/PanoProgressBar.java | 35 | ||||
-rw-r--r-- | src/com/android/camera/panorama/PanoramaActivity.java | 38 |
2 files changed, 66 insertions, 7 deletions
diff --git a/src/com/android/camera/panorama/PanoProgressBar.java b/src/com/android/camera/panorama/PanoProgressBar.java index c1a3d5a..a8a3b68 100644 --- a/src/com/android/camera/panorama/PanoProgressBar.java +++ b/src/com/android/camera/panorama/PanoProgressBar.java @@ -25,22 +25,27 @@ import android.widget.ImageView; class PanoProgressBar extends ImageView { private static final String TAG = "PanoProgressBar"; - private static final int DIRECTION_NONE = 0; - private static final int DIRECTION_LEFT = 1; - private static final int DIRECTION_RIGHT = 2; + public static final int DIRECTION_NONE = 0; + public static final int DIRECTION_LEFT = 1; + public static final int DIRECTION_RIGHT = 2; private float mProgress = 0; private float mMaxProgress = 0; private float mLeftMostProgress = 0; private float mRightMostProgress = 0; private float mProgressOffset = 0; private float mIndicatorWidth = 0; - private float mDirection = 0; + private int mDirection = 0; private final Paint mBackgroundPaint = new Paint(); private final Paint mDoneAreaPaint = new Paint(); private final Paint mIndicatorPaint = new Paint(); private float mWidth; private float mHeight; private RectF mDrawBounds; + private OnDirectionChangeListener mListener = null; + + public interface OnDirectionChangeListener { + public void onDirectionChange(int direction); + } public PanoProgressBar(Context context, AttributeSet attrs) { super(context, attrs); @@ -56,6 +61,22 @@ class PanoProgressBar extends ImageView { mDrawBounds = new RectF(); } + public void setOnDirectionChangeListener(OnDirectionChangeListener l) { + mListener = l; + } + + private void setDirection(int direction) { + int prev = mDirection; + mDirection = direction; + if (prev != mDirection && mListener != null) { + mListener.onDirectionChange(mDirection); + } + } + + public int getDirection() { + return mDirection; + } + public void setBackgroundColor(int color) { mBackgroundPaint.setColor(color); } @@ -84,15 +105,15 @@ class PanoProgressBar extends ImageView { public void setRightIncreasing(boolean rightIncreasing) { if (rightIncreasing) { - mDirection = DIRECTION_RIGHT; mLeftMostProgress = 0; mRightMostProgress = 0; mProgressOffset = 0; + setDirection(DIRECTION_RIGHT); } else { - mDirection = DIRECTION_LEFT; mLeftMostProgress = mWidth; mRightMostProgress = mWidth; mProgressOffset = mWidth; + setDirection(DIRECTION_LEFT); } invalidate(); } @@ -127,7 +148,7 @@ class PanoProgressBar extends ImageView { public void reset() { mProgress = 0; mProgressOffset = 0; - mDirection = DIRECTION_NONE; + setDirection(DIRECTION_NONE); invalidate(); } diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java index f6d58b2..c304b98 100644 --- a/src/com/android/camera/panorama/PanoramaActivity.java +++ b/src/com/android/camera/panorama/PanoramaActivity.java @@ -111,6 +111,8 @@ public class PanoramaActivity extends Activity implements private TextView mCaptureIndicator; private PanoProgressBar mPanoProgressBar; private PanoProgressBar mSavingProgressBar; + private View mLeftIndicator; + private View mRightIndicator; private MosaicRendererSurfaceView mMosaicView; private TextView mTooFastPrompt; private ShutterButton mShutterButton; @@ -438,6 +440,28 @@ public class PanoramaActivity extends Activity implements } } + private void hideDirectionIndicators() { + mLeftIndicator.setVisibility(View.GONE); + mRightIndicator.setVisibility(View.GONE); + } + + private void showDirectionIndicators(int direction) { + switch (direction) { + case PanoProgressBar.DIRECTION_NONE: + mLeftIndicator.setVisibility(View.VISIBLE); + mRightIndicator.setVisibility(View.VISIBLE); + break; + case PanoProgressBar.DIRECTION_LEFT: + mLeftIndicator.setVisibility(View.VISIBLE); + mRightIndicator.setVisibility(View.GONE); + break; + case PanoProgressBar.DIRECTION_RIGHT: + mLeftIndicator.setVisibility(View.GONE); + mRightIndicator.setVisibility(View.VISIBLE); + break; + } + } + public void startCapture() { // Reset values so we can do this again. mCancelComputation = false; @@ -445,6 +469,7 @@ public class PanoramaActivity extends Activity implements mCaptureState = CAPTURE_STATE_MOSAIC; mShutterButton.setBackgroundResource(R.drawable.btn_shutter_pan_recording); mCaptureIndicator.setVisibility(View.VISIBLE); + showDirectionIndicators(PanoProgressBar.DIRECTION_NONE); // XML-style animations can not be used here. The Y position has to be calculated runtime. float ystart = mThumbnailView.getY(); @@ -503,6 +528,7 @@ public class PanoramaActivity extends Activity implements mCaptureState = CAPTURE_STATE_VIEWFINDER; mTooFastPrompt.setVisibility(View.GONE); mCaptureIndicator.setVisibility(View.GONE); + hideDirectionIndicators(); mMosaicFrameProcessor.setProgressListener(null); stopCameraPreview(); @@ -560,6 +586,18 @@ public class PanoramaActivity extends Activity implements mPanoProgressBar.setBackgroundColor(appRes.getColor(R.color.pano_progress_empty)); mPanoProgressBar.setDoneColor(appRes.getColor(R.color.pano_progress_done)); mPanoProgressBar.setIndicatorColor(appRes.getColor(R.color.pano_progress_indication)); + mPanoProgressBar.setOnDirectionChangeListener( + new PanoProgressBar.OnDirectionChangeListener () { + @Override + public void onDirectionChange(int direction) { + if (mCaptureState == CAPTURE_STATE_MOSAIC) { + showDirectionIndicators(direction); + } + } + }); + + mLeftIndicator = (ImageView) findViewById(R.id.pano_pan_left_indicator); + mRightIndicator = (ImageView) findViewById(R.id.pano_pan_right_indicator); mTooFastPrompt = (TextView) findViewById(R.id.pano_capture_too_fast_textview); mSavingProgressBar = (PanoProgressBar) findViewById(R.id.pano_saving_progress_bar); |