mUI.showFocusUI(false);
mUI.showVideoRecordingHints(false);
- // A special case of mode options closing: during capture it should
- // not be possible to change mode state.
- mAppController.getCameraAppUI().hideModeOptions();
- mAppController.getCameraAppUI().animateBottomBarToVideoStop(R.drawable.ic_stop);
-
mActivity.updateStorageSpaceAndHint();
if (mActivity.getStorageSpaceBytes() <= Storage.LOW_STORAGE_THRESHOLD_BYTES) {
Log.v(TAG, "Storage issue, ignore the start request");
mMediaRecorderRecording = true;
mActivity.lockOrientation();
mRecordingStartTime = SystemClock.uptimeMillis();
+
+ // A special case of mode options closing: during capture it should
+ // not be possible to change mode state.
+ mAppController.getCameraAppUI().hideModeOptions();
+ mAppController.getCameraAppUI().animateBottomBarToVideoStop(R.drawable.ic_stop);
mUI.showRecordingUI(true);
setFocusParameters();
mUI.showFocusUI(true);
mUI.showVideoRecordingHints(true);
- mAppController.getCameraAppUI().showModeOptions();
- mAppController.getCameraAppUI().animateBottomBarToFullSize(mShutterIconId);
-
boolean fail = false;
if (mMediaRecorderRecording) {
boolean shouldAddToMediaStoreNow = false;
}
// release media recorder
releaseMediaRecorder();
+
+ mAppController.getCameraAppUI().showModeOptions();
+ mAppController.getCameraAppUI().animateBottomBarToFullSize(mShutterIconId);
if (!mPaused) {
setFocusParameters();
mCameraDevice.lock();
@Override
public void onCreate() {
- Log.d(TAG, "Starting up");
-
mProcessingServiceManager = ProcessingServiceManager.getInstance();
mSessionManager = getServices().getCaptureSessionManager();
// Tell the manager that we're shutting down, so in case new tasks are
// enqueued, we a new service needs to be started.
- mProcessingServiceManager.notifyStitchingFinished();
+ mProcessingServiceManager.notifyServiceFinished();
// TODO: Cancel session in progress...
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
+ Log.d(TAG, "Starting in foreground.");
+
// We need to start this service in foreground so that it's not getting
// killed easily when memory pressure is building up.
startForeground(CAMERA_NOTIFICATION_ID, mNotificationBuilder.build());
}
private void pause() {
+ Log.d(TAG, "Pausing");
try {
mSuspendStatusLock.lock();
mPaused = true;
}
private void resume() {
+ Log.d(TAG, "Resuming");
try {
mSuspendStatusLock.lock();
mPaused = false;
session.addProgressListener(this);
System.gc();
+ Log.d(TAG, "Processing start");
task.process(this, getServices(), session);
+ Log.d(TAG, "Processing done");
}
private void resetNotification() {
}
/**
+ * @return Whether the service is currently running.
+ */
+ public synchronized boolean isServiceRunning() {
+ return mServiceRunning;
+ }
+
+ /**
* Called by the processing service, notifying us that it has finished.
*/
- public synchronized void notifyStitchingFinished() {
+ public synchronized void notifyServiceFinished() {
this.mServiceRunning = false;
}
}
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
-import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
private int mBackgroundPressedColor;
private int mBackgroundAlpha = 0xff;
- private final Paint mCirclePaint = new Paint();
- private final Path mCirclePath = new Path();
private boolean mDrawCircle;
private final float mCircleRadius;
- private final Path mRectPath = new Path();
+ private float mCurrentCircleRadius;
+ private int mCircleColor;
+ private final Paint mCirclePaint= new Paint();
+ private float mCenterX;
+ private float mCenterY;
private final RectF mRect = new RectF();
mOptimalHeight = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height_optimal);
mCircleRadius = getResources()
.getDimensionPixelSize(R.dimen.video_capture_circle_diameter) / 2;
- mCirclePaint.setAntiAlias(true);
mBackgroundAlphaOverlay = getResources().getInteger(R.integer.bottom_bar_background_alpha_overlay);
mBackgroundAlphaDefault = getResources().getInteger(R.integer
.bottom_bar_background_alpha);
}
private void setPaintColor(int alpha, int color, boolean isCaptureChange) {
- int computedColor = (alpha << 24) | (color & 0x00ffffff);
- mCirclePaint.setColor(computedColor);
+ mCircleColor = (alpha << 24) | (color & 0x00ffffff);
+ mCirclePaint.setColor(mCircleColor);
invalidate();
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
-
notifyAreaAdjust();
-
- final int width = getWidth();
- final int height = getHeight();
-
- if (changed) {
- mCirclePath.reset();
- mCirclePath.addCircle(
- width/2,
- height/2,
- (int)(diagonalLength(width, height)/2),
- Path.Direction.CW);
-
- mRect.set(
- 0.0f,
- 0.0f,
- width,
- height);
- mRectPath.reset();
- mRectPath.addRect(mRect, Path.Direction.CW);
- }
+ mCenterX = (right - left) / 2;
+ mCenterY = (bottom - top) / 2;
}
@Override
switch (mMode) {
case MODE_CAPTURE:
if (mDrawCircle) {
- canvas.drawPath(mCirclePath, mCirclePaint);
+ canvas.drawCircle(mCenterX, mCenterY, mCurrentCircleRadius, mCirclePaint);
} else {
- canvas.drawPath(mRectPath, mCirclePaint);
+ canvas.drawColor(mCircleColor);
}
break;
case MODE_INTENT:
radiusAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
- mCirclePath.reset();
- mCirclePath.addCircle(
- getWidth()/2,
- getHeight()/2,
- (Float) animation.getAnimatedValue(),
- Path.Direction.CW);
+ mCurrentCircleRadius = (Float) animation.getAnimatedValue();
invalidate();
}
});
*/
public void animateToFullSize(int resId) {
if (mDrawCircle) {
+ final float endRadius = (float) diagonalLength()/2;
final ValueAnimator radiusAnimator =
- ValueAnimator.ofFloat(mCircleRadius, (float) diagonalLength()/2);
+ ValueAnimator.ofFloat(mCircleRadius, endRadius);
radiusAnimator.setDuration(CIRCLE_ANIM_DURATION_MS);
radiusAnimator.setInterpolator(Gusterpolator.INSTANCE);
radiusAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
- mCirclePath.reset();
- mCirclePath.addCircle(
- getWidth()/2,
- getHeight()/2,
- (Float) animation.getAnimatedValue(),
- Path.Direction.CW);
+ mCurrentCircleRadius = (Float) animation.getAnimatedValue();
invalidate();
}
});
@Override
public void onAnimationEnd(Animator animation) {
mDrawCircle = false;
- }
+ mCurrentCircleRadius = endRadius;
+ }
});
radiusAnimator.start();
}
public class ModeOptions extends FrameLayout {
private int mBackgroundColor;
private final Paint mPaint = new Paint();
- private final Path mPath = new Path();
private boolean mIsHiddenOrHiding;
private RectF mAnimateFrom = new RectF();
private View mViewToShowHide;
private int mParentSize;
private boolean mIsPortrait;
+ private float mRadius = 0f;
public ModeOptions(Context context, AttributeSet attrs) {
super(context, attrs);
@Override
public void onDraw(Canvas canvas) {
if (mDrawCircle) {
- canvas.drawPath(mPath, mPaint);
+ canvas.drawCircle(mAnimateFrom.centerX(), mAnimateFrom.centerY(), mRadius, mPaint);
} else if (mFill) {
canvas.drawPaint(mPaint);
}
radiusAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
- mPath.reset();
- mPath.addCircle(mAnimateFrom.centerX(),
- mAnimateFrom.centerY(),
- (Float) animation.getAnimatedValue(),
- Path.Direction.CW);
+ mRadius = (Float) animation.getAnimatedValue();
mDrawCircle = true;
mFill = false;
}
radiusAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- mPath.reset();
mDrawCircle = false;
mFill = true;
}
radiusAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
- mPath.reset();
- mPath.addCircle(mAnimateFrom.centerX(),
- mAnimateFrom.centerY(),
- (Float) animation.getAnimatedValue(),
- Path.Direction.CW);
+ mRadius = (Float) animation.getAnimatedValue();
mDrawCircle = true;
mFill = false;
invalidate();
@Override
public void onAnimationEnd(Animator animation) {
if (mViewToShowHide != null) {
- mPath.reset();
mViewToShowHide.setVisibility(View.VISIBLE);
mDrawCircle = false;
mFill = false;