diff options
-rw-r--r-- | src/com/android/camera/PhotoModule.java | 18 | ||||
-rw-r--r-- | src/com/android/camera/PhotoUI.java | 39 |
2 files changed, 46 insertions, 11 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index 49b209d34..7c4487b90 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -49,7 +49,6 @@ import android.os.SystemClock; import android.provider.MediaStore; import android.util.Log; import android.view.KeyEvent; -import android.view.MotionEvent; import android.view.OrientationEventListener; import android.view.SurfaceHolder; import android.view.View; @@ -74,7 +73,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; -import java.util.Collections; import java.util.Formatter; import java.util.List; @@ -940,18 +938,16 @@ public class PhotoModule } private void animateFlash() { - /* //TODO: // Only animate when in full screen capture mode // i.e. If monkey/a user swipes to the gallery during picture taking, // don't show animation - if (ApiHelper.HAS_SURFACE_TEXTURE && !mIsImageCaptureIntent - && mActivity.mShowCameraAppView) { - // Start capture animation. - ((CameraScreenNail) mActivity.mCameraScreenNail).animateFlash(mDisplayRotation); - mUI.enablePreviewThumb(true); - mHandler.sendEmptyMessageDelayed(CAPTURE_ANIMATION_DONE, - CaptureAnimManager.getAnimationDuration()); - } */ + if (!mIsImageCaptureIntent) { + mUI.animateFlash(); + + // TODO: mUI.enablePreviewThumb(true); + // mHandler.sendEmptyMessageDelayed(CAPTURE_ANIMATION_DONE, + // CaptureAnimManager.getAnimationDuration()); + } } @Override diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java index 1468a3ce4..b2a9df8cc 100644 --- a/src/com/android/camera/PhotoUI.java +++ b/src/com/android/camera/PhotoUI.java @@ -17,6 +17,9 @@ package com.android.camera; +import android.animation.Animator; +import android.animation.ObjectAnimator; +import android.animation.ValueAnimator; import android.graphics.Matrix; import android.graphics.SurfaceTexture; import android.hardware.Camera; @@ -108,6 +111,8 @@ public class PhotoUI implements PieListener, private float mSurfaceTextureUncroppedHeight; private View mPreviewThumb; + private ObjectAnimator mFlashAnim; + private View mFlashOverlay; private SurfaceTextureSizeChangedListener mSurfaceTextureSizeListener; private TextureView mTextureView; @@ -153,6 +158,26 @@ public class PhotoUI implements PieListener, } }; + private ValueAnimator.AnimatorListener mAnimatorListener = + new ValueAnimator.AnimatorListener() { + + @Override + public void onAnimationCancel(Animator arg0) {} + + @Override + public void onAnimationEnd(Animator arg0) { + mFlashOverlay.setAlpha(0f); + mFlashOverlay.setVisibility(View.GONE); + mFlashAnim.removeListener(this); + } + + @Override + public void onAnimationRepeat(Animator arg0) {} + + @Override + public void onAnimationStart(Animator arg0) {} + }; + public PhotoUI(CameraActivity activity, PhotoController controller, View parent) { mActivity = activity; mController = controller; @@ -161,6 +186,7 @@ public class PhotoUI implements PieListener, mActivity.getLayoutInflater().inflate(R.layout.photo_module, (ViewGroup) mRootView, true); mRenderOverlay = (RenderOverlay) mRootView.findViewById(R.id.render_overlay); + mFlashOverlay = mRootView.findViewById(R.id.flash_overlay); // display the view mTextureView = (TextureView) mRootView.findViewById(R.id.preview_content); mTextureView.setSurfaceTextureListener(this); @@ -444,6 +470,19 @@ public class PhotoUI implements PieListener, public void setCameraState(int state) { } + public void animateFlash() { + // End the previous animation if the previous one is still running + if (mFlashAnim != null && mFlashAnim.isRunning()) { + mFlashAnim.end(); + } + // Start new flash animation. + mFlashOverlay.setVisibility(View.VISIBLE); + mFlashAnim = ObjectAnimator.ofFloat((Object) mFlashOverlay, "alpha", 0.3f, 0f); + mFlashAnim.setDuration(300); + mFlashAnim.addListener(mAnimatorListener); + mFlashAnim.start(); + } + public void enableGestures(boolean enable) { if (mGestures != null) { mGestures.setEnabled(enable); |