summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/camera/AndroidCameraManagerImpl.java4
-rw-r--r--src/com/android/camera/CameraActivity.java7
-rw-r--r--src/com/android/camera/CameraHolder.java2
-rw-r--r--src/com/android/camera/CameraManager.java2
-rw-r--r--src/com/android/camera/CameraScreenNail.java526
-rw-r--r--src/com/android/camera/CameraSettings.java11
-rw-r--r--src/com/android/camera/CaptureAnimManager.java228
-rw-r--r--src/com/android/camera/EffectsRecorder.java7
-rw-r--r--src/com/android/camera/FocusOverlayManager.java27
-rw-r--r--src/com/android/camera/ListPreference.java5
-rw-r--r--src/com/android/camera/PhotoModule.java80
-rw-r--r--src/com/android/camera/PhotoUI.java21
-rw-r--r--src/com/android/camera/PreviewFrameLayout.java5
-rw-r--r--src/com/android/camera/RotateDialogController.java169
-rw-r--r--src/com/android/camera/SoundClips.java2
-rw-r--r--src/com/android/camera/StaticBitmapScreenNail.java32
-rw-r--r--src/com/android/camera/Storage.java2
-rw-r--r--src/com/android/camera/SwitchAnimManager.java146
-rw-r--r--src/com/android/camera/VideoModule.java69
-rw-r--r--src/com/android/camera/VideoUI.java20
-rw-r--r--src/com/android/camera/app/CameraApp.java19
-rw-r--r--src/com/android/camera/app/OrientationManager.java (renamed from src/com/android/camera/support/app/OrientationManager.java)5
-rw-r--r--src/com/android/camera/app/OrientationSource.java (renamed from src/com/android/camera/support/ui/OrientationSource.java)2
-rw-r--r--src/com/android/camera/data/LocalMediaData.java4
-rw-r--r--src/com/android/camera/support/app/StitchingChangeListener.java11
-rw-r--r--src/com/android/camera/support/common/Utils.java325
-rw-r--r--src/com/android/camera/support/filtershow/crop/CropExtras.java106
-rw-r--r--src/com/android/camera/support/glrenderer/BasicTexture.java197
-rw-r--r--src/com/android/camera/support/glrenderer/BitmapTexture.java38
-rw-r--r--src/com/android/camera/support/glrenderer/ExtTexture.java45
-rw-r--r--src/com/android/camera/support/glrenderer/GLCanvas.java201
-rw-r--r--src/com/android/camera/support/glrenderer/GLId.java17
-rw-r--r--src/com/android/camera/support/glrenderer/GLPaint.java26
-rw-r--r--src/com/android/camera/support/glrenderer/NinePatchChunk.java66
-rw-r--r--src/com/android/camera/support/glrenderer/NinePatchTexture.java408
-rw-r--r--src/com/android/camera/support/glrenderer/RawTexture.java58
-rw-r--r--src/com/android/camera/support/glrenderer/ResourceTexture.java37
-rw-r--r--src/com/android/camera/support/glrenderer/Texture.java27
-rw-r--r--src/com/android/camera/support/glrenderer/UploadedTexture.java283
-rw-r--r--src/com/android/camera/support/ui/BitmapScreenNail.java45
-rw-r--r--src/com/android/camera/support/ui/ScreenNail.java21
-rw-r--r--src/com/android/camera/support/ui/SurfaceTextureScreenNail.java128
-rw-r--r--src/com/android/camera/ui/CameraRootView.java6
-rw-r--r--src/com/android/camera/ui/CameraSwitcher.java6
-rw-r--r--src/com/android/camera/ui/EffectSettingPopup.java2
-rw-r--r--src/com/android/camera/ui/FaceView.java10
-rw-r--r--src/com/android/camera/ui/PreviewSurfaceView.java50
-rw-r--r--src/com/android/camera/ui/RotatableLayout.java10
-rw-r--r--src/com/android/camera/ui/RotateLayout.java4
-rw-r--r--src/com/android/camera/ui/RotateTextToast.java4
-rw-r--r--src/com/android/camera/ui/Switch.java2
-rw-r--r--src/com/android/camera/util/AccessibilityUtils.java (renamed from src/com/android/camera/support/util/AccessibilityUtils.java)4
-rw-r--r--src/com/android/camera/util/ApiHelper.java (renamed from src/com/android/camera/support/common/ApiHelper.java)19
-rw-r--r--src/com/android/camera/util/CameraUtil.java (renamed from src/com/android/camera/Util.java)19
-rw-r--r--src/com/android/camera/util/MotionEventHelper.java (renamed from src/com/android/camera/support/util/MotionEventHelper.java)4
55 files changed, 198 insertions, 3376 deletions
diff --git a/src/com/android/camera/AndroidCameraManagerImpl.java b/src/com/android/camera/AndroidCameraManagerImpl.java
index 667630609..00fe905a9 100644
--- a/src/com/android/camera/AndroidCameraManagerImpl.java
+++ b/src/com/android/camera/AndroidCameraManagerImpl.java
@@ -16,7 +16,7 @@
package com.android.camera;
-import static com.android.camera.Util.Assert;
+import static com.android.camera.util.CameraUtil.Assert;
import java.io.IOException;
@@ -39,7 +39,7 @@ import android.os.Message;
import android.util.Log;
import android.view.SurfaceHolder;
-import com.android.camera.support.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
/**
* A class to implement {@link CameraManager} of the Android camera framework.
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 508dfea34..ae2f34562 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -50,10 +50,11 @@ import com.android.camera.data.FixedLastDataAdapter;
import com.android.camera.data.LocalData;
import com.android.camera.data.LocalDataAdapter;
import com.android.camera.data.SimpleViewData;
-import com.android.camera.support.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
import com.android.camera.ui.CameraSwitcher;
import com.android.camera.ui.CameraSwitcher.CameraSwitchListener;
import com.android.camera.ui.FilmStripView;
+import com.android.camera.util.CameraUtil;
import com.android.camera.util.PhotoSphereHelper.PanoramaViewHelper;
import com.android.camera.util.PhotoSphereHelper;
import com.android.camera.util.RefocusHelper;
@@ -280,10 +281,10 @@ public class CameraActivity extends Activity
ContentResolver cr = getContentResolver();
String mimeType = cr.getType(uri);
if (mimeType.startsWith("video/")) {
- sendBroadcast(new Intent(Util.ACTION_NEW_VIDEO, uri));
+ sendBroadcast(new Intent(CameraUtil.ACTION_NEW_VIDEO, uri));
mDataAdapter.addNewVideo(cr, uri);
} else if (mimeType.startsWith("image/")) {
- Util.broadcastNewPicture(this, uri);
+ CameraUtil.broadcastNewPicture(this, uri);
mDataAdapter.addNewPhoto(cr, uri);
} else if (mimeType.startsWith("application/stitching-preview")) {
mDataAdapter.addNewPhoto(cr, uri);
diff --git a/src/com/android/camera/CameraHolder.java b/src/com/android/camera/CameraHolder.java
index d913df709..0ffc73663 100644
--- a/src/com/android/camera/CameraHolder.java
+++ b/src/com/android/camera/CameraHolder.java
@@ -16,7 +16,7 @@
package com.android.camera;
-import static com.android.camera.Util.Assert;
+import static com.android.camera.util.CameraUtil.Assert;
import android.hardware.Camera.CameraInfo;
import android.hardware.Camera.Parameters;
diff --git a/src/com/android/camera/CameraManager.java b/src/com/android/camera/CameraManager.java
index fd9b2ced3..4a8057d3f 100644
--- a/src/com/android/camera/CameraManager.java
+++ b/src/com/android/camera/CameraManager.java
@@ -27,7 +27,7 @@ import android.hardware.Camera.Parameters;
import android.os.Handler;
import android.view.SurfaceHolder;
-import com.android.camera.support.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
/**
* An interface which provides possible camera device operations.
diff --git a/src/com/android/camera/CameraScreenNail.java b/src/com/android/camera/CameraScreenNail.java
deleted file mode 100644
index 9fe2c067a..000000000
--- a/src/com/android/camera/CameraScreenNail.java
+++ /dev/null
@@ -1,526 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera;
-
-import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.graphics.SurfaceTexture;
-import android.opengl.Matrix;
-import android.util.Log;
-import com.android.camera.support.common.ApiHelper;
-import com.android.camera.support.glrenderer.GLCanvas;
-import com.android.camera.support.glrenderer.RawTexture;
-import com.android.camera.support.ui.SurfaceTextureScreenNail;
-
-/*
- * This is a ScreenNail which can display camera's preview.
- */
-@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
-public class CameraScreenNail extends SurfaceTextureScreenNail {
- private static final String TAG = "CAM_ScreenNail";
- private static final int ANIM_NONE = 0;
- // Capture animation is about to start.
- private static final int ANIM_CAPTURE_START = 1;
- // Capture animation is running.
- private static final int ANIM_CAPTURE_RUNNING = 2;
- // Switch camera animation needs to copy texture.
- private static final int ANIM_SWITCH_COPY_TEXTURE = 3;
- // Switch camera animation shows the initial feedback by darkening the
- // preview.
- private static final int ANIM_SWITCH_DARK_PREVIEW = 4;
- // Switch camera animation is waiting for the first frame.
- private static final int ANIM_SWITCH_WAITING_FIRST_FRAME = 5;
- // Switch camera animation is about to start.
- private static final int ANIM_SWITCH_START = 6;
- // Switch camera animation is running.
- private static final int ANIM_SWITCH_RUNNING = 7;
-
- private boolean mVisible;
- // True if first onFrameAvailable has been called. If screen nail is drawn
- // too early, it will be all white.
- private boolean mFirstFrameArrived;
- private Listener mListener;
- private final float[] mTextureTransformMatrix = new float[16];
-
- // Animation.
- private CaptureAnimManager mCaptureAnimManager;
- private SwitchAnimManager mSwitchAnimManager = new SwitchAnimManager();
- private int mAnimState = ANIM_NONE;
- private RawTexture mAnimTexture;
- // Some methods are called by GL thread and some are called by main thread.
- // This protects mAnimState, mVisible, and surface texture. This also makes
- // sure some code are atomic. For example, requestRender and setting
- // mAnimState.
- private Object mLock = new Object();
-
- private OnFrameDrawnListener mOneTimeFrameDrawnListener;
- private int mRenderWidth;
- private int mRenderHeight;
- // This represents the scaled, uncropped size of the texture
- // Needed for FaceView
- private int mUncroppedRenderWidth;
- private int mUncroppedRenderHeight;
- private float mScaleX = 1f, mScaleY = 1f;
- private boolean mFullScreen;
- private boolean mEnableAspectRatioClamping = false;
- private boolean mAcquireTexture = false;
- private final DrawClient mDefaultDraw = new DrawClient() {
- @Override
- public void onDraw(GLCanvas canvas, int x, int y, int width, int height) {
- CameraScreenNail.super.draw(canvas, x, y, width, height);
- }
-
- @Override
- public boolean requiresSurfaceTexture() {
- return true;
- }
-
- @Override
- public RawTexture copyToTexture(GLCanvas c, RawTexture texture, int w, int h) {
- // We shouldn't be here since requireSurfaceTexture() returns true.
- return null;
- }
- };
- private DrawClient mDraw = mDefaultDraw;
- private float mAlpha = 1f;
- private Runnable mOnFrameDrawnListener;
-
- public interface Listener {
- void requestRender();
- // Preview has been copied to a texture.
- void onPreviewTextureCopied();
-
- void onCaptureTextureCopied();
- }
-
- public interface OnFrameDrawnListener {
- void onFrameDrawn(CameraScreenNail c);
- }
-
- public interface DrawClient {
- void onDraw(GLCanvas canvas, int x, int y, int width, int height);
-
- boolean requiresSurfaceTexture();
- // The client should implement this if requiresSurfaceTexture() is false;
- RawTexture copyToTexture(GLCanvas c, RawTexture texture, int width, int height);
- }
-
- public CameraScreenNail(Listener listener, Context ctx) {
- mListener = listener;
- mCaptureAnimManager = new CaptureAnimManager(ctx);
- }
-
- public void setFullScreen(boolean full) {
- synchronized (mLock) {
- mFullScreen = full;
- }
- }
-
- /**
- * returns the uncropped, but scaled, width of the rendered texture
- */
- public int getUncroppedRenderWidth() {
- return mUncroppedRenderWidth;
- }
-
- /**
- * returns the uncropped, but scaled, width of the rendered texture
- */
- public int getUncroppedRenderHeight() {
- return mUncroppedRenderHeight;
- }
-
- @Override
- public int getWidth() {
- return mEnableAspectRatioClamping ? mRenderWidth : getTextureWidth();
- }
-
- @Override
- public int getHeight() {
- return mEnableAspectRatioClamping ? mRenderHeight : getTextureHeight();
- }
-
- private int getTextureWidth() {
- return super.getWidth();
- }
-
- private int getTextureHeight() {
- return super.getHeight();
- }
-
- @Override
- public void setSize(int w, int h) {
- super.setSize(w, h);
- mEnableAspectRatioClamping = false;
- if (mRenderWidth == 0) {
- mRenderWidth = w;
- mRenderHeight = h;
- }
- updateRenderSize();
- }
-
- /**
- * Tells the ScreenNail to override the default aspect ratio scaling
- * and instead perform custom scaling to basically do a centerCrop instead
- * of the default centerInside
- *
- * Note that calls to setSize will disable this
- */
- public void enableAspectRatioClamping() {
- mEnableAspectRatioClamping = true;
- updateRenderSize();
- }
-
- private void setPreviewLayoutSize(int w, int h) {
- Log.i(TAG, "preview layout size: "+w+"/"+h);
- mRenderWidth = w;
- mRenderHeight = h;
- updateRenderSize();
- }
-
- private void updateRenderSize() {
- if (!mEnableAspectRatioClamping) {
- mScaleX = mScaleY = 1f;
- mUncroppedRenderWidth = getTextureWidth();
- mUncroppedRenderHeight = getTextureHeight();
- Log.i(TAG, "aspect ratio clamping disabled");
- return;
- }
-
- float aspectRatio;
- if (getTextureWidth() > getTextureHeight()) {
- aspectRatio = (float) getTextureWidth() / (float) getTextureHeight();
- } else {
- aspectRatio = (float) getTextureHeight() / (float) getTextureWidth();
- }
- float scaledTextureWidth, scaledTextureHeight;
- if (mRenderWidth > mRenderHeight) {
- scaledTextureWidth = Math.max(mRenderWidth,
- (int) (mRenderHeight * aspectRatio));
- scaledTextureHeight = Math.max(mRenderHeight,
- (int)(mRenderWidth / aspectRatio));
- } else {
- scaledTextureWidth = Math.max(mRenderWidth,
- (int) (mRenderHeight / aspectRatio));
- scaledTextureHeight = Math.max(mRenderHeight,
- (int) (mRenderWidth * aspectRatio));
- }
- mScaleX = mRenderWidth / scaledTextureWidth;
- mScaleY = mRenderHeight / scaledTextureHeight;
- mUncroppedRenderWidth = Math.round(scaledTextureWidth);
- mUncroppedRenderHeight = Math.round(scaledTextureHeight);
- Log.i(TAG, "aspect ratio clamping enabled, surfaceTexture scale: " + mScaleX + ", " + mScaleY);
- }
-
- public void acquireSurfaceTexture() {
- synchronized (mLock) {
- mFirstFrameArrived = false;
- mAnimTexture = new RawTexture(getTextureWidth(), getTextureHeight(), true);
- mAcquireTexture = true;
- }
- mListener.requestRender();
- }
-
- @Override
- public void releaseSurfaceTexture() {
- synchronized (mLock) {
- if (mAcquireTexture) {
- mAcquireTexture = false;
- mLock.notifyAll();
- } else {
- if (super.getSurfaceTexture() != null) {
- super.releaseSurfaceTexture();
- }
- mAnimState = ANIM_NONE; // stop the animation
- }
- }
- }
-
- public void copyTexture() {
- synchronized (mLock) {
- mListener.requestRender();
- mAnimState = ANIM_SWITCH_COPY_TEXTURE;
- }
- }
-
- public void animateSwitchCamera() {
- Log.v(TAG, "animateSwitchCamera");
- synchronized (mLock) {
- if (mAnimState == ANIM_SWITCH_DARK_PREVIEW) {
- // Do not request render here because camera has been just
- // started. We do not want to draw black frames.
- mAnimState = ANIM_SWITCH_WAITING_FIRST_FRAME;
- }
- }
- }
-
- public void animateCapture(int displayRotation) {
- synchronized (mLock) {
- mCaptureAnimManager.setOrientation(displayRotation);
- mCaptureAnimManager.animateFlashAndSlide();
- mListener.requestRender();
- mAnimState = ANIM_CAPTURE_START;
- }
- }
-
- public RawTexture getAnimationTexture() {
- return mAnimTexture;
- }
-
- public void animateFlash(int displayRotation) {
- synchronized (mLock) {
- mCaptureAnimManager.setOrientation(displayRotation);
- mCaptureAnimManager.animateFlash();
- mListener.requestRender();
- mAnimState = ANIM_CAPTURE_START;
- }
- }
-
- public void animateSlide() {
- synchronized (mLock) {
- mCaptureAnimManager.animateSlide();
- mListener.requestRender();
- }
- }
-
- private void callbackIfNeeded() {
- if (mOneTimeFrameDrawnListener != null) {
- mOneTimeFrameDrawnListener.onFrameDrawn(this);
- mOneTimeFrameDrawnListener = null;
- }
- }
-
- @Override
- protected void updateTransformMatrix(float[] matrix) {
- super.updateTransformMatrix(matrix);
- Matrix.translateM(matrix, 0, .5f, .5f, 0);
- Matrix.scaleM(matrix, 0, mScaleX, mScaleY, 1f);
- Matrix.translateM(matrix, 0, -.5f, -.5f, 0);
- }
-
- @SuppressLint("WrongCall")
- public void directDraw(GLCanvas canvas, int x, int y, int width, int height) {
- DrawClient draw;
- synchronized (mLock) {
- draw = mDraw;
- }
- // TODO: Should this call draw or onDraw?
- draw.onDraw(canvas, x, y, width, height);
- }
-
- public void setDraw(DrawClient draw) {
- synchronized (mLock) {
- if (draw == null) {
- mDraw = mDefaultDraw;
- } else {
- mDraw = draw;
- }
- }
- mListener.requestRender();
- }
-
- @Override
- public void draw(GLCanvas canvas, int x, int y, int width, int height) {
- synchronized (mLock) {
- allocateTextureIfRequested(canvas);
- if (!mVisible) mVisible = true;
- SurfaceTexture surfaceTexture = getSurfaceTexture();
- if (mDraw.requiresSurfaceTexture() && (surfaceTexture == null || !mFirstFrameArrived)) {
- return;
- }
- if (mOnFrameDrawnListener != null) {
- mOnFrameDrawnListener.run();
- mOnFrameDrawnListener = null;
- }
- float oldAlpha = canvas.getAlpha();
- canvas.setAlpha(mAlpha);
-
- switch (mAnimState) {
- case ANIM_NONE:
- directDraw(canvas, x, y, width, height);
- break;
- case ANIM_SWITCH_COPY_TEXTURE:
- copyPreviewTexture(canvas);
- mSwitchAnimManager.setReviewDrawingSize(width, height);
- mListener.onPreviewTextureCopied();
- mAnimState = ANIM_SWITCH_DARK_PREVIEW;
- // The texture is ready. Fall through to draw darkened
- // preview.
- case ANIM_SWITCH_DARK_PREVIEW:
- case ANIM_SWITCH_WAITING_FIRST_FRAME:
- // Consume the frame. If the buffers are full,
- // onFrameAvailable will not be called. Animation state
- // relies on onFrameAvailable.
- surfaceTexture.updateTexImage();
- mSwitchAnimManager.drawDarkPreview(canvas, x, y, width,
- height, mAnimTexture);
- break;
- case ANIM_SWITCH_START:
- mSwitchAnimManager.startAnimation();
- mAnimState = ANIM_SWITCH_RUNNING;
- break;
- case ANIM_CAPTURE_START:
- copyPreviewTexture(canvas);
- mListener.onCaptureTextureCopied();
- mCaptureAnimManager.startAnimation();
- mAnimState = ANIM_CAPTURE_RUNNING;
- break;
- }
-
- if (mAnimState == ANIM_CAPTURE_RUNNING || mAnimState == ANIM_SWITCH_RUNNING) {
- boolean drawn;
- if (mAnimState == ANIM_CAPTURE_RUNNING) {
- if (!mFullScreen) {
- // Skip the animation if no longer in full screen mode
- drawn = false;
- } else {
- drawn = mCaptureAnimManager.drawAnimation(canvas, this, mAnimTexture,
- x, y, width, height);
- }
- } else {
- drawn = mSwitchAnimManager.drawAnimation(canvas, x, y,
- width, height, this, mAnimTexture);
- }
- if (drawn) {
- mListener.requestRender();
- } else {
- // Continue to the normal draw procedure if the animation is
- // not drawn.
- mAnimState = ANIM_NONE;
- directDraw(canvas, x, y, width, height);
- }
- }
- canvas.setAlpha(oldAlpha);
- callbackIfNeeded();
- } // mLock
- }
-
- private void copyPreviewTexture(GLCanvas canvas) {
- if (!mDraw.requiresSurfaceTexture()) {
- mAnimTexture = mDraw.copyToTexture(
- canvas, mAnimTexture, getTextureWidth(), getTextureHeight());
- } else {
- int width = mAnimTexture.getWidth();
- int height = mAnimTexture.getHeight();
- canvas.beginRenderTarget(mAnimTexture);
- // Flip preview texture vertically. OpenGL uses bottom left point
- // as the origin (0, 0).
- canvas.translate(0, height);
- canvas.scale(1, -1, 1);
- getSurfaceTexture().getTransformMatrix(mTextureTransformMatrix);
- updateTransformMatrix(mTextureTransformMatrix);
- canvas.drawTexture(mExtTexture, mTextureTransformMatrix, 0, 0, width, height);
- canvas.endRenderTarget();
- }
- }
-
- @Override
- public void noDraw() {
- synchronized (mLock) {
- mVisible = false;
- }
- }
-
- @Override
- public void recycle() {
- synchronized (mLock) {
- mVisible = false;
- }
- }
-
- @Override
- public void onFrameAvailable(SurfaceTexture surfaceTexture) {
- synchronized (mLock) {
- if (getSurfaceTexture() != surfaceTexture) {
- return;
- }
- mFirstFrameArrived = true;
- if (mVisible) {
- if (mAnimState == ANIM_SWITCH_WAITING_FIRST_FRAME) {
- mAnimState = ANIM_SWITCH_START;
- }
- // We need to ask for re-render if the SurfaceTexture receives a new
- // frame.
- mListener.requestRender();
- }
- }
- }
-
- // We need to keep track of the size of preview frame on the screen because
- // it's needed when we do switch-camera animation. See comments in
- // SwitchAnimManager.java. This is based on the natural orientation, not the
- // view system orientation.
- public void setPreviewFrameLayoutSize(int width, int height) {
- synchronized (mLock) {
- mSwitchAnimManager.setPreviewFrameLayoutSize(width, height);
- setPreviewLayoutSize(width, height);
- }
- }
-
- public void setOneTimeOnFrameDrawnListener(OnFrameDrawnListener l) {
- synchronized (mLock) {
- mFirstFrameArrived = false;
- mOneTimeFrameDrawnListener = l;
- }
- }
-
- @Override
- public SurfaceTexture getSurfaceTexture() {
- synchronized (mLock) {
- SurfaceTexture surfaceTexture = super.getSurfaceTexture();
- if (surfaceTexture == null && mAcquireTexture) {
- try {
- mLock.wait();
- surfaceTexture = super.getSurfaceTexture();
- } catch (InterruptedException e) {
- Log.w(TAG, "unexpected interruption");
- }
- }
- return surfaceTexture;
- }
- }
-
- private void allocateTextureIfRequested(GLCanvas canvas) {
- synchronized (mLock) {
- if (mAcquireTexture) {
- super.acquireSurfaceTexture(canvas);
- mAcquireTexture = false;
- mLock.notifyAll();
- }
- }
- }
-
- public void setOnFrameDrawnOneShot(Runnable run) {
- synchronized (mLock) {
- mOnFrameDrawnListener = run;
- }
- }
-
- public float getAlpha() {
- synchronized (mLock) {
- return mAlpha;
- }
- }
-
- public void setAlpha(float alpha) {
- synchronized (mLock) {
- mAlpha = alpha;
- mListener.requestRender();
- }
- }
-}
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 9e01d5c9b..791a4f719 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -29,8 +29,9 @@ import android.media.CamcorderProfile;
import android.util.FloatMath;
import android.util.Log;
+import com.android.camera.util.CameraUtil;
import com.android.camera2.R;
-import com.android.camera.support.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
import java.util.ArrayList;
import java.util.List;
@@ -197,7 +198,7 @@ public class CameraSettings {
flashMode, mParameters.getSupportedFlashModes());
}
if (focusMode != null) {
- if (!Util.isFocusAreaSupported(mParameters)) {
+ if (!CameraUtil.isFocusAreaSupported(mParameters)) {
filterUnsupportedOptions(group,
focusMode, mParameters.getSupportedFocusModes());
} else {
@@ -228,7 +229,7 @@ public class CameraSettings {
}
}
if (cameraHdr != null && (!ApiHelper.HAS_CAMERA_HDR
- || !Util.isCameraHdrSupported(mParameters))) {
+ || !CameraUtil.isCameraHdrSupported(mParameters))) {
removePreference(group, cameraHdr.getKey());
}
}
@@ -553,8 +554,8 @@ public class CameraSettings {
EffectsRecorder.isEffectSupported(EffectsRecorder.EFFECT_GOOFY_FACE);
boolean backdropperSupported =
EffectsRecorder.isEffectSupported(EffectsRecorder.EFFECT_BACKDROPPER) &&
- Util.isAutoExposureLockSupported(mParameters) &&
- Util.isAutoWhiteBalanceLockSupported(mParameters);
+ CameraUtil.isAutoExposureLockSupported(mParameters) &&
+ CameraUtil.isAutoWhiteBalanceLockSupported(mParameters);
ArrayList<String> supported = new ArrayList<String>();
for (CharSequence value : values) {
diff --git a/src/com/android/camera/CaptureAnimManager.java b/src/com/android/camera/CaptureAnimManager.java
deleted file mode 100644
index 3510d7528..000000000
--- a/src/com/android/camera/CaptureAnimManager.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Color;
-import android.os.SystemClock;
-import android.view.animation.DecelerateInterpolator;
-import android.view.animation.Interpolator;
-
-import com.android.camera.support.glrenderer.GLCanvas;
-import com.android.camera.support.glrenderer.NinePatchTexture;
-import com.android.camera.support.glrenderer.RawTexture;
-import com.android.camera2.R;
-
-/**
- * Class to handle the capture animation.
- */
-public class CaptureAnimManager {
- @SuppressWarnings("unused")
- private static final String TAG = "CAM_Capture";
- // times mark endpoint of animation phase
- private static final int TIME_FLASH = 200;
- private static final int TIME_HOLD = 400;
- private static final int TIME_SLIDE = 800;
- private static final int TIME_HOLD2 = 3300;
- private static final int TIME_SLIDE2 = 4100;
-
- private static final int ANIM_BOTH = 0;
- private static final int ANIM_FLASH = 1;
- private static final int ANIM_SLIDE = 2;
- private static final int ANIM_HOLD2 = 3;
- private static final int ANIM_SLIDE2 = 4;
-
- private final Interpolator mSlideInterpolator = new DecelerateInterpolator();
-
- private volatile int mAnimOrientation; // Could be 0, 90, 180 or 270 degrees.
- private long mAnimStartTime; // milliseconds.
- private float mX; // The center of the whole view including preview and review.
- private float mY;
- private int mDrawWidth;
- private int mDrawHeight;
- private int mAnimType;
-
- private int mHoldX;
- private int mHoldY;
- private int mHoldW;
- private int mHoldH;
-
- private int mOffset;
-
- private int mMarginRight;
- 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(Context ctx) {
- mBorder = new NinePatchTexture(ctx, R.drawable.capture_thumbnail_shadow);
- mResources = ctx.getResources();
- }
-
- public void setOrientation(int displayRotation) {
- mAnimOrientation = (360 - displayRotation) % 360;
- }
-
- public void animateSlide() {
- if (mAnimType != ANIM_FLASH) {
- return;
- }
- mAnimType = ANIM_SLIDE;
- mAnimStartTime = SystemClock.uptimeMillis();
- }
-
- public void animateFlash() {
- mAnimType = ANIM_FLASH;
- }
-
- public void animateFlashAndSlide() {
- mAnimType = ANIM_BOTH;
- }
-
- public void startAnimation() {
- mAnimStartTime = SystemClock.uptimeMillis();
- }
-
- 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;
- mDrawHeight = h;
- mX = x;
- mY = y;
- mHoldW = mSize;
- mHoldH = mSize;
- switch (mAnimOrientation) {
- case 0: // Preview is on the left.
- mHoldX = x + w - mMarginRight - mSize;
- mHoldY = y + mMarginTop;
- break;
- case 90: // Preview is below.
- mHoldX = x + mMarginTop;
- mHoldY = y + mMarginRight;
- break;
- case 180: // Preview on the right.
- mHoldX = x + mMarginRight;
- mHoldY = y + h - mMarginTop - mSize;
- break;
- case 270: // Preview is above.
- mHoldX = x + w - mMarginTop - mSize;
- mHoldY = y + h - mMarginRight - mSize;
- break;
- }
- }
-
- // Returns true if the animation has been drawn.
- public boolean drawAnimation(GLCanvas canvas, CameraScreenNail preview,
- RawTexture review, int lx, int ly, int lw, int lh) {
- setAnimationGeometry(lx, ly, lw, lh);
- long timeDiff = SystemClock.uptimeMillis() - mAnimStartTime;
- // Check if the animation is over
- if (mAnimType == ANIM_SLIDE && timeDiff > TIME_SLIDE2 - TIME_HOLD) return false;
- if (mAnimType == ANIM_BOTH && timeDiff > TIME_SLIDE2) return false;
-
- // determine phase and time in phase
- int animStep = mAnimType;
- if (mAnimType == ANIM_SLIDE) {
- timeDiff += TIME_HOLD;
- }
- if (mAnimType == ANIM_SLIDE || mAnimType == ANIM_BOTH) {
- if (timeDiff < TIME_HOLD) {
- animStep = ANIM_FLASH;
- } else if (timeDiff < TIME_SLIDE) {
- animStep = ANIM_SLIDE;
- timeDiff -= TIME_HOLD;
- } else if (timeDiff < TIME_HOLD2) {
- animStep = ANIM_HOLD2;
- timeDiff -= TIME_SLIDE;
- } else {
- // SLIDE2
- animStep = ANIM_SLIDE2;
- timeDiff -= TIME_HOLD2;
- }
- }
-
- if (animStep == ANIM_FLASH) {
- review.draw(canvas, (int) mX, (int) mY, mDrawWidth, mDrawHeight);
- if (timeDiff < TIME_FLASH) {
- float f = 0.3f - 0.3f * timeDiff / TIME_FLASH;
- int color = Color.argb((int) (255 * f), 255, 255, 255);
- canvas.fillRect(mX, mY, mDrawWidth, mDrawHeight, color);
- }
- } else if (animStep == ANIM_SLIDE) {
- float fraction = mSlideInterpolator.getInterpolation((float) (timeDiff) / (TIME_SLIDE - TIME_HOLD));
- float x = mX;
- float y = mY;
- float w = 0;
- float h = 0;
- x = interpolate(mX, mHoldX, fraction);
- y = interpolate(mY, mHoldY, fraction);
- w = interpolate(mDrawWidth, mHoldW, fraction);
- h = interpolate(mDrawHeight, mHoldH, fraction);
- preview.directDraw(canvas, (int) mX, (int) mY, mDrawWidth, mDrawHeight);
- review.draw(canvas, (int) x, (int) y, (int) w, (int) h);
- } 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;
- float y = mHoldY;
- float d = mOffset * fraction;
- switch (mAnimOrientation) {
- case 0:
- x = mHoldX + d;
- break;
- case 180:
- x = mHoldX - d;
- break;
- case 90:
- y = mHoldY - d;
- break;
- case 270:
- y = mHoldY + d;
- 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;
- }
-
- private static float interpolate(float start, float end, float fraction) {
- return start + (end - start) * fraction;
- }
-
-}
diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java
index 901226364..151441ef9 100644
--- a/src/com/android/camera/EffectsRecorder.java
+++ b/src/com/android/camera/EffectsRecorder.java
@@ -33,7 +33,8 @@ import android.os.Handler;
import android.os.Looper;
import android.util.Log;
-import com.android.camera.support.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
+import com.android.camera.util.CameraUtil;
import com.android.camera2.R;
@@ -1056,8 +1057,8 @@ public class EffectsRecorder {
return false;
}
Camera.Parameters params = mCameraDevice.getParameters();
- if (Util.isAutoExposureLockSupported(params) &&
- Util.isAutoWhiteBalanceLockSupported(params)) {
+ if (CameraUtil.isAutoExposureLockSupported(params) &&
+ CameraUtil.isAutoWhiteBalanceLockSupported(params)) {
params.setAutoExposureLock(toggle);
params.setAutoWhiteBalanceLock(toggle);
mCameraDevice.setParameters(params);
diff --git a/src/com/android/camera/FocusOverlayManager.java b/src/com/android/camera/FocusOverlayManager.java
index 7a9e1dd6d..d3215e7a6 100644
--- a/src/com/android/camera/FocusOverlayManager.java
+++ b/src/com/android/camera/FocusOverlayManager.java
@@ -30,7 +30,8 @@ import android.os.Looper;
import android.os.Message;
import android.util.Log;
-import com.android.camera.support.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
+import com.android.camera.util.CameraUtil;
/* A class that handles everything about focus in still picture mode.
* This also handles the metering area because it is the same as focus area.
@@ -151,10 +152,10 @@ public class FocusOverlayManager {
// camera is open.
if (parameters == null) return;
mParameters = parameters;
- mFocusAreaSupported = Util.isFocusAreaSupported(parameters);
- mMeteringAreaSupported = Util.isMeteringAreaSupported(parameters);
- mLockAeAwbNeeded = (Util.isAutoExposureLockSupported(mParameters) ||
- Util.isAutoWhiteBalanceLockSupported(mParameters));
+ mFocusAreaSupported = CameraUtil.isFocusAreaSupported(parameters);
+ mMeteringAreaSupported = CameraUtil.isMeteringAreaSupported(parameters);
+ mLockAeAwbNeeded = (CameraUtil.isAutoExposureLockSupported(mParameters) ||
+ CameraUtil.isAutoWhiteBalanceLockSupported(mParameters));
}
public void setPreviewSize(int previewWidth, int previewHeight) {
@@ -178,7 +179,7 @@ public class FocusOverlayManager {
private void setMatrix() {
if (mPreviewWidth != 0 && mPreviewHeight != 0) {
Matrix matrix = new Matrix();
- Util.prepareMatrix(matrix, mMirror, mDisplayOrientation,
+ CameraUtil.prepareMatrix(matrix, mMirror, mDisplayOrientation,
mPreviewWidth, mPreviewHeight);
// In face detection, the matrix converts the driver coordinates to UI
// coordinates. In tap focus, the inverted matrix converts the UI
@@ -440,17 +441,17 @@ public class FocusOverlayManager {
if (mFocusMode == null) {
for (int i = 0; i < mDefaultFocusModes.length; i++) {
String mode = mDefaultFocusModes[i];
- if (Util.isSupported(mode, supportedFocusModes)) {
+ if (CameraUtil.isSupported(mode, supportedFocusModes)) {
mFocusMode = mode;
break;
}
}
}
}
- if (!Util.isSupported(mFocusMode, supportedFocusModes)) {
+ if (!CameraUtil.isSupported(mFocusMode, supportedFocusModes)) {
// For some reasons, the driver does not support the current
// focus mode. Fall back to auto.
- if (Util.isSupported(Parameters.FOCUS_MODE_AUTO,
+ if (CameraUtil.isSupported(Parameters.FOCUS_MODE_AUTO,
mParameters.getSupportedFocusModes())) {
mFocusMode = Parameters.FOCUS_MODE_AUTO;
} else {
@@ -484,7 +485,7 @@ public class FocusOverlayManager {
} else if (mState == STATE_FOCUSING || mState == STATE_FOCUSING_SNAP_ON_FINISH) {
mUI.onFocusStarted();
} else {
- if (Util.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusMode)) {
+ if (CameraUtil.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusMode)) {
// TODO: check HAL behavior and decide if this can be removed.
mUI.onFocusSucceeded(false);
} else if (mState == STATE_SUCCESS) {
@@ -513,12 +514,12 @@ public class FocusOverlayManager {
private void calculateTapArea(int x, int y, float areaMultiple, Rect rect) {
int areaSize = (int) (Math.min(mPreviewWidth, mPreviewHeight) * areaMultiple / 20);
- int left = Util.clamp(x - areaSize, 0, mPreviewWidth - 2 * areaSize);
- int top = Util.clamp(y - areaSize, 0, mPreviewHeight - 2 * areaSize);
+ int left = CameraUtil.clamp(x - areaSize, 0, mPreviewWidth - 2 * areaSize);
+ int top = CameraUtil.clamp(y - areaSize, 0, mPreviewHeight - 2 * areaSize);
RectF rectF = new RectF(left, top, left + 2 * areaSize, top + 2 * areaSize);
mMatrix.mapRect(rectF);
- Util.rectFToRect(rectF, rect);
+ CameraUtil.rectFToRect(rectF, rect);
}
/* package */ int getFocusState() {
diff --git a/src/com/android/camera/ListPreference.java b/src/com/android/camera/ListPreference.java
index f593b35e5..34040d79b 100644
--- a/src/com/android/camera/ListPreference.java
+++ b/src/com/android/camera/ListPreference.java
@@ -26,6 +26,7 @@ import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
+import com.android.camera.util.CameraUtil;
import com.android.camera2.R;
/**
@@ -49,7 +50,7 @@ public class ListPreference extends CameraPreference {
TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.ListPreference, 0, 0);
- mKey = Util.checkNotNull(
+ mKey = CameraUtil.checkNotNull(
a.getString(R.styleable.ListPreference_key));
// We allow the defaultValue attribute to be a string or an array of
@@ -137,7 +138,7 @@ public class ListPreference extends CameraPreference {
public int findIndexOfValue(String value) {
for (int i = 0, n = mEntryValues.length; i < n; ++i) {
- if (Util.equals(mEntryValues[i], value)) return i;
+ if (CameraUtil.equals(mEntryValues[i], value)) return i;
}
return -1;
}
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 5c96592fe..8d68320bf 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -65,13 +65,13 @@ import com.android.camera.CameraManager.CameraAFMoveCallback;
import com.android.camera.CameraManager.CameraPictureCallback;
import com.android.camera.CameraManager.CameraProxy;
import com.android.camera.CameraManager.CameraShutterCallback;
-import com.android.camera.support.filtershow.crop.CropExtras;
+import com.android.camera.util.ApiHelper;
import com.android.camera.ui.CountDownView.OnCountDownFinishedListener;
import com.android.camera.ui.PopupManager;
import com.android.camera.ui.RotateTextToast;
+import com.android.camera.util.CameraUtil;
import com.android.camera.util.UsageStatistics;
import com.android.camera2.R;
-import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.exif.ExifInterface;
import com.android.gallery3d.exif.ExifTag;
import com.android.gallery3d.exif.Rational;
@@ -277,7 +277,7 @@ public class PhotoModule
// We need to check whether the activity is paused before long
// operations to ensure that onPause() can be done ASAP.
if (mCancelled) return;
- mCameraDevice = Util.openCamera(mActivity, mCameraId);
+ mCameraDevice = CameraUtil.openCamera(mActivity, mCameraId);
mParameters = mCameraDevice.getParameters();
// Wait until all the initialization needed by startPreview are
// done.
@@ -336,7 +336,7 @@ public class PhotoModule
// down and camera app is opened. Rotation animation will
// take some time and the rotation value we have got may be
// wrong. Framework does not have a callback for this now.
- if (Util.getDisplayRotation(mActivity) != mDisplayRotation) {
+ if (CameraUtil.getDisplayRotation(mActivity) != mDisplayRotation) {
setDisplayOrientation();
}
if (SystemClock.uptimeMillis() - mOnResumeTime < 5000) {
@@ -374,7 +374,7 @@ public class PhotoModule
case OPEN_CAMERA_FAIL: {
mCameraStartUpThread = null;
mOpenCameraFail = true;
- Util.showErrorAndFinish(mActivity,
+ CameraUtil.showErrorAndFinish(mActivity,
R.string.cannot_connect_camera);
break;
}
@@ -382,7 +382,7 @@ public class PhotoModule
case CAMERA_DISABLED: {
mCameraStartUpThread = null;
mCameraDisabled = true;
- Util.showErrorAndFinish(mActivity,
+ CameraUtil.showErrorAndFinish(mActivity,
R.string.camera_disabled);
break;
}
@@ -495,13 +495,13 @@ public class PhotoModule
mPreferences.setLocalId(mActivity, mCameraId);
CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
try {
- mCameraDevice = Util.openCamera(mActivity, mCameraId);
+ mCameraDevice = CameraUtil.openCamera(mActivity, mCameraId);
mParameters = mCameraDevice.getParameters();
} catch (CameraHardwareException e) {
- Util.showErrorAndFinish(mActivity, R.string.cannot_connect_camera);
+ CameraUtil.showErrorAndFinish(mActivity, R.string.cannot_connect_camera);
return;
} catch (CameraDisabledException e) {
- Util.showErrorAndFinish(mActivity, R.string.camera_disabled);
+ CameraUtil.showErrorAndFinish(mActivity, R.string.camera_disabled);
return;
}
initializeCapabilities();
@@ -734,7 +734,7 @@ public class PhotoModule
// Animate capture with real jpeg data instead of a preview frame.
mUI.animateCapture(jpegData);
}
- if (mSceneMode == Util.SCENE_MODE_HDR) {
+ if (mSceneMode == CameraUtil.SCENE_MODE_HDR) {
mUI.showSwitcher();
mUI.setSwipingEnabled(true);
}
@@ -860,7 +860,7 @@ public class PhotoModule
public void nameNewImage(ContentResolver resolver, long date) {
NamedEntity r = new NamedEntity();
- r.title = Util.createJpegName(date);
+ r.title = CameraUtil.createJpegName(date);
r.date = date;
mQueue.add(r);
}
@@ -924,7 +924,7 @@ public class PhotoModule
mPostViewPictureCallbackTime = 0;
mJpegImageData = null;
- final boolean animateBefore = (mSceneMode == Util.SCENE_MODE_HDR);
+ final boolean animateBefore = (mSceneMode == CameraUtil.SCENE_MODE_HDR);
if (animateBefore) {
animateAfterShutter();
@@ -939,10 +939,10 @@ public class PhotoModule
} else {
orientation = mOrientation;
}
- mJpegRotation = Util.getJpegRotation(mCameraId, orientation);
+ mJpegRotation = CameraUtil.getJpegRotation(mCameraId, orientation);
mParameters.setRotation(mJpegRotation);
Location loc = mLocationManager.getCurrentLocation();
- Util.setGpsParameters(mParameters, loc);
+ CameraUtil.setGpsParameters(mParameters, loc);
mCameraDevice.setParameters(mParameters);
mCameraDevice.takePicture(mHandler,
@@ -965,7 +965,7 @@ public class PhotoModule
}
private int getPreferredCameraId(ComboPreferences preferences) {
- int intentCameraId = Util.getCameraFacingIntentExtras(mActivity);
+ int intentCameraId = CameraUtil.getCameraFacingIntentExtras(mActivity);
if (intentCameraId != -1) {
// Testing purpose. Launch a specific camera through the intent
// extras.
@@ -1006,7 +1006,7 @@ public class PhotoModule
// the camera then point the camera to floor or sky, we still have
// the correct orientation.
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) return;
- mOrientation = Util.roundOrientation(orientation, mOrientation);
+ mOrientation = CameraUtil.roundOrientation(orientation, mOrientation);
// Show the toast after getting the first orientation changed.
if (mHandler.hasMessages(SHOW_TAP_TO_FOCUS_TOAST)) {
@@ -1062,13 +1062,13 @@ public class PhotoModule
} catch (IOException ex) {
// ignore exception
} finally {
- Util.closeSilently(outputStream);
+ CameraUtil.closeSilently(outputStream);
}
} else {
ExifInterface exif = Exif.getExif(data);
int orientation = Exif.getOrientation(exif);
- Bitmap bitmap = Util.makeBitmap(data, 50 * 1024);
- bitmap = Util.rotate(bitmap, orientation);
+ Bitmap bitmap = CameraUtil.makeBitmap(data, 50 * 1024);
+ bitmap = CameraUtil.rotate(bitmap, orientation);
mActivity.setResultEx(Activity.RESULT_OK,
new Intent("inline-data").putExtra("data", bitmap));
mActivity.finish();
@@ -1093,7 +1093,7 @@ public class PhotoModule
mActivity.finish();
return;
} finally {
- Util.closeSilently(tempStream);
+ CameraUtil.closeSilently(tempStream);
}
Bundle newExtras = new Bundle();
@@ -1103,10 +1103,10 @@ public class PhotoModule
if (mSaveUri != null) {
newExtras.putParcelable(MediaStore.EXTRA_OUTPUT, mSaveUri);
} else {
- newExtras.putBoolean(CropExtras.KEY_RETURN_DATA, true);
+ newExtras.putBoolean(CameraUtil.KEY_RETURN_DATA, true);
}
if (mActivity.isSecureCamera()) {
- newExtras.putBoolean(CropExtras.KEY_SHOW_WHEN_LOCKED, true);
+ newExtras.putBoolean(CameraUtil.KEY_SHOW_WHEN_LOCKED, true);
}
// TODO: Share this constant.
@@ -1154,7 +1154,7 @@ public class PhotoModule
}
Log.v(TAG, "onShutterButtonClick: mCameraState=" + mCameraState);
- if (mSceneMode == Util.SCENE_MODE_HDR) {
+ if (mSceneMode == CameraUtil.SCENE_MODE_HDR) {
mUI.hideSwitcher();
mUI.setSwipingEnabled(false);
}
@@ -1355,7 +1355,7 @@ public class PhotoModule
@Override
public void updateCameraOrientation() {
- if (mDisplayRotation != Util.getDisplayRotation(mActivity)) {
+ if (mDisplayRotation != CameraUtil.getDisplayRotation(mActivity)) {
setDisplayOrientation();
}
}
@@ -1490,8 +1490,8 @@ public class PhotoModule
}
private void setDisplayOrientation() {
- mDisplayRotation = Util.getDisplayRotation(mActivity);
- mDisplayOrientation = Util.getDisplayOrientation(mDisplayRotation, mCameraId);
+ mDisplayRotation = CameraUtil.getDisplayRotation(mActivity);
+ mDisplayOrientation = CameraUtil.getDisplayOrientation(mDisplayRotation, mCameraId);
mCameraDisplayOrientation = mDisplayOrientation;
mUI.setDisplayOrientation(mDisplayOrientation);
if (mFocusManager != null) {
@@ -1526,7 +1526,7 @@ public class PhotoModule
if (!mSnapshotOnIdle) {
// If the focus mode is continuous autofocus, call cancelAutoFocus to
// resume it because it may have been paused by autoFocus call.
- if (Util.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusManager.getFocusMode())) {
+ if (CameraUtil.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusManager.getFocusMode())) {
mCameraDevice.cancelAutoFocus();
}
mFocusManager.setAeAwbLock(false); // Unlock AE and AWB.
@@ -1563,14 +1563,14 @@ public class PhotoModule
private void updateCameraParametersInitialize() {
// Reset preview frame rate to the maximum because it may be lowered by
// video camera application.
- int[] fpsRange = Util.getMaxPreviewFpsRange(mParameters);
+ int[] fpsRange = CameraUtil.getMaxPreviewFpsRange(mParameters);
if (fpsRange.length > 0) {
mParameters.setPreviewFpsRange(
fpsRange[Parameters.PREVIEW_FPS_MIN_INDEX],
fpsRange[Parameters.PREVIEW_FPS_MAX_INDEX]);
}
- mParameters.set(Util.RECORDING_HINT, Util.FALSE);
+ mParameters.set(CameraUtil.RECORDING_HINT, CameraUtil.FALSE);
// Disable video stabilization. Convenience methods not available in API
// level <= 14
@@ -1637,7 +1637,7 @@ public class PhotoModule
// Set a preview size that is closest to the viewfinder height and has
// the right aspect ratio.
List<Size> sizes = mParameters.getSupportedPreviewSizes();
- Size optimalSize = Util.getOptimalPreviewSize(mActivity, sizes,
+ Size optimalSize = CameraUtil.getOptimalPreviewSize(mActivity, sizes,
(double) size.width / size.height);
Size original = mParameters.getPreviewSize();
if (!original.equals(optimalSize)) {
@@ -1661,13 +1661,13 @@ public class PhotoModule
String hdr = mPreferences.getString(CameraSettings.KEY_CAMERA_HDR,
mActivity.getString(R.string.pref_camera_hdr_default));
if (mActivity.getString(R.string.setting_on_value).equals(hdr)) {
- mSceneMode = Util.SCENE_MODE_HDR;
+ mSceneMode = CameraUtil.SCENE_MODE_HDR;
} else {
mSceneMode = mPreferences.getString(
CameraSettings.KEY_SCENE_MODE,
mActivity.getString(R.string.pref_camera_scenemode_default));
}
- if (Util.isSupported(mSceneMode, mParameters.getSupportedSceneModes())) {
+ if (CameraUtil.isSupported(mSceneMode, mParameters.getSupportedSceneModes())) {
if (!mParameters.getSceneMode().equals(mSceneMode)) {
mParameters.setSceneMode(mSceneMode);
@@ -1708,7 +1708,7 @@ public class PhotoModule
CameraSettings.KEY_FLASH_MODE,
mActivity.getString(R.string.pref_camera_flashmode_default));
List<String> supportedFlash = mParameters.getSupportedFlashModes();
- if (Util.isSupported(flashMode, supportedFlash)) {
+ if (CameraUtil.isSupported(flashMode, supportedFlash)) {
mParameters.setFlashMode(flashMode);
} else {
flashMode = mParameters.getFlashMode();
@@ -1722,7 +1722,7 @@ public class PhotoModule
String whiteBalance = mPreferences.getString(
CameraSettings.KEY_WHITE_BALANCE,
mActivity.getString(R.string.pref_camera_whitebalance_default));
- if (Util.isSupported(whiteBalance,
+ if (CameraUtil.isSupported(whiteBalance,
mParameters.getSupportedWhiteBalance())) {
mParameters.setWhiteBalance(whiteBalance);
} else {
@@ -1746,7 +1746,7 @@ public class PhotoModule
@TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
private void updateAutoFocusMoveCallback() {
- if (mParameters.getFocusMode().equals(Util.FOCUS_MODE_CONTINUOUS_PICTURE)) {
+ if (mParameters.getFocusMode().equals(CameraUtil.FOCUS_MODE_CONTINUOUS_PICTURE)) {
mCameraDevice.setAutoFocusMoveCallback(mHandler,
(CameraManager.CameraAFMoveCallback) mAutoFocusMoveCallback);
} else {
@@ -1885,12 +1885,12 @@ public class PhotoModule
private void initializeCapabilities() {
mInitialParams = mCameraDevice.getParameters();
- mFocusAreaSupported = Util.isFocusAreaSupported(mInitialParams);
- mMeteringAreaSupported = Util.isMeteringAreaSupported(mInitialParams);
- mAeLockSupported = Util.isAutoExposureLockSupported(mInitialParams);
- mAwbLockSupported = Util.isAutoWhiteBalanceLockSupported(mInitialParams);
+ mFocusAreaSupported = CameraUtil.isFocusAreaSupported(mInitialParams);
+ mMeteringAreaSupported = CameraUtil.isMeteringAreaSupported(mInitialParams);
+ mAeLockSupported = CameraUtil.isAutoExposureLockSupported(mInitialParams);
+ mAwbLockSupported = CameraUtil.isAutoWhiteBalanceLockSupported(mInitialParams);
mContinousFocusSupported = mInitialParams.getSupportedFocusModes().contains(
- Util.FOCUS_MODE_CONTINUOUS_PICTURE);
+ CameraUtil.FOCUS_MODE_CONTINUOUS_PICTURE);
}
@Override
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index a1de60af2..f5748ba3d 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -17,8 +17,6 @@
package com.android.camera;
-import java.util.List;
-
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.graphics.Bitmap;
@@ -47,6 +45,7 @@ import android.widget.Toast;
import com.android.camera.CameraPreference.OnPreferenceChangedListener;
import com.android.camera.FocusOverlayManager.FocusUI;
+import com.android.camera.util.ApiHelper;
import com.android.camera.ui.AbstractSettingPopup;
import com.android.camera.ui.CameraControls;
import com.android.camera.ui.CameraRootView;
@@ -60,8 +59,10 @@ import com.android.camera.ui.PieRenderer;
import com.android.camera.ui.PieRenderer.PieListener;
import com.android.camera.ui.RenderOverlay;
import com.android.camera.ui.ZoomRenderer;
+import com.android.camera.util.CameraUtil;
import com.android.camera2.R;
-import com.android.gallery3d.common.ApiHelper;
+
+import java.util.List;
public class PhotoUI implements PieListener,
PreviewGestures.SingleTapListener,
@@ -145,7 +146,7 @@ public class PhotoUI implements PieListener,
// Full-screen screennail
int w = width;
int h = height;
- if (Util.getDisplayRotation(mActivity) % 180 != 0) {
+ if (CameraUtil.getDisplayRotation(mActivity) % 180 != 0) {
w = height;
h = width;
}
@@ -168,7 +169,7 @@ public class PhotoUI implements PieListener,
@Override
protected Bitmap doInBackground(Integer... params) {
// Decode image in background.
- return Util.downSample(mData, DOWN_SAMPLE_FACTOR);
+ return CameraUtil.downSample(mData, DOWN_SAMPLE_FACTOR);
}
@Override
@@ -238,7 +239,7 @@ public class PhotoUI implements PieListener,
private void setTransformMatrix(int width, int height) {
mMatrix = mTextureView.getTransform(mMatrix);
- int orientation = Util.getDisplayRotation(mActivity);
+ int orientation = CameraUtil.getDisplayRotation(mActivity);
float scaleX = 1f, scaleY = 1f;
float scaledTextureWidth, scaledTextureHeight;
if (width > height) {
@@ -620,18 +621,18 @@ public class PhotoUI implements PieListener,
protected void showPostCaptureAlert() {
mOnScreenIndicators.setVisibility(View.GONE);
mMenuButton.setVisibility(View.GONE);
- Util.fadeIn(mReviewDoneButton);
+ CameraUtil.fadeIn(mReviewDoneButton);
mShutterButton.setVisibility(View.INVISIBLE);
- Util.fadeIn(mReviewRetakeButton);
+ CameraUtil.fadeIn(mReviewRetakeButton);
pauseFaceDetection();
}
protected void hidePostCaptureAlert() {
mOnScreenIndicators.setVisibility(View.VISIBLE);
mMenuButton.setVisibility(View.VISIBLE);
- Util.fadeOut(mReviewDoneButton);
+ CameraUtil.fadeOut(mReviewDoneButton);
mShutterButton.setVisibility(View.VISIBLE);
- Util.fadeOut(mReviewRetakeButton);
+ CameraUtil.fadeOut(mReviewRetakeButton);
resumeFaceDetection();
}
diff --git a/src/com/android/camera/PreviewFrameLayout.java b/src/com/android/camera/PreviewFrameLayout.java
index cc2d28099..2bdace69c 100644
--- a/src/com/android/camera/PreviewFrameLayout.java
+++ b/src/com/android/camera/PreviewFrameLayout.java
@@ -21,9 +21,10 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
-import com.android.camera.support.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
import com.android.camera.ui.LayoutChangeHelper;
import com.android.camera.ui.LayoutChangeNotifier;
+import com.android.camera.util.CameraUtil;
import com.android.camera2.R;
/**
@@ -68,7 +69,7 @@ public class PreviewFrameLayout extends RelativeLayout implements LayoutChangeNo
}
public void fadeOutBorder() {
- Util.fadeOut(mBorder);
+ CameraUtil.fadeOut(mBorder);
}
@Override
diff --git a/src/com/android/camera/RotateDialogController.java b/src/com/android/camera/RotateDialogController.java
deleted file mode 100644
index 45163f196..000000000
--- a/src/com/android/camera/RotateDialogController.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera;
-
-import android.app.Activity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.widget.Button;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import com.android.camera.ui.Rotatable;
-import com.android.camera.ui.RotateLayout;
-import com.android.camera2.R;
-
-public class RotateDialogController implements Rotatable {
-
- @SuppressWarnings("unused")
- private static final String TAG = "RotateDialogController";
- private static final long ANIM_DURATION = 150; // millis
-
- private Activity mActivity;
- private int mLayoutResourceID;
- private View mDialogRootLayout;
- private RotateLayout mRotateDialog;
- private View mRotateDialogTitleLayout;
- private View mRotateDialogButtonLayout;
- private TextView mRotateDialogTitle;
- private ProgressBar mRotateDialogSpinner;
- private TextView mRotateDialogText;
- private TextView mRotateDialogButton1;
- private TextView mRotateDialogButton2;
-
- private Animation mFadeInAnim, mFadeOutAnim;
-
- public RotateDialogController(Activity a, int layoutResource) {
- mActivity = a;
- mLayoutResourceID = layoutResource;
- }
-
- private void inflateDialogLayout() {
- if (mDialogRootLayout == null) {
- ViewGroup layoutRoot = (ViewGroup) mActivity.getWindow().getDecorView();
- LayoutInflater inflater = mActivity.getLayoutInflater();
- View v = inflater.inflate(mLayoutResourceID, layoutRoot);
- mDialogRootLayout = v.findViewById(R.id.rotate_dialog_root_layout);
- mRotateDialog = (RotateLayout) v.findViewById(R.id.rotate_dialog_layout);
- mRotateDialogTitleLayout = v.findViewById(R.id.rotate_dialog_title_layout);
- mRotateDialogButtonLayout = v.findViewById(R.id.rotate_dialog_button_layout);
- mRotateDialogTitle = (TextView) v.findViewById(R.id.rotate_dialog_title);
- mRotateDialogSpinner = (ProgressBar) v.findViewById(R.id.rotate_dialog_spinner);
- mRotateDialogText = (TextView) v.findViewById(R.id.rotate_dialog_text);
- mRotateDialogButton1 = (Button) v.findViewById(R.id.rotate_dialog_button1);
- mRotateDialogButton2 = (Button) v.findViewById(R.id.rotate_dialog_button2);
-
- mFadeInAnim = AnimationUtils.loadAnimation(
- mActivity, android.R.anim.fade_in);
- mFadeOutAnim = AnimationUtils.loadAnimation(
- mActivity, android.R.anim.fade_out);
- mFadeInAnim.setDuration(ANIM_DURATION);
- mFadeOutAnim.setDuration(ANIM_DURATION);
- }
- }
-
- @Override
- public void setOrientation(int orientation, boolean animation) {
- inflateDialogLayout();
- mRotateDialog.setOrientation(orientation, animation);
- }
-
- public void resetRotateDialog() {
- inflateDialogLayout();
- mRotateDialogTitleLayout.setVisibility(View.GONE);
- mRotateDialogSpinner.setVisibility(View.GONE);
- mRotateDialogButton1.setVisibility(View.GONE);
- mRotateDialogButton2.setVisibility(View.GONE);
- mRotateDialogButtonLayout.setVisibility(View.GONE);
- }
-
- private void fadeOutDialog() {
- mDialogRootLayout.startAnimation(mFadeOutAnim);
- mDialogRootLayout.setVisibility(View.GONE);
- }
-
- private void fadeInDialog() {
- mDialogRootLayout.startAnimation(mFadeInAnim);
- mDialogRootLayout.setVisibility(View.VISIBLE);
- }
-
- public void dismissDialog() {
- if (mDialogRootLayout != null && mDialogRootLayout.getVisibility() != View.GONE) {
- fadeOutDialog();
- }
- }
-
- public void showAlertDialog(String title, String msg, String button1Text,
- final Runnable r1, String button2Text, final Runnable r2) {
- resetRotateDialog();
-
- if (title != null) {
- mRotateDialogTitle.setText(title);
- mRotateDialogTitleLayout.setVisibility(View.VISIBLE);
- }
-
- mRotateDialogText.setText(msg);
-
- if (button1Text != null) {
- mRotateDialogButton1.setText(button1Text);
- mRotateDialogButton1.setContentDescription(button1Text);
- mRotateDialogButton1.setVisibility(View.VISIBLE);
- mRotateDialogButton1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (r1 != null) r1.run();
- dismissDialog();
- }
- });
- mRotateDialogButtonLayout.setVisibility(View.VISIBLE);
- }
- if (button2Text != null) {
- mRotateDialogButton2.setText(button2Text);
- mRotateDialogButton2.setContentDescription(button2Text);
- mRotateDialogButton2.setVisibility(View.VISIBLE);
- mRotateDialogButton2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (r2 != null) r2.run();
- dismissDialog();
- }
- });
- mRotateDialogButtonLayout.setVisibility(View.VISIBLE);
- }
-
- fadeInDialog();
- }
-
- public void showWaitingDialog(String msg) {
- resetRotateDialog();
-
- mRotateDialogText.setText(msg);
- mRotateDialogSpinner.setVisibility(View.VISIBLE);
-
- fadeInDialog();
- }
-
- public int getVisibility() {
- if (mDialogRootLayout != null) {
- return mDialogRootLayout.getVisibility();
- }
- return View.INVISIBLE;
- }
-}
diff --git a/src/com/android/camera/SoundClips.java b/src/com/android/camera/SoundClips.java
index b5cfeddaa..f981bd238 100644
--- a/src/com/android/camera/SoundClips.java
+++ b/src/com/android/camera/SoundClips.java
@@ -24,7 +24,7 @@ import android.media.SoundPool;
import android.util.Log;
import com.android.camera2.R;
-import com.android.gallery3d.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
/*
* This class controls the sound playback according to the API level.
diff --git a/src/com/android/camera/StaticBitmapScreenNail.java b/src/com/android/camera/StaticBitmapScreenNail.java
deleted file mode 100644
index 91ac35c31..000000000
--- a/src/com/android/camera/StaticBitmapScreenNail.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera;
-
-import android.graphics.Bitmap;
-
-import com.android.camera.support.ui.BitmapScreenNail;
-
-public class StaticBitmapScreenNail extends BitmapScreenNail {
- public StaticBitmapScreenNail(Bitmap bitmap) {
- super(bitmap);
- }
-
- @Override
- public void recycle() {
- // Always keep the bitmap in memory.
- }
-}
diff --git a/src/com/android/camera/Storage.java b/src/com/android/camera/Storage.java
index 4e5a7dd0e..aa2a9721b 100644
--- a/src/com/android/camera/Storage.java
+++ b/src/com/android/camera/Storage.java
@@ -32,7 +32,7 @@ import android.provider.MediaStore.Images.ImageColumns;
import android.provider.MediaStore.MediaColumns;
import android.util.Log;
-import com.android.camera.support.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
import com.android.gallery3d.exif.ExifInterface;
public class Storage {
diff --git a/src/com/android/camera/SwitchAnimManager.java b/src/com/android/camera/SwitchAnimManager.java
deleted file mode 100644
index 20a4bfd97..000000000
--- a/src/com/android/camera/SwitchAnimManager.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera;
-
-import android.os.SystemClock;
-import android.util.Log;
-
-import com.android.camera.support.glrenderer.GLCanvas;
-import com.android.camera.support.glrenderer.RawTexture;
-
-/**
- * Class to handle the animation when switching between back and front cameras.
- * An image of the previous camera zooms in and fades out. The preview of the
- * new camera zooms in and fades in. The image of the previous camera is called
- * review in this class.
- */
-public class SwitchAnimManager {
- private static final String TAG = "SwitchAnimManager";
- // The amount of change for zooming in and out.
- private static final float ZOOM_DELTA_PREVIEW = 0.2f;
- private static final float ZOOM_DELTA_REVIEW = 0.5f;
- private static final float ANIMATION_DURATION = 400; // ms
- public static final float INITIAL_DARKEN_ALPHA = 0.8f;
-
- private long mAnimStartTime; // milliseconds.
- // The drawing width and height of the review image. This is saved when the
- // texture is copied.
- private int mReviewDrawingWidth;
- private int mReviewDrawingHeight;
- // The maximum width of the camera screen nail width from onDraw. We need to
- // know how much the preview is scaled and scale the review the same amount.
- // For example, the preview is not full screen in film strip mode.
- private int mPreviewFrameLayoutWidth;
-
- public SwitchAnimManager() {
- }
-
- public void setReviewDrawingSize(int width, int height) {
- mReviewDrawingWidth = width;
- mReviewDrawingHeight = height;
- }
-
- // width: the width of PreviewFrameLayout view.
- // height: the height of PreviewFrameLayout view. Not used. Kept for
- // consistency.
- public void setPreviewFrameLayoutSize(int width, int height) {
- mPreviewFrameLayoutWidth = width;
- }
-
- // w and h: the rectangle area where the animation takes place.
- public void startAnimation() {
- mAnimStartTime = SystemClock.uptimeMillis();
- }
-
- // Returns true if the animation has been drawn.
- // preview: camera preview view.
- // review: snapshot of the preview before switching the camera.
- public boolean drawAnimation(GLCanvas canvas, int x, int y, int width,
- int height, CameraScreenNail preview, RawTexture review) {
- long timeDiff = SystemClock.uptimeMillis() - mAnimStartTime;
- if (timeDiff > ANIMATION_DURATION) return false;
- float fraction = timeDiff / ANIMATION_DURATION;
-
- // Calculate the position and the size of the preview.
- float centerX = x + width / 2f;
- float centerY = y + height / 2f;
- float previewAnimScale = 1 - ZOOM_DELTA_PREVIEW * (1 - fraction);
- float previewWidth = width * previewAnimScale;
- float previewHeight = height * previewAnimScale;
- int previewX = Math.round(centerX - previewWidth / 2);
- int previewY = Math.round(centerY - previewHeight / 2);
-
- // Calculate the position and the size of the review.
- float reviewAnimScale = 1 + ZOOM_DELTA_REVIEW * fraction;
-
- // Calculate how much preview is scaled.
- // The scaling is done by PhotoView in Gallery so we don't have the
- // scaling information but only the width and the height passed to this
- // method. The inference of the scale ratio is done by matching the
- // current width and the original width we have at first when the camera
- // layout is inflated.
- float scaleRatio = 1;
- if (mPreviewFrameLayoutWidth != 0) {
- scaleRatio = (float) width / mPreviewFrameLayoutWidth;
- } else {
- Log.e(TAG, "mPreviewFrameLayoutWidth is 0.");
- }
- float reviewWidth = mReviewDrawingWidth * reviewAnimScale * scaleRatio;
- float reviewHeight = mReviewDrawingHeight * reviewAnimScale * scaleRatio;
- int reviewX = Math.round(centerX - reviewWidth / 2);
- int reviewY = Math.round(centerY - reviewHeight / 2);
-
- // Draw the preview.
- float alpha = canvas.getAlpha();
- canvas.setAlpha(fraction); // fade in
- preview.directDraw(canvas, previewX, previewY, Math.round(previewWidth),
- Math.round(previewHeight));
-
- // Draw the review.
- canvas.setAlpha((1f - fraction) * INITIAL_DARKEN_ALPHA); // fade out
- review.draw(canvas, reviewX, reviewY, Math.round(reviewWidth),
- Math.round(reviewHeight));
- canvas.setAlpha(alpha);
- return true;
- }
-
- public boolean drawDarkPreview(GLCanvas canvas, int x, int y, int width,
- int height, RawTexture review) {
- // Calculate the position and the size.
- float centerX = x + width / 2f;
- float centerY = y + height / 2f;
- float scaleRatio = 1;
- if (mPreviewFrameLayoutWidth != 0) {
- scaleRatio = (float) width / mPreviewFrameLayoutWidth;
- } else {
- Log.e(TAG, "mPreviewFrameLayoutWidth is 0.");
- }
- float reviewWidth = mReviewDrawingWidth * scaleRatio;
- float reviewHeight = mReviewDrawingHeight * scaleRatio;
- int reviewX = Math.round(centerX - reviewWidth / 2);
- int reviewY = Math.round(centerY - reviewHeight / 2);
-
- // Draw the review.
- float alpha = canvas.getAlpha();
- canvas.setAlpha(INITIAL_DARKEN_ALPHA);
- review.draw(canvas, reviewX, reviewY, Math.round(reviewWidth),
- Math.round(reviewHeight));
- canvas.setAlpha(alpha);
- return true;
- }
-
-}
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 80bbbca37..90915334e 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -16,13 +16,6 @@
package com.android.camera;
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ActivityNotFoundException;
@@ -63,15 +56,23 @@ import android.widget.Toast;
import com.android.camera.CameraManager.CameraPictureCallback;
import com.android.camera.CameraManager.CameraProxy;
-import com.android.camera.support.app.OrientationManager;
-import com.android.camera.support.util.AccessibilityUtils;
+import com.android.camera.app.OrientationManager;
+import com.android.camera.util.ApiHelper;
+import com.android.camera.util.AccessibilityUtils;
import com.android.camera.ui.PopupManager;
import com.android.camera.ui.RotateTextToast;
+import com.android.camera.util.CameraUtil;
import com.android.camera.util.UsageStatistics;
import com.android.camera2.R;
-import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.exif.ExifInterface;
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
public class VideoModule implements CameraModule,
VideoController,
CameraPreference.OnPreferenceChangedListener,
@@ -223,7 +224,7 @@ public class VideoModule implements CameraModule,
private void openCamera() {
try {
if (mCameraDevice == null) {
- mCameraDevice = Util.openCamera(mActivity, mCameraId);
+ mCameraDevice = CameraUtil.openCamera(mActivity, mCameraId);
}
mParameters = mCameraDevice.getParameters();
} catch (CameraHardwareException e) {
@@ -261,7 +262,7 @@ public class VideoModule implements CameraModule,
// down and camera app is opened. Rotation animation will
// take some time and the rotation value we have got may be
// wrong. Framework does not have a callback for this now.
- if ((Util.getDisplayRotation(mActivity) != mDisplayRotation)
+ if ((CameraUtil.getDisplayRotation(mActivity) != mDisplayRotation)
&& !mMediaRecorderRecording && !mSwitchingCamera) {
startPreview();
}
@@ -321,7 +322,7 @@ public class VideoModule implements CameraModule,
}
private int getPreferredCameraId(ComboPreferences preferences) {
- int intentCameraId = Util.getCameraFacingIntentExtras(mActivity);
+ int intentCameraId = CameraUtil.getCameraFacingIntentExtras(mActivity);
if (intentCameraId != -1) {
// Testing purpose. Launch a specific camera through the intent
// extras.
@@ -370,10 +371,10 @@ public class VideoModule implements CameraModule,
try {
cameraOpenThread.join();
if (mOpenCameraFail) {
- Util.showErrorAndFinish(mActivity, R.string.cannot_connect_camera);
+ CameraUtil.showErrorAndFinish(mActivity, R.string.cannot_connect_camera);
return;
} else if (mCameraDisabled) {
- Util.showErrorAndFinish(mActivity, R.string.camera_disabled);
+ CameraUtil.showErrorAndFinish(mActivity, R.string.camera_disabled);
return;
}
} catch (InterruptedException ex) {
@@ -424,10 +425,10 @@ public class VideoModule implements CameraModule,
}
// Set rotation and gps data.
- int rotation = Util.getJpegRotation(mCameraId, mOrientation);
+ int rotation = CameraUtil.getJpegRotation(mCameraId, mOrientation);
mParameters.setRotation(rotation);
Location loc = mLocationManager.getCurrentLocation();
- Util.setGpsParameters(mParameters, loc);
+ CameraUtil.setGpsParameters(mParameters, loc);
mCameraDevice.setParameters(mParameters);
Log.v(TAG, "Video snapshot start");
@@ -466,7 +467,7 @@ public class VideoModule implements CameraModule,
// the camera then point the camera to floor or sky, we still have
// the correct orientation.
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) return;
- int newOrientation = Util.roundOrientation(orientation, mOrientation);
+ int newOrientation = CameraUtil.roundOrientation(orientation, mOrientation);
if (mOrientation != newOrientation) {
mOrientation = newOrientation;
@@ -668,7 +669,7 @@ public class VideoModule implements CameraModule,
it.remove();
}
}
- Size optimalSize = Util.getOptimalPreviewSize(mActivity, sizes,
+ Size optimalSize = CameraUtil.getOptimalPreviewSize(mActivity, sizes,
(double) mProfile.videoFrameWidth / mProfile.videoFrameHeight);
mDesiredPreviewWidth = optimalSize.width;
mDesiredPreviewHeight = optimalSize.height;
@@ -716,11 +717,11 @@ public class VideoModule implements CameraModule,
resetEffect();
openCamera();
if (mOpenCameraFail) {
- Util.showErrorAndFinish(mActivity,
+ CameraUtil.showErrorAndFinish(mActivity,
R.string.cannot_connect_camera);
return;
} else if (mCameraDisabled) {
- Util.showErrorAndFinish(mActivity, R.string.camera_disabled);
+ CameraUtil.showErrorAndFinish(mActivity, R.string.camera_disabled);
return;
}
readVideoPreferences();
@@ -753,8 +754,8 @@ public class VideoModule implements CameraModule,
}
private void setDisplayOrientation() {
- mDisplayRotation = Util.getDisplayRotation(mActivity);
- mCameraDisplayOrientation = Util.getDisplayOrientation(mDisplayRotation, mCameraId);
+ mDisplayRotation = CameraUtil.getDisplayRotation(mActivity);
+ mCameraDisplayOrientation = CameraUtil.getDisplayOrientation(mDisplayRotation, mCameraId);
// Change the camera display orientation
if (mCameraDevice != null) {
mCameraDevice.setDisplayOrientation(mCameraDisplayOrientation);
@@ -764,7 +765,7 @@ public class VideoModule implements CameraModule,
@Override
public void updateCameraOrientation() {
if (mMediaRecorderRecording) return;
- if (mDisplayRotation != Util.getDisplayRotation(mActivity)) {
+ if (mDisplayRotation != CameraUtil.getDisplayRotation(mActivity)) {
setDisplayOrientation();
}
}
@@ -819,9 +820,9 @@ public class VideoModule implements CameraModule,
throw new RuntimeException("startPreview failed", ex);
} finally {
if (mOpenCameraFail) {
- Util.showErrorAndFinish(mActivity, R.string.cannot_connect_camera);
+ CameraUtil.showErrorAndFinish(mActivity, R.string.cannot_connect_camera);
} else if (mCameraDisabled) {
- Util.showErrorAndFinish(mActivity, R.string.camera_disabled);
+ CameraUtil.showErrorAndFinish(mActivity, R.string.camera_disabled);
}
}
@@ -1048,7 +1049,7 @@ public class VideoModule implements CameraModule,
// SurfaceView we will have to take everything into account so the
// display rotation is considered.
mCameraDevice.setDisplayOrientation(
- Util.getDisplayOrientation(mDisplayRotation, mCameraId));
+ CameraUtil.getDisplayOrientation(mDisplayRotation, mCameraId));
mCameraDevice.startPreview();
mPreviewing = true;
mMediaRecorder.setPreviewDisplay(mUI.getSurfaceHolder().getSurface());
@@ -1496,7 +1497,7 @@ public class VideoModule implements CameraModule,
// it to match the UI orientation (and mirror if it is front-facing camera).
CameraInfo[] info = CameraHolder.instance().getCameraInfo();
boolean mirror = (info[mCameraId].facing == CameraInfo.CAMERA_FACING_FRONT);
- bitmap = Util.rotateAndMirror(bitmap, 0, mirror);
+ bitmap = CameraUtil.rotateAndMirror(bitmap, 0, mirror);
}
return bitmap;
}
@@ -1730,7 +1731,7 @@ public class VideoModule implements CameraModule,
@SuppressWarnings("deprecation")
private void setCameraParameters() {
mParameters.setPreviewSize(mDesiredPreviewWidth, mDesiredPreviewHeight);
- int[] fpsRange = Util.getMaxPreviewFpsRange(mParameters);
+ int[] fpsRange = CameraUtil.getMaxPreviewFpsRange(mParameters);
if (fpsRange.length > 0) {
mParameters.setPreviewFpsRange(
fpsRange[Parameters.PREVIEW_FPS_MIN_INDEX],
@@ -1784,7 +1785,7 @@ public class VideoModule implements CameraModule,
mParameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
}
- mParameters.set(Util.RECORDING_HINT, Util.TRUE);
+ mParameters.set(CameraUtil.RECORDING_HINT, CameraUtil.TRUE);
// Enable video stabilization. Convenience methods not available in API
// level <= 14
@@ -1798,7 +1799,7 @@ public class VideoModule implements CameraModule,
// There we determine the preview size based on the picture size, but
// here we determine the picture size based on the preview size.
List<Size> supported = mParameters.getSupportedPictureSizes();
- Size optimalSize = Util.getOptimalVideoSnapshotPictureSize(supported,
+ Size optimalSize = CameraUtil.getOptimalVideoSnapshotPictureSize(supported,
(double) mDesiredPreviewWidth / mDesiredPreviewHeight);
Size original = mParameters.getPictureSize();
if (!original.equals(optimalSize)) {
@@ -2058,7 +2059,7 @@ public class VideoModule implements CameraModule,
private void initializeVideoSnapshot() {
if (mParameters == null) return;
- if (Util.isVideoSnapshotSupported(mParameters) && !mIsVideoCaptureIntent) {
+ if (CameraUtil.isVideoSnapshotSupported(mParameters) && !mIsVideoCaptureIntent) {
// Show the tap to focus toast if this is the first start.
if (mPreferences.getBoolean(
CameraSettings.KEY_VIDEO_FIRST_USE_HINT_SHOWN, true)) {
@@ -2070,7 +2071,7 @@ public class VideoModule implements CameraModule,
void showVideoSnapshotUI(boolean enabled) {
if (mParameters == null) return;
- if (Util.isVideoSnapshotSupported(mParameters) && !mIsVideoCaptureIntent) {
+ if (CameraUtil.isVideoSnapshotSupported(mParameters) && !mIsVideoCaptureIntent) {
if (enabled) {
mUI.animateFlash();
} else {
@@ -2121,7 +2122,7 @@ public class VideoModule implements CameraModule,
private void storeImage(final byte[] data, Location loc) {
long dateTaken = System.currentTimeMillis();
- String title = Util.createJpegName(dateTaken);
+ String title = CameraUtil.createJpegName(dateTaken);
ExifInterface exif = Exif.getExif(data);
int orientation = Exif.getOrientation(exif);
Size s = mParameters.getPictureSize();
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index ee49277dc..5c7eca214 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -53,8 +53,9 @@ import com.android.camera.ui.PieRenderer;
import com.android.camera.ui.RenderOverlay;
import com.android.camera.ui.RotateLayout;
import com.android.camera.ui.ZoomRenderer;
+import com.android.camera.util.CameraUtil;
import com.android.camera2.R;
-import com.android.gallery3d.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
public class VideoUI implements PieRenderer.PieListener,
PreviewGestures.SingleTapListener,
@@ -87,7 +88,6 @@ public class VideoUI implements PieRenderer.PieListener,
private View mMenuButton;
private OnScreenIndicators mOnScreenIndicators;
private RotateLayout mRecordingTimeRect;
- private final Object mLock = new Object();
private SurfaceTexture mSurfaceTexture;
private VideoController mController;
private int mZoomMax;
@@ -124,7 +124,7 @@ public class VideoUI implements PieRenderer.PieListener,
// Full-screen screennail
int w = width;
int h = height;
- if (Util.getDisplayRotation(mActivity) % 180 != 0) {
+ if (CameraUtil.getDisplayRotation(mActivity) % 180 != 0) {
w = height;
h = width;
}
@@ -262,7 +262,7 @@ public class VideoUI implements PieRenderer.PieListener,
private void setTransformMatrix(int width, int height) {
mMatrix = mTextureView.getTransform(mMatrix);
- int orientation = Util.getDisplayRotation(mActivity);
+ int orientation = CameraUtil.getDisplayRotation(mActivity);
float scaleX = 1f, scaleY = 1f;
float scaledTextureWidth, scaledTextureHeight;
if (width > height) {
@@ -569,9 +569,9 @@ public class VideoUI implements PieRenderer.PieListener,
}
public void showReviewControls() {
- Util.fadeOut(mShutterButton);
- Util.fadeIn(mReviewDoneButton);
- Util.fadeIn(mReviewPlayButton);
+ CameraUtil.fadeOut(mShutterButton);
+ CameraUtil.fadeIn(mReviewDoneButton);
+ CameraUtil.fadeIn(mReviewPlayButton);
mReviewImage.setVisibility(View.VISIBLE);
mMenuButton.setVisibility(View.GONE);
mOnScreenIndicators.setVisibility(View.GONE);
@@ -582,9 +582,9 @@ public class VideoUI implements PieRenderer.PieListener,
mShutterButton.setEnabled(true);
mMenuButton.setVisibility(View.VISIBLE);
mOnScreenIndicators.setVisibility(View.VISIBLE);
- Util.fadeOut(mReviewDoneButton);
- Util.fadeOut(mReviewPlayButton);
- Util.fadeIn(mShutterButton);
+ CameraUtil.fadeOut(mReviewDoneButton);
+ CameraUtil.fadeOut(mReviewPlayButton);
+ CameraUtil.fadeIn(mShutterButton);
}
private void setShowMenu(boolean show) {
diff --git a/src/com/android/camera/app/CameraApp.java b/src/com/android/camera/app/CameraApp.java
index a72581531..e4da41461 100644
--- a/src/com/android/camera/app/CameraApp.java
+++ b/src/com/android/camera/app/CameraApp.java
@@ -16,28 +16,15 @@
package com.android.camera.app;
-import com.android.camera.Util;
-import com.android.camera.util.PhotoSphereHelper;
-
import android.app.Application;
-import android.content.Context;
-public class CameraApp extends Application {
+import com.android.camera.util.CameraUtil;
- private StitchingProgressManager mStitchingProgressManager;
+public class CameraApp extends Application {
@Override
public void onCreate() {
super.onCreate();
- Util.initialize(this);
- mStitchingProgressManager = PhotoSphereHelper.createStitchingManagerInstance(this);
- }
-
- public Context getAndroidContext() {
- return this;
- }
-
- public StitchingProgressManager getStitchingProgressManager() {
- return mStitchingProgressManager;
+ CameraUtil.initialize(this);
}
}
diff --git a/src/com/android/camera/support/app/OrientationManager.java b/src/com/android/camera/app/OrientationManager.java
index 850d46591..412be3024 100644
--- a/src/com/android/camera/support/app/OrientationManager.java
+++ b/src/com/android/camera/app/OrientationManager.java
@@ -1,4 +1,4 @@
-package com.android.camera.support.app;
+package com.android.camera.app;
import android.app.Activity;
@@ -11,8 +11,7 @@ import android.util.Log;
import android.view.OrientationEventListener;
import android.view.Surface;
-import com.android.camera.support.ui.OrientationSource;
-import com.android.gallery3d.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
public class OrientationManager implements OrientationSource {
private static final String TAG = "OrientationManager";
diff --git a/src/com/android/camera/support/ui/OrientationSource.java b/src/com/android/camera/app/OrientationSource.java
index a2841eec4..57dcfeb40 100644
--- a/src/com/android/camera/support/ui/OrientationSource.java
+++ b/src/com/android/camera/app/OrientationSource.java
@@ -1,4 +1,4 @@
-package com.android.camera.support.ui;
+package com.android.camera.app;
public interface OrientationSource {
public int getDisplayRotation();
diff --git a/src/com/android/camera/data/LocalMediaData.java b/src/com/android/camera/data/LocalMediaData.java
index d80862cad..cd568239d 100644
--- a/src/com/android/camera/data/LocalMediaData.java
+++ b/src/com/android/camera/data/LocalMediaData.java
@@ -35,7 +35,7 @@ import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
-import com.android.camera.Util;
+import com.android.camera.util.CameraUtil;
import com.android.camera.ui.FilmStripView;
import com.android.camera.util.PhotoSphereHelper;
import com.android.camera2.R;
@@ -526,7 +526,7 @@ public abstract class LocalMediaData implements LocalData {
icon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- Util.playVideo(ctx, mPlayUri, title);
+ CameraUtil.playVideo(ctx, mPlayUri, title);
}
});
diff --git a/src/com/android/camera/support/app/StitchingChangeListener.java b/src/com/android/camera/support/app/StitchingChangeListener.java
deleted file mode 100644
index f67fb3963..000000000
--- a/src/com/android/camera/support/app/StitchingChangeListener.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.android.camera.support.app;
-
-import android.net.Uri;
-
-public interface StitchingChangeListener {
- public void onStitchingQueued(Uri uri);
-
- public void onStitchingResult(Uri uri);
-
- public void onStitchingProgress(Uri uri, int progress);
-}
diff --git a/src/com/android/camera/support/common/Utils.java b/src/com/android/camera/support/common/Utils.java
deleted file mode 100644
index f36d6adcd..000000000
--- a/src/com/android/camera/support/common/Utils.java
+++ /dev/null
@@ -1,325 +0,0 @@
-package com.android.camera.support.common;
-
-
-import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.database.Cursor;
-import android.os.Build;
-import android.os.ParcelFileDescriptor;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-
-public class Utils {
- private static final String TAG = "Utils";
- private static final String DEBUG_TAG = "GalleryDebug";
-
- private static final long POLY64REV = 0x95AC9329AC4BC9B5L;
- private static final long INITIALCRC = 0xFFFFFFFFFFFFFFFFL;
-
- private static long[] sCrcTable = new long[256];
-
- private static final boolean IS_DEBUG_BUILD =
- Build.TYPE.equals("eng") || Build.TYPE.equals("userdebug");
-
- private static final String MASK_STRING = "********************************";
-
- // Throws AssertionError if the input is false.
- public static void assertTrue(boolean cond) {
- if (!cond) {
- throw new AssertionError();
- }
- }
-
- // Throws AssertionError with the message. We had a method having the form
- // assertTrue(boolean cond, String message, Object ... args);
- // However a call to that method will cause memory allocation even if the
- // condition is false (due to autoboxing generated by "Object ... args"),
- // so we don't use that anymore.
- public static void fail(String message, Object ... args) {
- throw new AssertionError(
- args.length == 0 ? message : String.format(message, args));
- }
-
- // Throws NullPointerException if the input is null.
- public static <T> T checkNotNull(T object) {
- if (object == null) throw new NullPointerException();
- return object;
- }
-
- // Returns true if two input Object are both null or equal
- // to each other.
- public static boolean equals(Object a, Object b) {
- return (a == b) || (a == null ? false : a.equals(b));
- }
-
- // Returns the next power of two.
- // Returns the input if it is already power of 2.
- // Throws IllegalArgumentException if the input is <= 0 or
- // the answer overflows.
- public static int nextPowerOf2(int n) {
- if (n <= 0 || n > (1 << 30)) throw new IllegalArgumentException("n is invalid: " + n);
- n -= 1;
- n |= n >> 16;
- n |= n >> 8;
- n |= n >> 4;
- n |= n >> 2;
- n |= n >> 1;
- return n + 1;
- }
-
- // Returns the previous power of two.
- // Returns the input if it is already power of 2.
- // Throws IllegalArgumentException if the input is <= 0
- public static int prevPowerOf2(int n) {
- if (n <= 0) throw new IllegalArgumentException();
- return Integer.highestOneBit(n);
- }
-
- // Returns the input value x clamped to the range [min, max].
- public static int clamp(int x, int min, int max) {
- if (x > max) return max;
- if (x < min) return min;
- return x;
- }
-
- // Returns the input value x clamped to the range [min, max].
- public static float clamp(float x, float min, float max) {
- if (x > max) return max;
- if (x < min) return min;
- return x;
- }
-
- // Returns the input value x clamped to the range [min, max].
- public static long clamp(long x, long min, long max) {
- if (x > max) return max;
- if (x < min) return min;
- return x;
- }
-
- public static boolean isOpaque(int color) {
- return color >>> 24 == 0xFF;
- }
-
- public static void swap(int[] array, int i, int j) {
- int temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- }
-
- /**
- * A function thats returns a 64-bit crc for string
- *
- * @param in input string
- * @return a 64-bit crc value
- */
- public static final long crc64Long(String in) {
- if (in == null || in.length() == 0) {
- return 0;
- }
- return crc64Long(getBytes(in));
- }
-
- static {
- // http://bioinf.cs.ucl.ac.uk/downloads/crc64/crc64.c
- long part;
- for (int i = 0; i < 256; i++) {
- part = i;
- for (int j = 0; j < 8; j++) {
- long x = ((int) part & 1) != 0 ? POLY64REV : 0;
- part = (part >> 1) ^ x;
- }
- sCrcTable[i] = part;
- }
- }
-
- public static final long crc64Long(byte[] buffer) {
- long crc = INITIALCRC;
- for (int k = 0, n = buffer.length; k < n; ++k) {
- crc = sCrcTable[(((int) crc) ^ buffer[k]) & 0xff] ^ (crc >> 8);
- }
- return crc;
- }
-
- public static byte[] getBytes(String in) {
- byte[] result = new byte[in.length() * 2];
- int output = 0;
- for (char ch : in.toCharArray()) {
- result[output++] = (byte) (ch & 0xFF);
- result[output++] = (byte) (ch >> 8);
- }
- return result;
- }
-
- public static void closeSilently(Closeable c) {
- if (c == null) return;
- try {
- c.close();
- } catch (IOException t) {
- Log.w(TAG, "close fail ", t);
- }
- }
-
- public static int compare(long a, long b) {
- return a < b ? -1 : a == b ? 0 : 1;
- }
-
- public static int ceilLog2(float value) {
- int i;
- for (i = 0; i < 31; i++) {
- if ((1 << i) >= value) break;
- }
- return i;
- }
-
- public static int floorLog2(float value) {
- int i;
- for (i = 0; i < 31; i++) {
- if ((1 << i) > value) break;
- }
- return i - 1;
- }
-
- public static void closeSilently(ParcelFileDescriptor fd) {
- try {
- if (fd != null) fd.close();
- } catch (Throwable t) {
- Log.w(TAG, "fail to close", t);
- }
- }
-
- public static void closeSilently(Cursor cursor) {
- try {
- if (cursor != null) cursor.close();
- } catch (Throwable t) {
- Log.w(TAG, "fail to close", t);
- }
- }
-
- public static float interpolateAngle(
- float source, float target, float progress) {
- // interpolate the angle from source to target
- // We make the difference in the range of [-179, 180], this is the
- // shortest path to change source to target.
- float diff = target - source;
- if (diff < 0) diff += 360f;
- if (diff > 180) diff -= 360f;
-
- float result = source + diff * progress;
- return result < 0 ? result + 360f : result;
- }
-
- public static float interpolateScale(
- float source, float target, float progress) {
- return source + progress * (target - source);
- }
-
- public static String ensureNotNull(String value) {
- return value == null ? "" : value;
- }
-
- public static float parseFloatSafely(String content, float defaultValue) {
- if (content == null) return defaultValue;
- try {
- return Float.parseFloat(content);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
-
- public static int parseIntSafely(String content, int defaultValue) {
- if (content == null) return defaultValue;
- try {
- return Integer.parseInt(content);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
-
- public static boolean isNullOrEmpty(String exifMake) {
- return TextUtils.isEmpty(exifMake);
- }
-
- public static void waitWithoutInterrupt(Object object) {
- try {
- object.wait();
- } catch (InterruptedException e) {
- Log.w(TAG, "unexpected interrupt: " + object);
- }
- }
-
- public static boolean handleInterrruptedException(Throwable e) {
- // A helper to deal with the interrupt exception
- // If an interrupt detected, we will setup the bit again.
- if (e instanceof InterruptedIOException
- || e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- return true;
- }
- return false;
- }
-
- /**
- * @return String with special XML characters escaped.
- */
- public static String escapeXml(String s) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0, len = s.length(); i < len; ++i) {
- char c = s.charAt(i);
- switch (c) {
- case '<': sb.append("&lt;"); break;
- case '>': sb.append("&gt;"); break;
- case '\"': sb.append("&quot;"); break;
- case '\'': sb.append("&#039;"); break;
- case '&': sb.append("&amp;"); break;
- default: sb.append(c);
- }
- }
- return sb.toString();
- }
-
- public static String getUserAgent(Context context) {
- PackageInfo packageInfo;
- try {
- packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
- } catch (NameNotFoundException e) {
- throw new IllegalStateException("getPackageInfo failed");
- }
- return String.format("%s/%s; %s/%s/%s/%s; %s/%s/%s",
- packageInfo.packageName,
- packageInfo.versionName,
- Build.BRAND,
- Build.DEVICE,
- Build.MODEL,
- Build.ID,
- Build.VERSION.SDK_INT,
- Build.VERSION.RELEASE,
- Build.VERSION.INCREMENTAL);
- }
-
- public static String[] copyOf(String[] source, int newSize) {
- String[] result = new String[newSize];
- newSize = Math.min(source.length, newSize);
- System.arraycopy(source, 0, result, 0, newSize);
- return result;
- }
-
- // Mask information for debugging only. It returns <code>info.toString()</code> directly
- // for debugging build (i.e., 'eng' and 'userdebug') and returns a mask ("****")
- // in release build to protect the information (e.g. for privacy issue).
- public static String maskDebugInfo(Object info) {
- if (info == null) return null;
- String s = info.toString();
- int length = Math.min(s.length(), MASK_STRING.length());
- return IS_DEBUG_BUILD ? s : MASK_STRING.substring(0, length);
- }
-
- // This method should be ONLY used for debugging.
- public static void debug(String message, Object ... args) {
- Log.v(DEBUG_TAG, String.format(message, args));
- }
-} \ No newline at end of file
diff --git a/src/com/android/camera/support/filtershow/crop/CropExtras.java b/src/com/android/camera/support/filtershow/crop/CropExtras.java
deleted file mode 100644
index 6250a3573..000000000
--- a/src/com/android/camera/support/filtershow/crop/CropExtras.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package com.android.camera.support.filtershow.crop;
-
-
-import android.net.Uri;
-
-public class CropExtras {
-
- public static final String KEY_CROPPED_RECT = "cropped-rect";
- public static final String KEY_OUTPUT_X = "outputX";
- public static final String KEY_OUTPUT_Y = "outputY";
- public static final String KEY_SCALE = "scale";
- public static final String KEY_SCALE_UP_IF_NEEDED = "scaleUpIfNeeded";
- public static final String KEY_ASPECT_X = "aspectX";
- public static final String KEY_ASPECT_Y = "aspectY";
- public static final String KEY_SET_AS_WALLPAPER = "set-as-wallpaper";
- public static final String KEY_RETURN_DATA = "return-data";
- public static final String KEY_DATA = "data";
- public static final String KEY_SPOTLIGHT_X = "spotlightX";
- public static final String KEY_SPOTLIGHT_Y = "spotlightY";
- public static final String KEY_SHOW_WHEN_LOCKED = "showWhenLocked";
- public static final String KEY_OUTPUT_FORMAT = "outputFormat";
-
- private int mOutputX = 0;
- private int mOutputY = 0;
- private boolean mScaleUp = true;
- private int mAspectX = 0;
- private int mAspectY = 0;
- private boolean mSetAsWallpaper = false;
- private boolean mReturnData = false;
- private Uri mExtraOutput = null;
- private String mOutputFormat = null;
- private boolean mShowWhenLocked = false;
- private float mSpotlightX = 0;
- private float mSpotlightY = 0;
-
- public CropExtras(int outputX, int outputY, boolean scaleUp, int aspectX, int aspectY,
- boolean setAsWallpaper, boolean returnData, Uri extraOutput, String outputFormat,
- boolean showWhenLocked, float spotlightX, float spotlightY) {
- mOutputX = outputX;
- mOutputY = outputY;
- mScaleUp = scaleUp;
- mAspectX = aspectX;
- mAspectY = aspectY;
- mSetAsWallpaper = setAsWallpaper;
- mReturnData = returnData;
- mExtraOutput = extraOutput;
- mOutputFormat = outputFormat;
- mShowWhenLocked = showWhenLocked;
- mSpotlightX = spotlightX;
- mSpotlightY = spotlightY;
- }
-
- public CropExtras(CropExtras c) {
- this(c.mOutputX, c.mOutputY, c.mScaleUp, c.mAspectX, c.mAspectY, c.mSetAsWallpaper,
- c.mReturnData, c.mExtraOutput, c.mOutputFormat, c.mShowWhenLocked,
- c.mSpotlightX, c.mSpotlightY);
- }
-
- public int getOutputX() {
- return mOutputX;
- }
-
- public int getOutputY() {
- return mOutputY;
- }
-
- public boolean getScaleUp() {
- return mScaleUp;
- }
-
- public int getAspectX() {
- return mAspectX;
- }
-
- public int getAspectY() {
- return mAspectY;
- }
-
- public boolean getSetAsWallpaper() {
- return mSetAsWallpaper;
- }
-
- public boolean getReturnData() {
- return mReturnData;
- }
-
- public Uri getExtraOutput() {
- return mExtraOutput;
- }
-
- public String getOutputFormat() {
- return mOutputFormat;
- }
-
- public boolean getShowWhenLocked() {
- return mShowWhenLocked;
- }
-
- public float getSpotlightX() {
- return mSpotlightX;
- }
-
- public float getSpotlightY() {
- return mSpotlightY;
- }
-} \ No newline at end of file
diff --git a/src/com/android/camera/support/glrenderer/BasicTexture.java b/src/com/android/camera/support/glrenderer/BasicTexture.java
deleted file mode 100644
index 39cc519c2..000000000
--- a/src/com/android/camera/support/glrenderer/BasicTexture.java
+++ /dev/null
@@ -1,197 +0,0 @@
-package com.android.camera.support.glrenderer;
-
-
-import java.util.WeakHashMap;
-
-import com.android.camera.support.common.Utils;
-
-import android.util.Log;
-
-// BasicTexture is a Texture corresponds to a real GL texture.
-// The state of a BasicTexture indicates whether its data is loaded to GL memory.
-// If a BasicTexture is loaded into GL memory, it has a GL texture id.
-public abstract class BasicTexture implements Texture {
-
- @SuppressWarnings("unused")
- private static final String TAG = "BasicTexture";
- protected static final int UNSPECIFIED = -1;
-
- protected static final int STATE_UNLOADED = 0;
- protected static final int STATE_LOADED = 1;
- protected static final int STATE_ERROR = -1;
-
- // Log a warning if a texture is larger along a dimension
- private static final int MAX_TEXTURE_SIZE = 4096;
-
- protected int mId = -1;
- protected int mState;
-
- protected int mWidth = UNSPECIFIED;
- protected int mHeight = UNSPECIFIED;
-
- protected int mTextureWidth;
- protected int mTextureHeight;
-
- private boolean mHasBorder;
-
- protected GLCanvas mCanvasRef = null;
- private static WeakHashMap<BasicTexture, Object> sAllTextures
- = new WeakHashMap<BasicTexture, Object>();
- private static ThreadLocal sInFinalizer = new ThreadLocal();
-
- protected BasicTexture(GLCanvas canvas, int id, int state) {
- setAssociatedCanvas(canvas);
- mId = id;
- mState = state;
- synchronized (sAllTextures) {
- sAllTextures.put(this, null);
- }
- }
-
- protected BasicTexture() {
- this(null, 0, STATE_UNLOADED);
- }
-
- protected void setAssociatedCanvas(GLCanvas canvas) {
- mCanvasRef = canvas;
- }
-
- /**
- * Sets the content size of this texture. In OpenGL, the actual texture
- * size must be of power of 2, the size of the content may be smaller.
- */
- public void setSize(int width, int height) {
- mWidth = width;
- mHeight = height;
- mTextureWidth = width > 0 ? Utils.nextPowerOf2(width) : 0;
- mTextureHeight = height > 0 ? Utils.nextPowerOf2(height) : 0;
- if (mTextureWidth > MAX_TEXTURE_SIZE || mTextureHeight > MAX_TEXTURE_SIZE) {
- Log.w(TAG, String.format("texture is too large: %d x %d",
- mTextureWidth, mTextureHeight), new Exception());
- }
- }
-
- public boolean isFlippedVertically() {
- return false;
- }
-
- public int getId() {
- return mId;
- }
-
- @Override
- public int getWidth() {
- return mWidth;
- }
-
- @Override
- public int getHeight() {
- return mHeight;
- }
-
- // Returns the width rounded to the next power of 2.
- public int getTextureWidth() {
- return mTextureWidth;
- }
-
- // Returns the height rounded to the next power of 2.
- public int getTextureHeight() {
- return mTextureHeight;
- }
-
- // Returns true if the texture has one pixel transparent border around the
- // actual content. This is used to avoid jigged edges.
- //
- // The jigged edges appear because we use GL_CLAMP_TO_EDGE for texture wrap
- // mode (GL_CLAMP is not available in OpenGL ES), so a pixel partially
- // covered by the texture will use the color of the edge texel. If we add
- // the transparent border, the color of the edge texel will be mixed with
- // appropriate amount of transparent.
- //
- // Currently our background is black, so we can draw the thumbnails without
- // enabling blending.
- public boolean hasBorder() {
- return mHasBorder;
- }
-
- protected void setBorder(boolean hasBorder) {
- mHasBorder = hasBorder;
- }
-
- @Override
- public void draw(GLCanvas canvas, int x, int y) {
- canvas.drawTexture(this, x, y, getWidth(), getHeight());
- }
-
- @Override
- public void draw(GLCanvas canvas, int x, int y, int w, int h) {
- canvas.drawTexture(this, x, y, w, h);
- }
-
- // onBind is called before GLCanvas binds this texture.
- // It should make sure the data is uploaded to GL memory.
- abstract protected boolean onBind(GLCanvas canvas);
-
- // Returns the GL texture target for this texture (e.g. GL_TEXTURE_2D).
- abstract protected int getTarget();
-
- public boolean isLoaded() {
- return mState == STATE_LOADED;
- }
-
- // recycle() is called when the texture will never be used again,
- // so it can free all resources.
- public void recycle() {
- freeResource();
- }
-
- // yield() is called when the texture will not be used temporarily,
- // so it can free some resources.
- // The default implementation unloads the texture from GL memory, so
- // the subclass should make sure it can reload the texture to GL memory
- // later, or it will have to override this method.
- public void yield() {
- freeResource();
- }
-
- private void freeResource() {
- GLCanvas canvas = mCanvasRef;
- if (canvas != null && mId != -1) {
- canvas.unloadTexture(this);
- mId = -1; // Don't free it again.
- }
- mState = STATE_UNLOADED;
- setAssociatedCanvas(null);
- }
-
- @Override
- protected void finalize() {
- sInFinalizer.set(BasicTexture.class);
- recycle();
- sInFinalizer.set(null);
- }
-
- // This is for deciding if we can call Bitmap's recycle().
- // We cannot call Bitmap's recycle() in finalizer because at that point
- // the finalizer of Bitmap may already be called so recycle() will crash.
- public static boolean inFinalizer() {
- return sInFinalizer.get() != null;
- }
-
- public static void yieldAllTextures() {
- synchronized (sAllTextures) {
- for (BasicTexture t : sAllTextures.keySet()) {
- t.yield();
- }
- }
- }
-
- public static void invalidateAllTextures() {
- synchronized (sAllTextures) {
- for (BasicTexture t : sAllTextures.keySet()) {
- t.mState = STATE_UNLOADED;
- t.setAssociatedCanvas(null);
- }
- }
- }
-}
diff --git a/src/com/android/camera/support/glrenderer/BitmapTexture.java b/src/com/android/camera/support/glrenderer/BitmapTexture.java
deleted file mode 100644
index b62a44436..000000000
--- a/src/com/android/camera/support/glrenderer/BitmapTexture.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.android.camera.support.glrenderer;
-
-import android.graphics.Bitmap;
-
-import junit.framework.Assert;
-
-// BitmapTexture is a texture whose content is specified by a fixed Bitmap.
-//
-// The texture does not own the Bitmap. The user should make sure the Bitmap
-// is valid during the texture's lifetime. When the texture is recycled, it
-// does not free the Bitmap.
-public class BitmapTexture extends UploadedTexture {
- protected Bitmap mContentBitmap;
-
- public BitmapTexture(Bitmap bitmap) {
- this(bitmap, false);
- }
-
- public BitmapTexture(Bitmap bitmap, boolean hasBorder) {
- super(hasBorder);
- Assert.assertTrue(bitmap != null && !bitmap.isRecycled());
- mContentBitmap = bitmap;
- }
-
- @Override
- protected void onFreeBitmap(Bitmap bitmap) {
- // Do nothing.
- }
-
- @Override
- protected Bitmap onGetBitmap() {
- return mContentBitmap;
- }
-
- public Bitmap getBitmap() {
- return mContentBitmap;
- }
-}
diff --git a/src/com/android/camera/support/glrenderer/ExtTexture.java b/src/com/android/camera/support/glrenderer/ExtTexture.java
deleted file mode 100644
index 121e17d5f..000000000
--- a/src/com/android/camera/support/glrenderer/ExtTexture.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.android.camera.support.glrenderer;
-
-
-//ExtTexture is a texture whose content comes from a external texture.
-//Before drawing, setSize() should be called.
-public class ExtTexture extends BasicTexture {
-
- private int mTarget;
-
- public ExtTexture(GLCanvas canvas, int target) {
- GLId glId = canvas.getGLId();
- mId = glId.generateTexture();
- mTarget = target;
- }
-
- private void uploadToCanvas(GLCanvas canvas) {
- canvas.setTextureParameters(this);
- setAssociatedCanvas(canvas);
- mState = STATE_LOADED;
- }
-
- @Override
- protected boolean onBind(GLCanvas canvas) {
- if (!isLoaded()) {
- uploadToCanvas(canvas);
- }
-
- return true;
- }
-
- @Override
- public int getTarget() {
- return mTarget;
- }
-
- @Override
- public boolean isOpaque() {
- return true;
- }
-
- @Override
- public void yield() {
- // we cannot free the texture because we have no backup.
- }
-}
diff --git a/src/com/android/camera/support/glrenderer/GLCanvas.java b/src/com/android/camera/support/glrenderer/GLCanvas.java
deleted file mode 100644
index 1e4ec2f16..000000000
--- a/src/com/android/camera/support/glrenderer/GLCanvas.java
+++ /dev/null
@@ -1,201 +0,0 @@
-package com.android.camera.support.glrenderer;
-
-import android.graphics.Bitmap;
-import android.graphics.Rect;
-import android.graphics.RectF;
-
-import javax.microedition.khronos.opengles.GL11;
-
-//
-// GLCanvas gives a convenient interface to draw using OpenGL.
-//
-// When a rectangle is specified in this interface, it means the region
-// [x, x+width) * [y, y+height)
-//
-public interface GLCanvas {
-
- public GLId getGLId();
-
- // Tells GLCanvas the size of the underlying GL surface. This should be
- // called before first drawing and when the size of GL surface is changed.
- // This is called by GLRoot and should not be called by the clients
- // who only want to draw on the GLCanvas. Both width and height must be
- // nonnegative.
- public abstract void setSize(int width, int height);
-
- // Clear the drawing buffers. This should only be used by GLRoot.
- public abstract void clearBuffer();
-
- public abstract void clearBuffer(float[] argb);
-
- // Sets and gets the current alpha, alpha must be in [0, 1].
- public abstract void setAlpha(float alpha);
-
- public abstract float getAlpha();
-
- // (current alpha) = (current alpha) * alpha
- public abstract void multiplyAlpha(float alpha);
-
- // Change the current transform matrix.
- public abstract void translate(float x, float y, float z);
-
- public abstract void translate(float x, float y);
-
- public abstract void scale(float sx, float sy, float sz);
-
- public abstract void rotate(float angle, float x, float y, float z);
-
- public abstract void multiplyMatrix(float[] mMatrix, int offset);
-
- // Pushes the configuration state (matrix, and alpha) onto
- // a private stack.
- public abstract void save();
-
- // Same as save(), but only save those specified in saveFlags.
- public abstract void save(int saveFlags);
-
- public static final int SAVE_FLAG_ALL = 0xFFFFFFFF;
- public static final int SAVE_FLAG_ALPHA = 0x01;
- public static final int SAVE_FLAG_MATRIX = 0x02;
-
- // Pops from the top of the stack as current configuration state (matrix,
- // alpha, and clip). This call balances a previous call to save(), and is
- // used to remove all modifications to the configuration state since the
- // last save call.
- public abstract void restore();
-
- // Draws a line using the specified paint from (x1, y1) to (x2, y2).
- // (Both end points are included).
- public abstract void drawLine(float x1, float y1, float x2, float y2, GLPaint paint);
-
- // Draws a rectangle using the specified paint from (x1, y1) to (x2, y2).
- // (Both end points are included).
- public abstract void drawRect(float x1, float y1, float x2, float y2, GLPaint paint);
-
- // Fills the specified rectangle with the specified color.
- public abstract void fillRect(float x, float y, float width, float height, int color);
-
- // Draws a texture to the specified rectangle.
- public abstract void drawTexture(
- BasicTexture texture, int x, int y, int width, int height);
-
- public abstract void drawMesh(BasicTexture tex, int x, int y, int xyBuffer,
- int uvBuffer, int indexBuffer, int indexCount);
-
- // Draws the source rectangle part of the texture to the target rectangle.
- public abstract void drawTexture(BasicTexture texture, RectF source, RectF target);
-
- // Draw a texture with a specified texture transform.
- public abstract void drawTexture(BasicTexture texture, float[] mTextureTransform,
- int x, int y, int w, int h);
-
- // Draw two textures to the specified rectangle. The actual texture used is
- // from * (1 - ratio) + to * ratio
- // The two textures must have the same size.
- public abstract void drawMixed(BasicTexture from, int toColor,
- float ratio, int x, int y, int w, int h);
-
- // Draw a region of a texture and a specified color to the specified
- // rectangle. The actual color used is from * (1 - ratio) + to * ratio.
- // The region of the texture is defined by parameter "src". The target
- // rectangle is specified by parameter "target".
- public abstract void drawMixed(BasicTexture from, int toColor,
- float ratio, RectF src, RectF target);
-
- // Unloads the specified texture from the canvas. The resource allocated
- // to draw the texture will be released. The specified texture will return
- // to the unloaded state. This function should be called only from
- // BasicTexture or its descendant
- public abstract boolean unloadTexture(BasicTexture texture);
-
- // Delete the specified buffer object, similar to unloadTexture.
- public abstract void deleteBuffer(int bufferId);
-
- // Delete the textures and buffers in GL side. This function should only be
- // called in the GL thread.
- public abstract void deleteRecycledResources();
-
- // Dump statistics information and clear the counters. For debug only.
- public abstract void dumpStatisticsAndClear();
-
- public abstract void beginRenderTarget(RawTexture texture);
-
- public abstract void endRenderTarget();
-
- /**
- * Sets texture parameters to use GL_CLAMP_TO_EDGE for both
- * GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T. Sets texture parameters to be
- * GL_LINEAR for GL_TEXTURE_MIN_FILTER and GL_TEXTURE_MAG_FILTER.
- * bindTexture() must be called prior to this.
- *
- * @param texture The texture to set parameters on.
- */
- public abstract void setTextureParameters(BasicTexture texture);
-
- /**
- * Initializes the texture to a size by calling texImage2D on it.
- *
- * @param texture The texture to initialize the size.
- * @param format The texture format (e.g. GL_RGBA)
- * @param type The texture type (e.g. GL_UNSIGNED_BYTE)
- */
- public abstract void initializeTextureSize(BasicTexture texture, int format, int type);
-
- /**
- * Initializes the texture to a size by calling texImage2D on it.
- *
- * @param texture The texture to initialize the size.
- * @param bitmap The bitmap to initialize the bitmap with.
- */
- public abstract void initializeTexture(BasicTexture texture, Bitmap bitmap);
-
- /**
- * Calls glTexSubImage2D to upload a bitmap to the texture.
- *
- * @param texture The target texture to write to.
- * @param xOffset Specifies a texel offset in the x direction within the
- * texture array.
- * @param yOffset Specifies a texel offset in the y direction within the
- * texture array.
- * @param format The texture format (e.g. GL_RGBA)
- * @param type The texture type (e.g. GL_UNSIGNED_BYTE)
- */
- public abstract void texSubImage2D(BasicTexture texture, int xOffset, int yOffset,
- Bitmap bitmap,
- int format, int type);
-
- /**
- * Generates buffers and uploads the buffer data.
- *
- * @param buffer The buffer to upload
- * @return The buffer ID that was generated.
- */
- public abstract int uploadBuffer(java.nio.FloatBuffer buffer);
-
- /**
- * Generates buffers and uploads the element array buffer data.
- *
- * @param buffer The buffer to upload
- * @return The buffer ID that was generated.
- */
- public abstract int uploadBuffer(java.nio.ByteBuffer buffer);
-
- /**
- * After LightCycle makes GL calls, this method is called to restore the GL
- * configuration to the one expected by GLCanvas.
- */
- public abstract void recoverFromLightCycle();
-
- /**
- * Gets the bounds given by x, y, width, and height as well as the internal
- * matrix state. There is no special handling for non-90-degree rotations.
- * It only considers the lower-left and upper-right corners as the bounds.
- *
- * @param bounds The output bounds to write to.
- * @param x The left side of the input rectangle.
- * @param y The bottom of the input rectangle.
- * @param width The width of the input rectangle.
- * @param height The height of the input rectangle.
- */
- public abstract void getBounds(Rect bounds, int x, int y, int width, int height);
-} \ No newline at end of file
diff --git a/src/com/android/camera/support/glrenderer/GLId.java b/src/com/android/camera/support/glrenderer/GLId.java
deleted file mode 100644
index 695343b12..000000000
--- a/src/com/android/camera/support/glrenderer/GLId.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.android.camera.support.glrenderer;
-
-import javax.microedition.khronos.opengles.GL11;
-import javax.microedition.khronos.opengles.GL11ExtensionPack;
-
-// This mimics corresponding GL functions.
-public interface GLId {
- public int generateTexture();
-
- public void glGenBuffers(int n, int[] buffers, int offset);
-
- public void glDeleteTextures(GL11 gl, int n, int[] textures, int offset);
-
- public void glDeleteBuffers(GL11 gl, int n, int[] buffers, int offset);
-
- public void glDeleteFramebuffers(GL11ExtensionPack gl11ep, int n, int[] buffers, int offset);
-}
diff --git a/src/com/android/camera/support/glrenderer/GLPaint.java b/src/com/android/camera/support/glrenderer/GLPaint.java
deleted file mode 100644
index 7c6af73eb..000000000
--- a/src/com/android/camera/support/glrenderer/GLPaint.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.android.camera.support.glrenderer;
-
-
-import junit.framework.Assert;
-
-public class GLPaint {
- private float mLineWidth = 1f;
- private int mColor = 0;
-
- public void setColor(int color) {
- mColor = color;
- }
-
- public int getColor() {
- return mColor;
- }
-
- public void setLineWidth(float width) {
- Assert.assertTrue(width >= 0);
- mLineWidth = width;
- }
-
- public float getLineWidth() {
- return mLineWidth;
- }
-}
diff --git a/src/com/android/camera/support/glrenderer/NinePatchChunk.java b/src/com/android/camera/support/glrenderer/NinePatchChunk.java
deleted file mode 100644
index f7deb1864..000000000
--- a/src/com/android/camera/support/glrenderer/NinePatchChunk.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.android.camera.support.glrenderer;
-
-import android.graphics.Rect;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-// See "frameworks/base/include/utils/ResourceTypes.h" for the format of
-// NinePatch chunk.
-class NinePatchChunk {
-
- public static final int NO_COLOR = 0x00000001;
- public static final int TRANSPARENT_COLOR = 0x00000000;
-
- public Rect mPaddings = new Rect();
-
- public int mDivX[];
- public int mDivY[];
- public int mColor[];
-
- private static void readIntArray(int[] data, ByteBuffer buffer) {
- for (int i = 0, n = data.length; i < n; ++i) {
- data[i] = buffer.getInt();
- }
- }
-
- private static void checkDivCount(int length) {
- if (length == 0 || (length & 0x01) != 0) {
- throw new RuntimeException("invalid nine-patch: " + length);
- }
- }
-
- public static NinePatchChunk deserialize(byte[] data) {
- ByteBuffer byteBuffer =
- ByteBuffer.wrap(data).order(ByteOrder.nativeOrder());
-
- byte wasSerialized = byteBuffer.get();
- if (wasSerialized == 0) return null;
-
- NinePatchChunk chunk = new NinePatchChunk();
- chunk.mDivX = new int[byteBuffer.get()];
- chunk.mDivY = new int[byteBuffer.get()];
- chunk.mColor = new int[byteBuffer.get()];
-
- checkDivCount(chunk.mDivX.length);
- checkDivCount(chunk.mDivY.length);
-
- // skip 8 bytes
- byteBuffer.getInt();
- byteBuffer.getInt();
-
- chunk.mPaddings.left = byteBuffer.getInt();
- chunk.mPaddings.right = byteBuffer.getInt();
- chunk.mPaddings.top = byteBuffer.getInt();
- chunk.mPaddings.bottom = byteBuffer.getInt();
-
- // skip 4 bytes
- byteBuffer.getInt();
-
- readIntArray(chunk.mDivX, byteBuffer);
- readIntArray(chunk.mDivY, byteBuffer);
- readIntArray(chunk.mColor, byteBuffer);
-
- return chunk;
- }
-} \ No newline at end of file
diff --git a/src/com/android/camera/support/glrenderer/NinePatchTexture.java b/src/com/android/camera/support/glrenderer/NinePatchTexture.java
deleted file mode 100644
index c69afd682..000000000
--- a/src/com/android/camera/support/glrenderer/NinePatchTexture.java
+++ /dev/null
@@ -1,408 +0,0 @@
-package com.android.camera.support.glrenderer;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.FloatBuffer;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Rect;
-
-import com.android.camera.support.common.Utils;
-
-// NinePatchTexture is a texture backed by a NinePatch resource.
-//
-// getPaddings() returns paddings specified in the NinePatch.
-// getNinePatchChunk() returns the layout data specified in the NinePatch.
-//
-public class NinePatchTexture extends ResourceTexture {
- @SuppressWarnings("unused")
- private static final String TAG = "NinePatchTexture";
- private NinePatchChunk mChunk;
- private SmallCache<NinePatchInstance> mInstanceCache
- = new SmallCache<NinePatchInstance>();
-
- public NinePatchTexture(Context context, int resId) {
- super(context, resId);
- }
-
- @Override
- protected Bitmap onGetBitmap() {
- if (mBitmap != null) return mBitmap;
-
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- Bitmap bitmap = BitmapFactory.decodeResource(
- mContext.getResources(), mResId, options);
- mBitmap = bitmap;
- setSize(bitmap.getWidth(), bitmap.getHeight());
- byte[] chunkData = bitmap.getNinePatchChunk();
- mChunk = chunkData == null
- ? null
- : NinePatchChunk.deserialize(bitmap.getNinePatchChunk());
- if (mChunk == null) {
- throw new RuntimeException("invalid nine-patch image: " + mResId);
- }
- return bitmap;
- }
-
- public Rect getPaddings() {
- // get the paddings from nine patch
- if (mChunk == null) onGetBitmap();
- return mChunk.mPaddings;
- }
-
- public NinePatchChunk getNinePatchChunk() {
- if (mChunk == null) onGetBitmap();
- return mChunk;
- }
-
- // This is a simple cache for a small number of things. Linear search
- // is used because the cache is small. It also tries to remove less used
- // item when the cache is full by moving the often-used items to the front.
- private static class SmallCache<V> {
- private static final int CACHE_SIZE = 16;
- private static final int CACHE_SIZE_START_MOVE = CACHE_SIZE / 2;
- private int[] mKey = new int[CACHE_SIZE];
- private V[] mValue = (V[]) new Object[CACHE_SIZE];
- private int mCount; // number of items in this cache
-
- // Puts a value into the cache. If the cache is full, also returns
- // a less used item, otherwise returns null.
- public V put(int key, V value) {
- if (mCount == CACHE_SIZE) {
- V old = mValue[CACHE_SIZE - 1]; // remove the last item
- mKey[CACHE_SIZE - 1] = key;
- mValue[CACHE_SIZE - 1] = value;
- return old;
- } else {
- mKey[mCount] = key;
- mValue[mCount] = value;
- mCount++;
- return null;
- }
- }
-
- public V get(int key) {
- for (int i = 0; i < mCount; i++) {
- if (mKey[i] == key) {
- // Move the accessed item one position to the front, so it
- // will less likely to be removed when cache is full. Only
- // do this if the cache is starting to get full.
- if (mCount > CACHE_SIZE_START_MOVE && i > 0) {
- int tmpKey = mKey[i];
- mKey[i] = mKey[i - 1];
- mKey[i - 1] = tmpKey;
-
- V tmpValue = mValue[i];
- mValue[i] = mValue[i - 1];
- mValue[i - 1] = tmpValue;
- }
- return mValue[i];
- }
- }
- return null;
- }
-
- public void clear() {
- for (int i = 0; i < mCount; i++) {
- mValue[i] = null; // make sure it's can be garbage-collected.
- }
- mCount = 0;
- }
-
- public int size() {
- return mCount;
- }
-
- public V valueAt(int i) {
- return mValue[i];
- }
- }
-
- private NinePatchInstance findInstance(GLCanvas canvas, int w, int h) {
- int key = w;
- key = (key << 16) | h;
- NinePatchInstance instance = mInstanceCache.get(key);
-
- if (instance == null) {
- instance = new NinePatchInstance(this, w, h);
- NinePatchInstance removed = mInstanceCache.put(key, instance);
- if (removed != null) {
- removed.recycle(canvas);
- }
- }
-
- return instance;
- }
-
- @Override
- public void draw(GLCanvas canvas, int x, int y, int w, int h) {
- if (!isLoaded()) {
- mInstanceCache.clear();
- }
-
- if (w != 0 && h != 0) {
- findInstance(canvas, w, h).draw(canvas, this, x, y);
- }
- }
-
- @Override
- public void recycle() {
- super.recycle();
- GLCanvas canvas = mCanvasRef;
- if (canvas == null) return;
- int n = mInstanceCache.size();
- for (int i = 0; i < n; i++) {
- NinePatchInstance instance = mInstanceCache.valueAt(i);
- instance.recycle(canvas);
- }
- mInstanceCache.clear();
- }
-}
-
-// This keeps data for a specialization of NinePatchTexture with the size
-// (width, height). We pre-compute the coordinates for efficiency.
-class NinePatchInstance {
-
- @SuppressWarnings("unused")
- private static final String TAG = "NinePatchInstance";
-
- // We need 16 vertices for a normal nine-patch image (the 4x4 vertices)
- private static final int VERTEX_BUFFER_SIZE = 16 * 2;
-
- // We need 22 indices for a normal nine-patch image, plus 2 for each
- // transparent region. Current there are at most 1 transparent region.
- private static final int INDEX_BUFFER_SIZE = 22 + 2;
-
- private FloatBuffer mXyBuffer;
- private FloatBuffer mUvBuffer;
- private ByteBuffer mIndexBuffer;
-
- // Names for buffer names: xy, uv, index.
- private int mXyBufferName = -1;
- private int mUvBufferName;
- private int mIndexBufferName;
-
- private int mIdxCount;
-
- public NinePatchInstance(NinePatchTexture tex, int width, int height) {
- NinePatchChunk chunk = tex.getNinePatchChunk();
-
- if (width <= 0 || height <= 0) {
- throw new RuntimeException("invalid dimension");
- }
-
- // The code should be easily extended to handle the general cases by
- // allocating more space for buffers. But let's just handle the only
- // use case.
- if (chunk.mDivX.length != 2 || chunk.mDivY.length != 2) {
- throw new RuntimeException("unsupported nine patch");
- }
-
- float divX[] = new float[4];
- float divY[] = new float[4];
- float divU[] = new float[4];
- float divV[] = new float[4];
-
- int nx = stretch(divX, divU, chunk.mDivX, tex.getWidth(), width);
- int ny = stretch(divY, divV, chunk.mDivY, tex.getHeight(), height);
-
- prepareVertexData(divX, divY, divU, divV, nx, ny, chunk.mColor);
- }
-
- /**
- * Stretches the texture according to the nine-patch rules. It will
- * linearly distribute the strechy parts defined in the nine-patch chunk to
- * the target area.
- *
- * <pre>
- * source
- * /--------------^---------------\
- * u0 u1 u2 u3 u4 u5
- * div ---> |fffff|ssssssss|fff|ssssss|ffff| ---> u
- * | div0 div1 div2 div3 |
- * | | / / / /
- * | | / / / /
- * | | / / / /
- * |fffff|ssss|fff|sss|ffff| ---> x
- * x0 x1 x2 x3 x4 x5
- * \----------v------------/
- * target
- *
- * f: fixed segment
- * s: stretchy segment
- * </pre>
- *
- * @param div the stretch parts defined in nine-patch chunk
- * @param source the length of the texture
- * @param target the length on the drawing plan
- * @param u output, the positions of these dividers in the texture
- * coordinate
- * @param x output, the corresponding position of these dividers on the
- * drawing plan
- * @return the number of these dividers.
- */
- private static int stretch(
- float x[], float u[], int div[], int source, int target) {
- int textureSize = Utils.nextPowerOf2(source);
- float textureBound = (float) source / textureSize;
-
- float stretch = 0;
- for (int i = 0, n = div.length; i < n; i += 2) {
- stretch += div[i + 1] - div[i];
- }
-
- float remaining = target - source + stretch;
-
- float lastX = 0;
- float lastU = 0;
-
- x[0] = 0;
- u[0] = 0;
- for (int i = 0, n = div.length; i < n; i += 2) {
- // Make the stretchy segment a little smaller to prevent sampling
- // on neighboring fixed segments.
- // fixed segment
- x[i + 1] = lastX + (div[i] - lastU) + 0.5f;
- u[i + 1] = Math.min((div[i] + 0.5f) / textureSize, textureBound);
-
- // stretchy segment
- float partU = div[i + 1] - div[i];
- float partX = remaining * partU / stretch;
- remaining -= partX;
- stretch -= partU;
-
- lastX = x[i + 1] + partX;
- lastU = div[i + 1];
- x[i + 2] = lastX - 0.5f;
- u[i + 2] = Math.min((lastU - 0.5f)/ textureSize, textureBound);
- }
- // the last fixed segment
- x[div.length + 1] = target;
- u[div.length + 1] = textureBound;
-
- // remove segments with length 0.
- int last = 0;
- for (int i = 1, n = div.length + 2; i < n; ++i) {
- if ((x[i] - x[last]) < 1f) continue;
- x[++last] = x[i];
- u[last] = u[i];
- }
- return last + 1;
- }
-
- private void prepareVertexData(float x[], float y[], float u[], float v[],
- int nx, int ny, int[] color) {
- /*
- * Given a 3x3 nine-patch image, the vertex order is defined as the
- * following graph:
- *
- * (0) (1) (2) (3)
- * | /| /| /|
- * | / | / | / |
- * (4) (5) (6) (7)
- * | \ | \ | \ |
- * | \| \| \|
- * (8) (9) (A) (B)
- * | /| /| /|
- * | / | / | / |
- * (C) (D) (E) (F)
- *
- * And we draw the triangle strip in the following index order:
- *
- * index: 04152637B6A5948C9DAEBF
- */
- int pntCount = 0;
- float xy[] = new float[VERTEX_BUFFER_SIZE];
- float uv[] = new float[VERTEX_BUFFER_SIZE];
- for (int j = 0; j < ny; ++j) {
- for (int i = 0; i < nx; ++i) {
- int xIndex = (pntCount++) << 1;
- int yIndex = xIndex + 1;
- xy[xIndex] = x[i];
- xy[yIndex] = y[j];
- uv[xIndex] = u[i];
- uv[yIndex] = v[j];
- }
- }
-
- int idxCount = 1;
- boolean isForward = false;
- byte index[] = new byte[INDEX_BUFFER_SIZE];
- for (int row = 0; row < ny - 1; row++) {
- --idxCount;
- isForward = !isForward;
-
- int start, end, inc;
- if (isForward) {
- start = 0;
- end = nx;
- inc = 1;
- } else {
- start = nx - 1;
- end = -1;
- inc = -1;
- }
-
- for (int col = start; col != end; col += inc) {
- int k = row * nx + col;
- if (col != start) {
- int colorIdx = row * (nx - 1) + col;
- if (isForward) colorIdx--;
- if (color[colorIdx] == NinePatchChunk.TRANSPARENT_COLOR) {
- index[idxCount] = index[idxCount - 1];
- ++idxCount;
- index[idxCount++] = (byte) k;
- }
- }
-
- index[idxCount++] = (byte) k;
- index[idxCount++] = (byte) (k + nx);
- }
- }
-
- mIdxCount = idxCount;
-
- int size = (pntCount * 2) * (Float.SIZE / Byte.SIZE);
- mXyBuffer = allocateDirectNativeOrderBuffer(size).asFloatBuffer();
- mUvBuffer = allocateDirectNativeOrderBuffer(size).asFloatBuffer();
- mIndexBuffer = allocateDirectNativeOrderBuffer(mIdxCount);
-
- mXyBuffer.put(xy, 0, pntCount * 2).position(0);
- mUvBuffer.put(uv, 0, pntCount * 2).position(0);
- mIndexBuffer.put(index, 0, idxCount).position(0);
- }
-
- private static ByteBuffer allocateDirectNativeOrderBuffer(int size) {
- return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
- }
-
- private void prepareBuffers(GLCanvas canvas) {
- mXyBufferName = canvas.uploadBuffer(mXyBuffer);
- mUvBufferName = canvas.uploadBuffer(mUvBuffer);
- mIndexBufferName = canvas.uploadBuffer(mIndexBuffer);
-
- // These buffers are never used again.
- mXyBuffer = null;
- mUvBuffer = null;
- mIndexBuffer = null;
- }
-
- public void draw(GLCanvas canvas, NinePatchTexture tex, int x, int y) {
- if (mXyBufferName == -1) {
- prepareBuffers(canvas);
- }
- canvas.drawMesh(tex, x, y, mXyBufferName, mUvBufferName, mIndexBufferName, mIdxCount);
- }
-
- public void recycle(GLCanvas canvas) {
- if (mXyBuffer == null) {
- canvas.deleteBuffer(mXyBufferName);
- canvas.deleteBuffer(mUvBufferName);
- canvas.deleteBuffer(mIndexBufferName);
- mXyBufferName = -1;
- }
- }
-} \ No newline at end of file
diff --git a/src/com/android/camera/support/glrenderer/RawTexture.java b/src/com/android/camera/support/glrenderer/RawTexture.java
deleted file mode 100644
index b86282d0e..000000000
--- a/src/com/android/camera/support/glrenderer/RawTexture.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.android.camera.support.glrenderer;
-
-
-import android.util.Log;
-
-import javax.microedition.khronos.opengles.GL11;
-
-public class RawTexture extends BasicTexture {
- private static final String TAG = "RawTexture";
-
- private final boolean mOpaque;
- private boolean mIsFlipped;
-
- public RawTexture(int width, int height, boolean opaque) {
- mOpaque = opaque;
- setSize(width, height);
- }
-
- @Override
- public boolean isOpaque() {
- return mOpaque;
- }
-
- @Override
- public boolean isFlippedVertically() {
- return mIsFlipped;
- }
-
- public void setIsFlippedVertically(boolean isFlipped) {
- mIsFlipped = isFlipped;
- }
-
- protected void prepare(GLCanvas canvas) {
- GLId glId = canvas.getGLId();
- mId = glId.generateTexture();
- canvas.initializeTextureSize(this, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE);
- canvas.setTextureParameters(this);
- mState = STATE_LOADED;
- setAssociatedCanvas(canvas);
- }
-
- @Override
- protected boolean onBind(GLCanvas canvas) {
- if (isLoaded()) return true;
- Log.w(TAG, "lost the content due to context change");
- return false;
- }
-
- @Override
- public void yield() {
- // we cannot free the texture because we have no backup.
- }
-
- @Override
- protected int getTarget() {
- return GL11.GL_TEXTURE_2D;
- }
-}
diff --git a/src/com/android/camera/support/glrenderer/ResourceTexture.java b/src/com/android/camera/support/glrenderer/ResourceTexture.java
deleted file mode 100644
index 121c184cd..000000000
--- a/src/com/android/camera/support/glrenderer/ResourceTexture.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.android.camera.support.glrenderer;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-
-import junit.framework.Assert;
-
-// ResourceTexture is a texture whose Bitmap is decoded from a resource.
-// By default ResourceTexture is not opaque.
-public class ResourceTexture extends UploadedTexture {
-
- protected final Context mContext;
- protected final int mResId;
-
- public ResourceTexture(Context context, int resId) {
- Assert.assertNotNull(context);
- mContext = context;
- mResId = resId;
- setOpaque(false);
- }
-
- @Override
- protected Bitmap onGetBitmap() {
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- return BitmapFactory.decodeResource(
- mContext.getResources(), mResId, options);
- }
-
- @Override
- protected void onFreeBitmap(Bitmap bitmap) {
- if (!inFinalizer()) {
- bitmap.recycle();
- }
- }
-}
diff --git a/src/com/android/camera/support/glrenderer/Texture.java b/src/com/android/camera/support/glrenderer/Texture.java
deleted file mode 100644
index 4d1a49d2b..000000000
--- a/src/com/android/camera/support/glrenderer/Texture.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.android.camera.support.glrenderer;
-
-//Texture is a rectangular image which can be drawn on GLCanvas.
-//The isOpaque() function gives a hint about whether the texture is opaque,
-//so the drawing can be done faster.
-//
-//This is the current texture hierarchy:
-//
-//Texture
-//-- ColorTexture
-//-- FadeInTexture
-//-- BasicTexture
-// -- UploadedTexture
-// -- BitmapTexture
-// -- Tile
-// -- ResourceTexture
-// -- NinePatchTexture
-// -- CanvasTexture
-// -- StringTexture
-//
-public interface Texture {
- public int getWidth();
- public int getHeight();
- public void draw(GLCanvas canvas, int x, int y);
- public void draw(GLCanvas canvas, int x, int y, int w, int h);
- public boolean isOpaque();
-}
diff --git a/src/com/android/camera/support/glrenderer/UploadedTexture.java b/src/com/android/camera/support/glrenderer/UploadedTexture.java
deleted file mode 100644
index 106aa4ef3..000000000
--- a/src/com/android/camera/support/glrenderer/UploadedTexture.java
+++ /dev/null
@@ -1,283 +0,0 @@
-package com.android.camera.support.glrenderer;
-
-
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.opengl.GLUtils;
-
-import junit.framework.Assert;
-
-import java.util.HashMap;
-
-import javax.microedition.khronos.opengles.GL11;
-
-// UploadedTextures use a Bitmap for the content of the texture.
-//
-// Subclasses should implement onGetBitmap() to provide the Bitmap and
-// implement onFreeBitmap(mBitmap) which will be called when the Bitmap
-// is not needed anymore.
-//
-// isContentValid() is meaningful only when the isLoaded() returns true.
-// It means whether the content needs to be updated.
-//
-// The user of this class should call recycle() when the texture is not
-// needed anymore.
-//
-// By default an UploadedTexture is opaque (so it can be drawn faster without
-// blending). The user or subclass can override it using setOpaque().
-public abstract class UploadedTexture extends BasicTexture {
-
- // To prevent keeping allocation the borders, we store those used borders here.
- // Since the length will be power of two, it won't use too much memory.
- private static HashMap<BorderKey, Bitmap> sBorderLines =
- new HashMap<BorderKey, Bitmap>();
- private static BorderKey sBorderKey = new BorderKey();
-
- @SuppressWarnings("unused")
- private static final String TAG = "Texture";
- private boolean mContentValid = true;
-
- // indicate this textures is being uploaded in background
- private boolean mIsUploading = false;
- private boolean mOpaque = true;
- private boolean mThrottled = false;
- private static int sUploadedCount;
- private static final int UPLOAD_LIMIT = 100;
-
- protected Bitmap mBitmap;
- private int mBorder;
-
- protected UploadedTexture() {
- this(false);
- }
-
- protected UploadedTexture(boolean hasBorder) {
- super(null, 0, STATE_UNLOADED);
- if (hasBorder) {
- setBorder(true);
- mBorder = 1;
- }
- }
-
- protected void setIsUploading(boolean uploading) {
- mIsUploading = uploading;
- }
-
- public boolean isUploading() {
- return mIsUploading;
- }
-
- private static class BorderKey implements Cloneable {
- public boolean vertical;
- public Config config;
- public int length;
-
- @Override
- public int hashCode() {
- int x = config.hashCode() ^ length;
- return vertical ? x : -x;
- }
-
- @Override
- public boolean equals(Object object) {
- if (!(object instanceof BorderKey)) return false;
- BorderKey o = (BorderKey) object;
- return vertical == o.vertical
- && config == o.config && length == o.length;
- }
-
- @Override
- public BorderKey clone() {
- try {
- return (BorderKey) super.clone();
- } catch (CloneNotSupportedException e) {
- throw new AssertionError(e);
- }
- }
- }
-
- protected void setThrottled(boolean throttled) {
- mThrottled = throttled;
- }
-
- private static Bitmap getBorderLine(
- boolean vertical, Config config, int length) {
- BorderKey key = sBorderKey;
- key.vertical = vertical;
- key.config = config;
- key.length = length;
- Bitmap bitmap = sBorderLines.get(key);
- if (bitmap == null) {
- bitmap = vertical
- ? Bitmap.createBitmap(1, length, config)
- : Bitmap.createBitmap(length, 1, config);
- sBorderLines.put(key.clone(), bitmap);
- }
- return bitmap;
- }
-
- private Bitmap getBitmap() {
- if (mBitmap == null) {
- mBitmap = onGetBitmap();
- int w = mBitmap.getWidth() + mBorder * 2;
- int h = mBitmap.getHeight() + mBorder * 2;
- if (mWidth == UNSPECIFIED) {
- setSize(w, h);
- }
- }
- return mBitmap;
- }
-
- private void freeBitmap() {
- Assert.assertTrue(mBitmap != null);
- onFreeBitmap(mBitmap);
- mBitmap = null;
- }
-
- @Override
- public int getWidth() {
- if (mWidth == UNSPECIFIED) getBitmap();
- return mWidth;
- }
-
- @Override
- public int getHeight() {
- if (mWidth == UNSPECIFIED) getBitmap();
- return mHeight;
- }
-
- protected abstract Bitmap onGetBitmap();
-
- protected abstract void onFreeBitmap(Bitmap bitmap);
-
- protected void invalidateContent() {
- if (mBitmap != null) freeBitmap();
- mContentValid = false;
- mWidth = UNSPECIFIED;
- mHeight = UNSPECIFIED;
- }
-
- /**
- * Whether the content on GPU is valid.
- */
- public boolean isContentValid() {
- return isLoaded() && mContentValid;
- }
-
- /**
- * Updates the content on GPU's memory.
- * @param canvas
- */
- public void updateContent(GLCanvas canvas) {
- if (!isLoaded()) {
- if (mThrottled && ++sUploadedCount > UPLOAD_LIMIT) {
- return;
- }
- uploadToCanvas(canvas);
- } else if (!mContentValid) {
- Bitmap bitmap = getBitmap();
- int format = GLUtils.getInternalFormat(bitmap);
- int type = GLUtils.getType(bitmap);
- canvas.texSubImage2D(this, mBorder, mBorder, bitmap, format, type);
- freeBitmap();
- mContentValid = true;
- }
- }
-
- public static void resetUploadLimit() {
- sUploadedCount = 0;
- }
-
- public static boolean uploadLimitReached() {
- return sUploadedCount > UPLOAD_LIMIT;
- }
-
- private void uploadToCanvas(GLCanvas canvas) {
-
- Bitmap bitmap = getBitmap();
- if (bitmap != null) {
- try {
- int bWidth = bitmap.getWidth();
- int bHeight = bitmap.getHeight();
- int width = bWidth + mBorder * 2;
- int height = bHeight + mBorder * 2;
- int texWidth = getTextureWidth();
- int texHeight = getTextureHeight();
-
- Assert.assertTrue(bWidth <= texWidth && bHeight <= texHeight);
-
- // Upload the bitmap to a new texture.
- mId = canvas.getGLId().generateTexture();
- canvas.setTextureParameters(this);
-
- if (bWidth == texWidth && bHeight == texHeight) {
- canvas.initializeTexture(this, bitmap);
- } else {
- int format = GLUtils.getInternalFormat(bitmap);
- int type = GLUtils.getType(bitmap);
- Config config = bitmap.getConfig();
-
- canvas.initializeTextureSize(this, format, type);
- canvas.texSubImage2D(this, mBorder, mBorder, bitmap, format, type);
-
- if (mBorder > 0) {
- // Left border
- Bitmap line = getBorderLine(true, config, texHeight);
- canvas.texSubImage2D(this, 0, 0, line, format, type);
-
- // Top border
- line = getBorderLine(false, config, texWidth);
- canvas.texSubImage2D(this, 0, 0, line, format, type);
- }
-
- // Right border
- if (mBorder + bWidth < texWidth) {
- Bitmap line = getBorderLine(true, config, texHeight);
- canvas.texSubImage2D(this, mBorder + bWidth, 0, line, format, type);
- }
-
- // Bottom border
- if (mBorder + bHeight < texHeight) {
- Bitmap line = getBorderLine(false, config, texWidth);
- canvas.texSubImage2D(this, 0, mBorder + bHeight, line, format, type);
- }
- }
- } finally {
- freeBitmap();
- }
- // Update texture state.
- setAssociatedCanvas(canvas);
- mState = STATE_LOADED;
- mContentValid = true;
- } else {
- mState = STATE_ERROR;
- throw new RuntimeException("Texture load fail, no bitmap");
- }
- }
-
- @Override
- protected boolean onBind(GLCanvas canvas) {
- updateContent(canvas);
- return isContentValid();
- }
-
- @Override
- protected int getTarget() {
- return GL11.GL_TEXTURE_2D;
- }
-
- public void setOpaque(boolean isOpaque) {
- mOpaque = isOpaque;
- }
-
- @Override
- public boolean isOpaque() {
- return mOpaque;
- }
-
- @Override
- public void recycle() {
- super.recycle();
- if (mBitmap != null) freeBitmap();
- }
-} \ No newline at end of file
diff --git a/src/com/android/camera/support/ui/BitmapScreenNail.java b/src/com/android/camera/support/ui/BitmapScreenNail.java
deleted file mode 100644
index a0252b9a5..000000000
--- a/src/com/android/camera/support/ui/BitmapScreenNail.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.android.camera.support.ui;
-
-import android.graphics.Bitmap;
-import android.graphics.RectF;
-
-import com.android.camera.support.glrenderer.BitmapTexture;
-import com.android.camera.support.glrenderer.GLCanvas;
-
-public class BitmapScreenNail implements ScreenNail {
- private final BitmapTexture mBitmapTexture;
-
- public BitmapScreenNail(Bitmap bitmap) {
- mBitmapTexture = new BitmapTexture(bitmap);
- }
-
- @Override
- public int getWidth() {
- return mBitmapTexture.getWidth();
- }
-
- @Override
- public int getHeight() {
- return mBitmapTexture.getHeight();
- }
-
- @Override
- public void draw(GLCanvas canvas, int x, int y, int width, int height) {
- mBitmapTexture.draw(canvas, x, y, width, height);
- }
-
- @Override
- public void noDraw() {
- // do nothing
- }
-
- @Override
- public void recycle() {
- mBitmapTexture.recycle();
- }
-
- @Override
- public void draw(GLCanvas canvas, RectF source, RectF dest) {
- canvas.drawTexture(mBitmapTexture, source, dest);
- }
-}
diff --git a/src/com/android/camera/support/ui/ScreenNail.java b/src/com/android/camera/support/ui/ScreenNail.java
deleted file mode 100644
index 67b2f58c5..000000000
--- a/src/com/android/camera/support/ui/ScreenNail.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.android.camera.support.ui;
-
-
-import android.graphics.RectF;
-
-import com.android.camera.support.glrenderer.GLCanvas;
-
-public interface ScreenNail {
- public int getWidth();
- public int getHeight();
- public void draw(GLCanvas canvas, int x, int y, int width, int height);
-
- // We do not need to draw this ScreenNail in this frame.
- public void noDraw();
-
- // This ScreenNail will not be used anymore. Release related resources.
- public void recycle();
-
- // This is only used by TileImageView to back up the tiles not yet loaded.
- public void draw(GLCanvas canvas, RectF source, RectF dest);
-}
diff --git a/src/com/android/camera/support/ui/SurfaceTextureScreenNail.java b/src/com/android/camera/support/ui/SurfaceTextureScreenNail.java
deleted file mode 100644
index d78b1ba4a..000000000
--- a/src/com/android/camera/support/ui/SurfaceTextureScreenNail.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package com.android.camera.support.ui;
-
-
-import android.annotation.TargetApi;
-import android.graphics.RectF;
-import android.graphics.SurfaceTexture;
-
-import com.android.camera.support.common.ApiHelper;
-import com.android.camera.support.glrenderer.ExtTexture;
-import com.android.camera.support.glrenderer.GLCanvas;
-
-
-@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
-public abstract class SurfaceTextureScreenNail implements ScreenNail,
- SurfaceTexture.OnFrameAvailableListener {
- @SuppressWarnings("unused")
- private static final String TAG = "SurfaceTextureScreenNail";
- // This constant is not available in API level before 15, but it was just an
- // oversight.
- private static final int GL_TEXTURE_EXTERNAL_OES = 0x8D65;
-
- protected ExtTexture mExtTexture;
- private SurfaceTexture mSurfaceTexture;
- private int mWidth, mHeight;
- private float[] mTransform = new float[16];
- private boolean mHasTexture = false;
-
- public SurfaceTextureScreenNail() {
- }
-
- public void acquireSurfaceTexture(GLCanvas canvas) {
- mExtTexture = new ExtTexture(canvas, GL_TEXTURE_EXTERNAL_OES);
- mExtTexture.setSize(mWidth, mHeight);
- mSurfaceTexture = new SurfaceTexture(mExtTexture.getId());
- setDefaultBufferSize(mSurfaceTexture, mWidth, mHeight);
- mSurfaceTexture.setOnFrameAvailableListener(this);
- synchronized (this) {
- mHasTexture = true;
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
- private static void setDefaultBufferSize(SurfaceTexture st, int width, int height) {
- if (ApiHelper.HAS_SET_DEFALT_BUFFER_SIZE) {
- st.setDefaultBufferSize(width, height);
- }
- }
-
- @TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
- private static void releaseSurfaceTexture(SurfaceTexture st) {
- st.setOnFrameAvailableListener(null);
- if (ApiHelper.HAS_RELEASE_SURFACE_TEXTURE) {
- st.release();
- }
- }
-
- public SurfaceTexture getSurfaceTexture() {
- return mSurfaceTexture;
- }
-
- public void releaseSurfaceTexture() {
- synchronized (this) {
- mHasTexture = false;
- }
- mExtTexture.recycle();
- mExtTexture = null;
- releaseSurfaceTexture(mSurfaceTexture);
- mSurfaceTexture = null;
- }
-
- public void setSize(int width, int height) {
- mWidth = width;
- mHeight = height;
- }
-
- public void resizeTexture() {
- if (mExtTexture != null) {
- mExtTexture.setSize(mWidth, mHeight);
- setDefaultBufferSize(mSurfaceTexture, mWidth, mHeight);
- }
- }
-
- @Override
- public int getWidth() {
- return mWidth;
- }
-
- @Override
- public int getHeight() {
- return mHeight;
- }
-
- @Override
- public void draw(GLCanvas canvas, int x, int y, int width, int height) {
- synchronized (this) {
- if (!mHasTexture) return;
- mSurfaceTexture.updateTexImage();
- mSurfaceTexture.getTransformMatrix(mTransform);
-
- // Flip vertically.
- canvas.save(GLCanvas.SAVE_FLAG_MATRIX);
- int cx = x + width / 2;
- int cy = y + height / 2;
- canvas.translate(cx, cy);
- canvas.scale(1, -1, 1);
- canvas.translate(-cx, -cy);
- updateTransformMatrix(mTransform);
- canvas.drawTexture(mExtTexture, mTransform, x, y, width, height);
- canvas.restore();
- }
- }
-
- @Override
- public void draw(GLCanvas canvas, RectF source, RectF dest) {
- throw new UnsupportedOperationException();
- }
-
- protected void updateTransformMatrix(float[] matrix) {}
-
- @Override
- abstract public void noDraw();
-
- @Override
- abstract public void recycle();
-
- @Override
- abstract public void onFrameAvailable(SurfaceTexture surfaceTexture);
-} \ No newline at end of file
diff --git a/src/com/android/camera/ui/CameraRootView.java b/src/com/android/camera/ui/CameraRootView.java
index 5186ea24c..48f24e4f2 100644
--- a/src/com/android/camera/ui/CameraRootView.java
+++ b/src/com/android/camera/ui/CameraRootView.java
@@ -27,8 +27,8 @@ import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
-import com.android.camera.Util;
-import com.android.camera.support.common.ApiHelper;
+import com.android.camera.util.CameraUtil;
+import com.android.camera.util.ApiHelper;
@SuppressLint("NewApi")
public class CameraRootView extends FrameLayout {
@@ -110,7 +110,7 @@ public class CameraRootView extends FrameLayout {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int rotation = Util.getDisplayRotation((Activity) getContext());
+ int rotation = CameraUtil.getDisplayRotation((Activity) getContext());
// all the layout code assumes camera device orientation to be portrait
// adjust rotation for landscape
int orientation = getResources().getConfiguration().orientation;
diff --git a/src/com/android/camera/ui/CameraSwitcher.java b/src/com/android/camera/ui/CameraSwitcher.java
index 4a05622bc..eee68a58c 100644
--- a/src/com/android/camera/ui/CameraSwitcher.java
+++ b/src/com/android/camera/ui/CameraSwitcher.java
@@ -34,12 +34,12 @@ import android.view.ViewGroup;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;
-import com.android.camera.Util;
+import com.android.camera.util.CameraUtil;
import com.android.camera.util.PhotoSphereHelper;
import com.android.camera.util.RefocusHelper;
import com.android.camera.util.UsageStatistics;
import com.android.camera2.R;
-import com.android.gallery3d.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
public class CameraSwitcher extends RotateImageView
implements OnClickListener, OnTouchListener {
@@ -292,7 +292,7 @@ public class CameraSwitcher extends RotateImageView
}
private void layoutPopup() {
- int orientation = Util.getDisplayRotation((Activity) getContext());
+ int orientation = CameraUtil.getDisplayRotation((Activity) getContext());
int w = mPopup.getMeasuredWidth();
int h = mPopup.getMeasuredHeight();
if (orientation == 0) {
diff --git a/src/com/android/camera/ui/EffectSettingPopup.java b/src/com/android/camera/ui/EffectSettingPopup.java
index d51803a83..1ee278d21 100644
--- a/src/com/android/camera/ui/EffectSettingPopup.java
+++ b/src/com/android/camera/ui/EffectSettingPopup.java
@@ -30,7 +30,7 @@ import android.widget.SimpleAdapter;
import com.android.camera.IconListPreference;
import com.android.camera2.R;
-import com.android.gallery3d.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
// A popup window that shows video effect setting. It has two grid view.
// One shows the goofy face effects. The other shows the background replacer
diff --git a/src/com/android/camera/ui/FaceView.java b/src/com/android/camera/ui/FaceView.java
index 1a539665e..7ec9b7e54 100644
--- a/src/com/android/camera/ui/FaceView.java
+++ b/src/com/android/camera/ui/FaceView.java
@@ -31,10 +31,10 @@ import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
+import com.android.camera.util.CameraUtil;
import com.android.camera.PhotoUI;
-import com.android.camera.Util;
import com.android.camera2.R;
-import com.android.gallery3d.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
@TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
public class FaceView extends View
@@ -197,7 +197,7 @@ public class FaceView extends View
rw = rh;
rh = temp;
}
- Util.prepareMatrix(mMatrix, mMirror, mDisplayOrientation, rw, rh);
+ CameraUtil.prepareMatrix(mMatrix, mMirror, mDisplayOrientation, rw, rh);
int dx = (getWidth() - rw) / 2;
int dy = (getHeight() - rh) / 2;
@@ -212,9 +212,9 @@ public class FaceView extends View
// Transform the coordinates.
mRect.set(mFaces[i].rect);
- if (LOGV) Util.dumpRect(mRect, "Original rect");
+ if (LOGV) CameraUtil.dumpRect(mRect, "Original rect");
mMatrix.mapRect(mRect);
- if (LOGV) Util.dumpRect(mRect, "Transformed rect");
+ if (LOGV) CameraUtil.dumpRect(mRect, "Transformed rect");
mPaint.setColor(mColor);
mRect.offset(dx, dy);
canvas.drawOval(mRect, mPaint);
diff --git a/src/com/android/camera/ui/PreviewSurfaceView.java b/src/com/android/camera/ui/PreviewSurfaceView.java
deleted file mode 100644
index 9a428e23c..000000000
--- a/src/com/android/camera/ui/PreviewSurfaceView.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.ViewGroup;
-
-import com.android.gallery3d.common.ApiHelper;
-
-public class PreviewSurfaceView extends SurfaceView {
- public PreviewSurfaceView(Context context, AttributeSet attrs) {
- super(context, attrs);
- setZOrderMediaOverlay(true);
- getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
- }
-
- public void shrink() {
- setLayoutSize(1);
- }
-
- public void expand() {
- setLayoutSize(ViewGroup.LayoutParams.MATCH_PARENT);
- }
-
- private void setLayoutSize(int size) {
- ViewGroup.LayoutParams p = getLayoutParams();
- if (p.width != size || p.height != size) {
- p.width = size;
- p.height = size;
- setLayoutParams(p);
- }
- }
-}
diff --git a/src/com/android/camera/ui/RotatableLayout.java b/src/com/android/camera/ui/RotatableLayout.java
index 965d62a90..e9ee0f358 100644
--- a/src/com/android/camera/ui/RotatableLayout.java
+++ b/src/com/android/camera/ui/RotatableLayout.java
@@ -25,7 +25,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
-import com.android.camera.Util;
+import com.android.camera.util.CameraUtil;
/* RotatableLayout rotates itself as well as all its children when orientation
* changes. Specifically, when going from portrait to landscape, camera
@@ -62,7 +62,7 @@ public class RotatableLayout extends FrameLayout {
@Override
public void onAttachedToWindow() {
- mPrevRotation = Util.getDisplayRotation((Activity) getContext());
+ mPrevRotation = CameraUtil.getDisplayRotation((Activity) getContext());
// check if there is any rotation before the view is attached to window
int currentOrientation = getResources().getConfiguration().orientation;
int orientation = getUnifiedRotation();
@@ -89,7 +89,7 @@ public class RotatableLayout extends FrameLayout {
// all the layout code assumes camera device orientation to be portrait
// adjust rotation for landscape
int orientation = getResources().getConfiguration().orientation;
- int rotation = Util.getDisplayRotation((Activity) getContext());
+ int rotation = CameraUtil.getDisplayRotation((Activity) getContext());
int camOrientation = (rotation % 180 == 0) ? Configuration.ORIENTATION_PORTRAIT
: Configuration.ORIENTATION_LANDSCAPE;
if (camOrientation != orientation) {
@@ -99,7 +99,7 @@ public class RotatableLayout extends FrameLayout {
}
public void checkLayoutFlip() {
- int currentRotation = Util.getDisplayRotation((Activity) getContext());
+ int currentRotation = CameraUtil.getDisplayRotation((Activity) getContext());
if ((currentRotation - mPrevRotation + 360) % 360 == 180) {
mPrevRotation = currentRotation;
flipChildren();
@@ -118,7 +118,7 @@ public class RotatableLayout extends FrameLayout {
@Override
public void onConfigurationChanged(Configuration config) {
super.onConfigurationChanged(config);
- int rotation = Util.getDisplayRotation((Activity) getContext());
+ int rotation = CameraUtil.getDisplayRotation((Activity) getContext());
int diff = (rotation - mPrevRotation + 360) % 360;
if ( diff == 0) {
// No rotation
diff --git a/src/com/android/camera/ui/RotateLayout.java b/src/com/android/camera/ui/RotateLayout.java
index 5d6debb17..044da1cee 100644
--- a/src/com/android/camera/ui/RotateLayout.java
+++ b/src/com/android/camera/ui/RotateLayout.java
@@ -27,8 +27,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
-import com.android.camera.support.util.MotionEventHelper;
-import com.android.gallery3d.common.ApiHelper;
+import com.android.camera.util.MotionEventHelper;
+import com.android.camera.util.ApiHelper;
// A RotateLayout is designed to display a single item and provides the
// capabilities to rotate the item.
diff --git a/src/com/android/camera/ui/RotateTextToast.java b/src/com/android/camera/ui/RotateTextToast.java
index 16382442e..ea1268218 100644
--- a/src/com/android/camera/ui/RotateTextToast.java
+++ b/src/com/android/camera/ui/RotateTextToast.java
@@ -23,7 +23,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
-import com.android.camera.Util;
+import com.android.camera.util.CameraUtil;
import com.android.camera2.R;
public class RotateTextToast {
@@ -46,7 +46,7 @@ public class RotateTextToast {
private final Runnable mRunnable = new Runnable() {
@Override
public void run() {
- Util.fadeOut(mToast);
+ CameraUtil.fadeOut(mToast);
mLayoutRoot.removeView(mToast);
mToast = null;
}
diff --git a/src/com/android/camera/ui/Switch.java b/src/com/android/camera/ui/Switch.java
index 9191242f6..4518dedf4 100644
--- a/src/com/android/camera/ui/Switch.java
+++ b/src/com/android/camera/ui/Switch.java
@@ -39,7 +39,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.CompoundButton;
import com.android.camera2.R;
-import com.android.gallery3d.common.ApiHelper;
+import com.android.camera.util.ApiHelper;
/**
* A Switch is a two-state toggle switch widget that can select between two
diff --git a/src/com/android/camera/support/util/AccessibilityUtils.java b/src/com/android/camera/util/AccessibilityUtils.java
index e758e2f7e..543c7ff4d 100644
--- a/src/com/android/camera/support/util/AccessibilityUtils.java
+++ b/src/com/android/camera/util/AccessibilityUtils.java
@@ -1,4 +1,4 @@
-package com.android.camera.support.util;
+package com.android.camera.util;
import android.content.Context;
import android.support.v4.view.accessibility.AccessibilityRecordCompat;
@@ -6,8 +6,6 @@ import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
-import com.android.camera.support.common.ApiHelper;
-
/**
* AccessibilityUtils provides functions needed in accessibility mode. All the functions
* in this class are made compatible with gingerbread and later API's
diff --git a/src/com/android/camera/support/common/ApiHelper.java b/src/com/android/camera/util/ApiHelper.java
index e6c1f5fb6..6cb303476 100644
--- a/src/com/android/camera/support/common/ApiHelper.java
+++ b/src/com/android/camera/util/ApiHelper.java
@@ -1,5 +1,20 @@
-package com.android.camera.support.common;
-
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera.util;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/util/CameraUtil.java
index 11176a79b..736235bcd 100644
--- a/src/com/android/camera/Util.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.camera;
+package com.android.camera.util;
import java.io.Closeable;
import java.io.IOException;
@@ -61,15 +61,22 @@ import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.Toast;
+import com.android.camera.CameraDisabledException;
+import com.android.camera.CameraHardwareException;
+import com.android.camera.CameraHolder;
+import com.android.camera.CameraManager;
import com.android.camera2.R;
-import com.android.gallery3d.common.ApiHelper;
/**
* Collection of utility functions used in this package.
*/
-public class Util {
+public class CameraUtil {
private static final String TAG = "Util";
+ // For creating crop intents.
+ public static final String KEY_RETURN_DATA = "return-data";
+ public static final String KEY_SHOW_WHEN_LOCKED = "showWhenLocked";
+
// Orientation hysteresis amount used in rounding, in degrees
public static final int ORIENTATION_HYSTERESIS = 5;
@@ -138,7 +145,7 @@ public class Util {
private static float sPixelDensity = 1;
private static ImageFileNamer sImageFileNamer;
- private Util() {
+ private CameraUtil() {
}
public static void initialize(Context context) {
@@ -554,7 +561,7 @@ public class Util {
int cameraId = -1;
int intentCameraId =
- currentActivity.getIntent().getIntExtra(Util.EXTRAS_CAMERA_FACING, -1);
+ currentActivity.getIntent().getIntExtra(CameraUtil.EXTRAS_CAMERA_FACING, -1);
if (isFrontCameraIntent(intentCameraId)) {
// Check if the front camera exist
@@ -622,7 +629,7 @@ public class Util {
}
try {
- context.startActivity(new Intent(Util.REVIEW_ACTION, uri));
+ context.startActivity(new Intent(CameraUtil.REVIEW_ACTION, uri));
} catch (ActivityNotFoundException ex) {
try {
context.startActivity(new Intent(Intent.ACTION_VIEW, uri));
diff --git a/src/com/android/camera/support/util/MotionEventHelper.java b/src/com/android/camera/util/MotionEventHelper.java
index 2a3340e28..eabaeab3b 100644
--- a/src/com/android/camera/support/util/MotionEventHelper.java
+++ b/src/com/android/camera/util/MotionEventHelper.java
@@ -1,4 +1,4 @@
-package com.android.camera.support.util;
+package com.android.camera.util;
import android.annotation.TargetApi;
import android.graphics.Matrix;
@@ -6,8 +6,6 @@ import android.util.FloatMath;
import android.view.MotionEvent;
import android.view.MotionEvent.PointerCoords;
-import com.android.gallery3d.common.ApiHelper;
-
public final class MotionEventHelper {
private MotionEventHelper() {}