diff options
-rw-r--r-- | res/values/colors.xml | 1 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 8 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorWheel.java | 66 |
3 files changed, 75 insertions, 0 deletions
diff --git a/res/values/colors.xml b/res/values/colors.xml index 344f99f..a9d8482 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -24,4 +24,5 @@ <color name="on_viewfinder_label_background_color">#77333333</color> <color name="review_control_pressed_color">#FF6899FF</color> <color name="icon_disabled_color">#DD777777</color> + <color name="time_lapse_arc">#FFC5C5C5</color> </resources> diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index b283df5..8dea4cd 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -1419,12 +1419,20 @@ public class VideoCamera extends NoSearchActivity mRecordingTimeView.setText(""); mRecordingTimeView.setVisibility(View.VISIBLE); if (mReviewControl != null) mReviewControl.setVisibility(View.GONE); + if (mCaptureTimeLapse) { + mIndicatorWheel.startTimeLapseAnimation( + mTimeBetweenTimeLapseFrameCaptureMs, + mRecordingStartTime); + } } else { mShutterButton.setImageDrawable(getResources().getDrawable( R.drawable.btn_ic_video_record)); mShutterButton.setBackgroundResource(R.drawable.btn_shutter); mRecordingTimeView.setVisibility(View.GONE); if (mReviewControl != null) mReviewControl.setVisibility(View.VISIBLE); + if (mCaptureTimeLapse) { + mIndicatorWheel.stopTimeLapseAnimation(); + } } } diff --git a/src/com/android/camera/ui/IndicatorWheel.java b/src/com/android/camera/ui/IndicatorWheel.java index 2a3ee4c..5829645 100644 --- a/src/com/android/camera/ui/IndicatorWheel.java +++ b/src/com/android/camera/ui/IndicatorWheel.java @@ -26,6 +26,8 @@ import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.RectF; +import android.os.Handler; +import android.os.SystemClock; import android.util.AttributeSet; import android.util.Log; import android.widget.ImageView; @@ -49,9 +51,11 @@ public class IndicatorWheel extends ViewGroup implements private static final float EDGE_STROKE_WIDTH = 6f; private static final int HIGHLIGHT_WIDTH = 4; private static final int HIGHLIGHT_DEGREE = 30; + private static final int TIME_LAPSE_ARC_WIDTH = 6; private final int HIGHLIGHT_COLOR; private final int DISABLED_COLOR; + private final int TIME_LAPSE_ARC_COLOR; private Listener mListener; // The center of the shutter button. @@ -71,12 +75,25 @@ public class IndicatorWheel extends ViewGroup implements // opening it again. private int mJustDeselectedIndex = -1; + // Time lapse recording variables. + private int mTimeLapseInterval; // in ms + private long mRecordingStartTime = 0; + private long mNumberOfFrames = 0; + private float mLastEndAngle; + private Context mContext; private PreferenceGroup mPreferenceGroup; private ArrayList<String> mPreferenceKeys; private BasicSettingPopup[] mBasicSettingPopups; private OtherSettingsPopup mOtherSettingsPopup; + private Handler mHandler = new Handler(); + private final Runnable mRunnable = new Runnable() { + public void run() { + invalidate(); + } + }; + static public interface Listener { public void onSharedPreferenceChanged(); public void onRestorePreferencesClicked(); @@ -93,6 +110,7 @@ public class IndicatorWheel extends ViewGroup implements Resources resources = context.getResources(); HIGHLIGHT_COLOR = resources.getColor(R.color.review_control_pressed_color); DISABLED_COLOR = resources.getColor(R.color.icon_disabled_color); + TIME_LAPSE_ARC_COLOR = resources.getColor(R.color.time_lapse_arc); setWillNotDraw(false); mBackgroundPaint = new Paint(); @@ -191,6 +209,7 @@ public class IndicatorWheel extends ViewGroup implements super.onFinishInflate(); // The first view is shutter button. mShutterButton = getChildAt(0); + mHandler.postDelayed(mRunnable, 0); } public void removeIndicators() { @@ -286,6 +305,19 @@ public class IndicatorWheel extends ViewGroup implements } } + public void startTimeLapseAnimation(int timeLapseInterval, long startTime) { + mTimeLapseInterval = timeLapseInterval; + mRecordingStartTime = startTime; + mNumberOfFrames = 0; + mLastEndAngle = 0f; + invalidate(); + } + + public void stopTimeLapseAnimation() { + mTimeLapseInterval = 0; + invalidate(); + } + @Override protected void onDraw(Canvas canvas) { // Draw highlight. @@ -307,6 +339,40 @@ public class IndicatorWheel extends ViewGroup implements HIGHLIGHT_DEGREE, false, mBackgroundPaint); } + // Draw arc shaped indicator in time lapse recording. + if (mTimeLapseInterval != 0) { + // Setup rectangle and paint. + mBackgroundRect.set((float)(mCenterX - mShutterButtonRadius), + (float)(mCenterY - mShutterButtonRadius), + (float)(mCenterX + mShutterButtonRadius), + (float)(mCenterY + mShutterButtonRadius)); + mBackgroundRect.inset(3f, 3f); + mBackgroundPaint.setStrokeWidth(TIME_LAPSE_ARC_WIDTH); + mBackgroundPaint.setStrokeCap(Paint.Cap.ROUND); + mBackgroundPaint.setColor(TIME_LAPSE_ARC_COLOR); + + // Compute the start angle and sweep angle. + long timeDelta = SystemClock.uptimeMillis() - mRecordingStartTime; + long numberOfFrames = timeDelta / mTimeLapseInterval; + float sweepAngle, startAngle; + float endAngle = ((float) timeDelta) % mTimeLapseInterval / mTimeLapseInterval * 360f; + if (numberOfFrames > mNumberOfFrames) { + // The arc just acrosses 0 degree. Draw the arc from the degree + // of last onDraw. Otherwise some parts of the arc will be never + // drawn. + startAngle = mLastEndAngle; + sweepAngle = endAngle + 360f - mLastEndAngle; + mNumberOfFrames = numberOfFrames; + } else { + startAngle = 0; + sweepAngle = endAngle; + } + mLastEndAngle = endAngle; + + canvas.drawArc(mBackgroundRect, startAngle, sweepAngle, false, mBackgroundPaint); + mHandler.postDelayed(mRunnable, 0); + } + super.onDraw(canvas); } |