diff options
15 files changed, 90 insertions, 10 deletions
diff --git a/res/drawable-hdpi/ic_pan_left_indicator.png b/res/drawable-hdpi/ic_pan_left_indicator.png Binary files differnew file mode 100644 index 0000000..c9a6907 --- /dev/null +++ b/res/drawable-hdpi/ic_pan_left_indicator.png diff --git a/res/drawable-hdpi/ic_pan_right_indicator.png b/res/drawable-hdpi/ic_pan_right_indicator.png Binary files differnew file mode 100644 index 0000000..2c4fe80 --- /dev/null +++ b/res/drawable-hdpi/ic_pan_right_indicator.png diff --git a/res/drawable-mdpi/ic_pan_left_indicator.png b/res/drawable-mdpi/ic_pan_left_indicator.png Binary files differnew file mode 100644 index 0000000..7b52deb --- /dev/null +++ b/res/drawable-mdpi/ic_pan_left_indicator.png diff --git a/res/drawable-mdpi/ic_pan_right_indicator.png b/res/drawable-mdpi/ic_pan_right_indicator.png Binary files differnew file mode 100644 index 0000000..0e8059f --- /dev/null +++ b/res/drawable-mdpi/ic_pan_right_indicator.png diff --git a/res/drawable-w1024dp-hdpi/ic_pan_left_indicator.png b/res/drawable-w1024dp-hdpi/ic_pan_left_indicator.png Binary files differnew file mode 100644 index 0000000..60d1f98 --- /dev/null +++ b/res/drawable-w1024dp-hdpi/ic_pan_left_indicator.png diff --git a/res/drawable-w1024dp-hdpi/ic_pan_right_indicator.png b/res/drawable-w1024dp-hdpi/ic_pan_right_indicator.png Binary files differnew file mode 100644 index 0000000..f9b2ca2 --- /dev/null +++ b/res/drawable-w1024dp-hdpi/ic_pan_right_indicator.png diff --git a/res/drawable-w1024dp-mdpi/ic_pan_left_indicator.png b/res/drawable-w1024dp-mdpi/ic_pan_left_indicator.png Binary files differnew file mode 100644 index 0000000..4579cf7 --- /dev/null +++ b/res/drawable-w1024dp-mdpi/ic_pan_left_indicator.png diff --git a/res/drawable-w1024dp-mdpi/ic_pan_right_indicator.png b/res/drawable-w1024dp-mdpi/ic_pan_right_indicator.png Binary files differnew file mode 100644 index 0000000..de44206 --- /dev/null +++ b/res/drawable-w1024dp-mdpi/ic_pan_right_indicator.png diff --git a/res/drawable-w1024dp-xhdpi/ic_pan_left_indicator.png b/res/drawable-w1024dp-xhdpi/ic_pan_left_indicator.png Binary files differnew file mode 100644 index 0000000..0bc4d06 --- /dev/null +++ b/res/drawable-w1024dp-xhdpi/ic_pan_left_indicator.png diff --git a/res/drawable-w1024dp-xhdpi/ic_pan_right_indicator.png b/res/drawable-w1024dp-xhdpi/ic_pan_right_indicator.png Binary files differnew file mode 100644 index 0000000..640e47d --- /dev/null +++ b/res/drawable-w1024dp-xhdpi/ic_pan_right_indicator.png diff --git a/res/drawable-xhdpi/ic_pan_left_indicator.png b/res/drawable-xhdpi/ic_pan_left_indicator.png Binary files differnew file mode 100644 index 0000000..cab6c90 --- /dev/null +++ b/res/drawable-xhdpi/ic_pan_left_indicator.png diff --git a/res/drawable-xhdpi/ic_pan_right_indicator.png b/res/drawable-xhdpi/ic_pan_right_indicator.png Binary files differnew file mode 100644 index 0000000..7ffe6ac --- /dev/null +++ b/res/drawable-xhdpi/ic_pan_right_indicator.png diff --git a/res/layout/pano_capture.xml b/res/layout/pano_capture.xml index 5988196..fc949b7 100644 --- a/res/layout/pano_capture.xml +++ b/res/layout/pano_capture.xml @@ -30,6 +30,7 @@ android:layout_height="match_parent" android:orientation="vertical"> + <!-- The top bar with capture indication --> <FrameLayout android:id="@+id/pano_capture_indicator_layout" style="@style/PanoViewHorizontalBar"> @@ -53,16 +54,36 @@ android:layout_width="match_parent" android:layout_height="@dimen/pano_mosaic_surface_height" /> - <FrameLayout + <!-- The bottom bar with progress bar and direction indicators --> + <RelativeLayout style="@style/PanoViewHorizontalBar"> <com.android.camera.panorama.PanoProgressBar android:id="@+id/pano_pan_progress_bar" android:visibility="gone" android:src="@drawable/ic_pan_progression" - android:layout_gravity="center" + android:layout_centerInParent="true" android:layout_width="wrap_content" android:layout_height="wrap_content" /> - </FrameLayout> + <ImageView + android:id="@+id/pano_pan_left_indicator" + android:src="@drawable/ic_pan_left_indicator" + android:visibility="gone" + android:layout_marginRight="5dp" + android:layout_toLeftOf="@id/pano_pan_progress_bar" + android:layout_centerVertical="true" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + + <ImageView + android:id="@+id/pano_pan_right_indicator" + android:src="@drawable/ic_pan_right_indicator" + android:visibility="gone" + android:layout_marginLeft="5dp" + android:layout_toRightOf="@id/pano_pan_progress_bar" + android:layout_centerVertical="true" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + </RelativeLayout> </LinearLayout> 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); |