package com.android.camera;
import android.annotation.TargetApi;
-import android.content.res.Resources;
+import android.content.Context;
import android.graphics.SurfaceTexture;
import android.opengl.Matrix;
import android.util.Log;
private final float[] mTextureTransformMatrix = new float[16];
// Animation.
- private CaptureAnimManager mCaptureAnimManager = new CaptureAnimManager();
+ private CaptureAnimManager mCaptureAnimManager;
private SwitchAnimManager mSwitchAnimManager = new SwitchAnimManager();
private int mAnimState = ANIM_NONE;
private RawTexture mAnimTexture;
RawTexture copyToTexture(GLCanvas c, RawTexture texture, int width, int height);
}
- public CameraScreenNail(Listener listener, Resources res) {
+ public CameraScreenNail(Listener listener, Context ctx) {
mListener = listener;
- mCaptureAnimManager.setResources(res);
+ mCaptureAnimManager = new CaptureAnimManager(ctx);
}
public void setFullScreen(boolean full) {
public void animateSlide() {
synchronized (mLock) {
- // Ignore the case where animateFlash is skipped but animateSlide is called
- // e.g. Double tap shutter and immediately swipe to gallery, and quickly swipe back
- // to camera. This case only happens in monkey tests, not applicable to normal
- // human beings.
- if (mAnimState != ANIM_CAPTURE_RUNNING) {
- Log.v(TAG, "Cannot animateSlide outside of animateCapture!"
- + " Animation state = " + mAnimState);
- return;
- }
mCaptureAnimManager.animateSlide();
mListener.requestRender();
}
case ANIM_CAPTURE_START:
copyPreviewTexture(canvas);
mListener.onCaptureTextureCopied();
- mCaptureAnimManager.startAnimation(x, y, width, height);
+ mCaptureAnimManager.startAnimation();
mAnimState = ANIM_CAPTURE_RUNNING;
break;
}
package com.android.camera;
+import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.SystemClock;
import com.android.gallery3d.R;
import com.android.gallery3d.glrenderer.GLCanvas;
+import com.android.gallery3d.glrenderer.NinePatchTexture;
import com.android.gallery3d.glrenderer.RawTexture;
/**
private int mMarginTop;
private int mSize;
private Resources mResources;
+ private NinePatchTexture mBorder;
+ private int mShadowSize;
public static int getAnimationDuration() {
return TIME_SLIDE2;
/* preview: camera preview view.
* review: view of picture just taken.
*/
- public CaptureAnimManager() {
-
- }
-
- public void setResources(Resources res) {
- mResources = res;
+ public CaptureAnimManager(Context ctx) {
+ mBorder = new NinePatchTexture(ctx, R.drawable.capture_thumbnail_shadow);
+ mResources = ctx.getResources();
}
public void setOrientation(int displayRotation) {
mAnimType = ANIM_BOTH;
}
- // x, y, w and h: the rectangle area where the animation takes place.
- public void startAnimation(int x, int y, int w, int h) {
+ public void startAnimation() {
mAnimStartTime = SystemClock.uptimeMillis();
- setAnimationGeometry(x, y, w, h);
}
private void setAnimationGeometry(int x, int y, int w, int h) {
mMarginRight = mResources.getDimensionPixelSize(R.dimen.capture_margin_right);
mMarginTop = mResources.getDimensionPixelSize(R.dimen.capture_margin_top);
mSize = mResources.getDimensionPixelSize(R.dimen.capture_size);
+ mShadowSize = mResources.getDimensionPixelSize(R.dimen.capture_border);
mOffset = mMarginRight + mSize;
// Set the views to the initial positions.
mDrawWidth = w;
} else if (animStep == ANIM_HOLD2) {
preview.directDraw(canvas, (int) mX, (int) mY, mDrawWidth, mDrawHeight);
review.draw(canvas, mHoldX, mHoldY, mHoldW, mHoldH);
+ mBorder.draw(canvas, (int) mHoldX - mShadowSize, (int) mHoldY - mShadowSize,
+ (int) mHoldW + 2 * mShadowSize, (int) mHoldH + 2 * mShadowSize);
} else if (animStep == ANIM_SLIDE2) {
float fraction = (float)(timeDiff) / (TIME_SLIDE2 - TIME_HOLD2);
float x = mHoldX;
break;
}
preview.directDraw(canvas, (int) mX, (int) mY, mDrawWidth, mDrawHeight);
+ mBorder.draw(canvas, (int) x - mShadowSize, (int) y - mShadowSize,
+ (int) mHoldW + 2 * mShadowSize, (int) mHoldH + 2 * mShadowSize);
review.draw(canvas, (int) x, (int) y, mHoldW, mHoldH);
}
return true;