summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoris Liu <tianliu@google.com>2013-06-19 14:20:51 -0700
committerDoris Liu <tianliu@google.com>2013-06-19 15:17:52 -0700
commita10ca0b0f41c064cc3f7485fa4cf4d2e7a0b65e4 (patch)
tree28ed6497c50f6a4662039b272792ecf5220292e9
parent592bfa6ae120aa092749414fe44015496fbb67fa (diff)
downloadandroid_packages_apps_Gallery2-a10ca0b0f41c064cc3f7485fa4cf4d2e7a0b65e4.tar.gz
android_packages_apps_Gallery2-a10ca0b0f41c064cc3f7485fa4cf4d2e7a0b65e4.tar.bz2
android_packages_apps_Gallery2-a10ca0b0f41c064cc3f7485fa4cf4d2e7a0b65e4.zip
Add flash animation to photo module
Change-Id: I9faa46e71e27064c4fbcb629c5c31cc4d7b22652
-rw-r--r--res/layout/photo_module.xml7
-rw-r--r--src/com/android/camera/PhotoModule.java18
-rw-r--r--src/com/android/camera/PhotoUI.java39
3 files changed, 53 insertions, 11 deletions
diff --git a/res/layout/photo_module.xml b/res/layout/photo_module.xml
index 70a7579b7..390863a71 100644
--- a/res/layout/photo_module.xml
+++ b/res/layout/photo_module.xml
@@ -28,6 +28,13 @@
android:id="@+id/preview_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
+ <View
+ android:id="@+id/flash_overlay"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@android:color/white"
+ android:visibility="gone"
+ android:alpha="0" />
<ViewStub android:id="@+id/face_view_stub"
android:inflatedId="@+id/face_view"
android:layout="@layout/face_view"
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);