From 4d7f3be87a92c7efac7cf92bbd4ce7dd61f46e0d Mon Sep 17 00:00:00 2001 From: Andy Huibers Date: Tue, 2 Sep 2014 22:12:09 -0700 Subject: [PATCH] CaptureModule countdown timer fixes: ability to cancel, and remove premature SoundPlayer release. Bug: 17204673 Change-Id: I438c3d4e7a9aad3f8fc709d255a249399bb05b57 --- src/com/android/camera/CaptureModule.java | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 04398017d..280ff4a0f 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -315,6 +315,13 @@ public class CaptureModule extends CameraModule String action = activity.getIntent().getAction(); mIsImageCaptureIntent = (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) || CameraActivity.ACTION_IMAGE_CAPTURE_SECURE.equals(action)); + View cancelButton = activity.findViewById(R.id.shutter_cancel_button); + cancelButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + cancelCountDown(); + } + }); } @Override @@ -393,12 +400,21 @@ public class CaptureModule extends CameraModule } } + private void cancelCountDown() { + if (mUI.isCountingDown()) { + // Cancel on-going countdown. + mUI.cancelCountDown(); + } + mAppController.getCameraAppUI().showModeOptions(); + mAppController.getCameraAppUI().transitionToCapture(); + } + @Override public void onPreviewAreaChanged(RectF previewArea) { mPreviewArea = previewArea; mUI.onPreviewAreaChanged(previewArea); // mUI.updatePreviewAreaRect(previewArea); - // mUI.positionProgressOverlay(previewArea); + mUI.positionProgressOverlay(previewArea); } @Override @@ -545,9 +561,11 @@ public class CaptureModule extends CameraModule @Override public void pause() { mPaused = true; + cancelCountDown(); resetTextureBufferSize(); closeCamera(); - mCountdownSoundPlayer.release(); + mCountdownSoundPlayer.unloadSound(R.raw.beep_once); + mCountdownSoundPlayer.unloadSound(R.raw.beep_twice); // Remove delayed resume trigger, if it hasn't been executed yet. mMainHandler.removeCallbacksAndMessages(null); @@ -562,6 +580,7 @@ public class CaptureModule extends CameraModule @Override public void destroy() { + mCountdownSoundPlayer.release(); } @Override @@ -648,7 +667,9 @@ public class CaptureModule extends CameraModule switch (keyCode) { case KeyEvent.KEYCODE_CAMERA: case KeyEvent.KEYCODE_DPAD_CENTER: - if (event.getRepeatCount() == 0) { + if (mUI.isCountingDown()) { + cancelCountDown(); + } else if (event.getRepeatCount() == 0) { onShutterButtonClick(); } return true; -- 2.11.0