summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/camera/VideoModule.java14
-rw-r--r--src/com/android/camera/data/CameraDataAdapter.java1
-rw-r--r--src/com/android/camera/data/LocalData.java79
-rw-r--r--src/com/android/camera/ui/FilmStripView.java235
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java135
5 files changed, 274 insertions, 190 deletions
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 839037fc0..0daa67246 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -394,12 +394,6 @@ public class VideoModule implements CameraModule,
readVideoPreferences();
mUI.setPrefChangedListener(this);
- new Thread(new Runnable() {
- @Override
- public void run() {
- startPreview();
- }
- }).start();
mQuickCapture = mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE, false);
mLocationManager = new LocationManager(mActivity, null);
@@ -761,7 +755,11 @@ public class VideoModule implements CameraModule,
new Thread(new Runnable() {
@Override
public void run() {
- startPreview();
+ synchronized (mCameraOpened) {
+ if (mCameraOpened) {
+ startPreview();
+ }
+ }
}
}).start();
} else {
@@ -931,8 +929,8 @@ public class VideoModule implements CameraModule,
CameraHolder.instance().release();
}
mCameraOpened = false;
+ mCameraDevice = null;
}
- mCameraDevice = null;
mPreviewing = false;
mSnapshotInProgress = false;
}
diff --git a/src/com/android/camera/data/CameraDataAdapter.java b/src/com/android/camera/data/CameraDataAdapter.java
index 0788c1a7a..436919776 100644
--- a/src/com/android/camera/data/CameraDataAdapter.java
+++ b/src/com/android/camera/data/CameraDataAdapter.java
@@ -340,7 +340,6 @@ public class CameraDataAdapter implements FilmStripView.DataAdapter {
LocalData data = LocalData.Video.buildFromCursor(c);
if (data != null) {
l.add(data);
- Log.v(TAG, "video data added:" + data);
} else {
Log.e(TAG, "Error loading data:"
+ c.getString(LocalData.Video.COL_DATA));
diff --git a/src/com/android/camera/data/LocalData.java b/src/com/android/camera/data/LocalData.java
index 0ccc63950..384456ed2 100644
--- a/src/com/android/camera/data/LocalData.java
+++ b/src/com/android/camera/data/LocalData.java
@@ -148,14 +148,15 @@ public interface LocalData extends FilmStripView.ImageData {
}
@Override
- public boolean delete(Context c) {
+ public boolean delete(Context ctx) {
File f = new File(path);
return f.delete();
}
- protected View fillViewBackground(Context c, View v,
+ protected ImageView fillImageView(Context ctx, ImageView v,
int decodeWidth, int decodeHeight, Drawable placeHolder) {
- v.setBackground(placeHolder);
+ v.setScaleType(ImageView.ScaleType.FIT_XY);
+ v.setImageDrawable(placeHolder);
BitmapLoadTask task = getBitmapLoadTask(v, decodeWidth, decodeHeight);
task.execute();
@@ -163,9 +164,10 @@ public interface LocalData extends FilmStripView.ImageData {
}
@Override
- public View getView(Context c,
+ public View getView(Context ctx,
int decodeWidth, int decodeHeight, Drawable placeHolder) {
- return fillViewBackground(c, new ImageView(c), decodeWidth, decodeHeight, placeHolder);
+ return fillImageView(ctx, new ImageView(ctx),
+ decodeWidth, decodeHeight, placeHolder);
}
@Override
@@ -192,16 +194,16 @@ public interface LocalData extends FilmStripView.ImageData {
public abstract int getType();
protected abstract BitmapLoadTask getBitmapLoadTask(
- View v, int decodeWidth, int decodeHeight);
+ ImageView v, int decodeWidth, int decodeHeight);
/*
* An AsyncTask class that loads the bitmap in the background thread.
* Sub-classes should implement their own "protected Bitmap doInBackground(Void... )"
*/
protected abstract class BitmapLoadTask extends AsyncTask<Void, Void, Bitmap> {
- protected View mView;
+ protected ImageView mView;
- protected BitmapLoadTask(View v) {
+ protected BitmapLoadTask(ImageView v) {
mView = v;
}
@@ -213,8 +215,8 @@ public interface LocalData extends FilmStripView.ImageData {
return;
}
BitmapDrawable d = new BitmapDrawable(bitmap);
- d.setGravity(Gravity.FILL);
- mView.setBackground(d);
+ mView.setScaleType(ImageView.ScaleType.FIT_XY);
+ mView.setImageDrawable(d);
}
}
}
@@ -270,14 +272,16 @@ public interface LocalData extends FilmStripView.ImageData {
d.width = c.getInt(COL_WIDTH);
d.height = c.getInt(COL_HEIGHT);
if (d.width <= 0 || d.height <= 0) {
- Log.v(TAG, "warning! zero dimension for "
+ Log.w(TAG, "Warning! zero dimension for "
+ d.path + ":" + d.width + "x" + d.height);
- BitmapFactory.Options opts = decodeDimension(d.path);
- if (opts != null) {
+ BitmapFactory.Options opts = new BitmapFactory.Options();
+ opts.inJustDecodeBounds = true;
+ BitmapFactory.decodeFile(d.path, opts);
+ if (opts.outWidth != -1 && opts.outHeight != -1) {
d.width = opts.outWidth;
d.height = opts.outHeight;
} else {
- Log.v(TAG, "warning! dimension decode failed for " + d.path);
+ Log.w(TAG, "Warning! dimension decode failed for " + d.path);
Bitmap b = BitmapFactory.decodeFile(d.path);
if (b == null) {
return null;
@@ -325,25 +329,15 @@ public interface LocalData extends FilmStripView.ImageData {
@Override
protected BitmapLoadTask getBitmapLoadTask(
- View v, int decodeWidth, int decodeHeight) {
+ ImageView v, int decodeWidth, int decodeHeight) {
return new PhotoBitmapLoadTask(v, decodeWidth, decodeHeight);
}
- private static BitmapFactory.Options decodeDimension(String path) {
- BitmapFactory.Options opts = new BitmapFactory.Options();
- opts.inJustDecodeBounds = true;
- Bitmap b = BitmapFactory.decodeFile(path, opts);
- if (b == null) {
- return null;
- }
- return opts;
- }
-
private final class PhotoBitmapLoadTask extends BitmapLoadTask {
private int mDecodeWidth;
private int mDecodeHeight;
- public PhotoBitmapLoadTask(View v, int decodeWidth, int decodeHeight) {
+ public PhotoBitmapLoadTask(ImageView v, int decodeWidth, int decodeHeight) {
super(v);
mDecodeWidth = decodeWidth;
mDecodeHeight = decodeHeight;
@@ -436,7 +430,8 @@ public interface LocalData extends FilmStripView.ImageData {
MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
}
retriever.release();
- if (rotation.equals("90") || rotation.equals("270")) {
+ if (rotation != null
+ && (rotation.equals("90") || rotation.equals("270"))) {
int b = d.width;
d.width = d.height;
d.height = b;
@@ -466,18 +461,25 @@ public interface LocalData extends FilmStripView.ImageData {
}
@Override
- public boolean delete(Context c) {
- ContentResolver cr = c.getContentResolver();
+ public boolean delete(Context ctx) {
+ ContentResolver cr = ctx.getContentResolver();
cr.delete(CONTENT_URI, VideoColumns._ID + "=" + id, null);
- return super.delete(c);
+ return super.delete(ctx);
}
@Override
- public View getView(final Context c,
+ public View getView(final Context ctx,
int decodeWidth, int decodeHeight, Drawable placeHolder) {
- FrameLayout f = new FrameLayout(c);
- fillViewBackground(c, f, decodeWidth, decodeHeight, placeHolder);
- ImageView icon = new ImageView(c);
+
+ // ImageView for the bitmap.
+ ImageView iv = new ImageView(ctx);
+ iv.setLayoutParams(new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER));
+ fillImageView(ctx, iv, decodeWidth, decodeHeight, placeHolder);
+
+ // ImageView for the play icon.
+ ImageView icon = new ImageView(ctx);
icon.setImageResource(R.drawable.ic_control_play);
icon.setScaleType(ImageView.ScaleType.CENTER);
icon.setLayoutParams(new FrameLayout.LayoutParams(
@@ -486,22 +488,25 @@ public interface LocalData extends FilmStripView.ImageData {
icon.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
- Util.playVideo(c, mPlayUri, title);
+ Util.playVideo(ctx, mPlayUri, title);
}
});
+
+ FrameLayout f = new FrameLayout(ctx);
+ f.addView(iv);
f.addView(icon);
return f;
}
@Override
protected BitmapLoadTask getBitmapLoadTask(
- View v, int decodeWidth, int decodeHeight) {
+ ImageView v, int decodeWidth, int decodeHeight) {
return new VideoBitmapLoadTask(v);
}
private final class VideoBitmapLoadTask extends BitmapLoadTask {
- public VideoBitmapLoadTask(View v) {
+ public VideoBitmapLoadTask(ImageView v) {
super(v);
}
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java
index 709d7c666..c1b677204 100644
--- a/src/com/android/camera/ui/FilmStripView.java
+++ b/src/com/android/camera/ui/FilmStripView.java
@@ -24,12 +24,12 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
-import android.view.animation.LinearInterpolator;
import android.widget.Scroller;
public class FilmStripView extends ViewGroup {
@@ -42,7 +42,7 @@ public class FilmStripView extends ViewGroup {
private static final int DURATION_SCROLL_TO_FILMSTRIP = 350;
private static final int DURATION_GEOMETRY_ADJUST = 200;
private static final float FILM_STRIP_SCALE = 0.6f;
- private static final float MAX_SCALE = 1f;
+ private static final float FULLSCREEN_SCALE = 1f;
// Only check for intercepting touch events within first 500ms
private static final int SWIPE_TIME_OUT = 500;
@@ -143,6 +143,7 @@ public class FilmStripView extends ViewGroup {
public interface Controller {
public boolean isScalling();
+ public void scroll(float deltaX);
public void fling(float velocity);
public void scrollTo(int position, int duration, boolean interruptible);
public boolean stopScrolling();
@@ -162,6 +163,7 @@ public class FilmStripView extends ViewGroup {
// the position of the left of the view in the whole filmstrip.
private int mLeftPosition;
private View mView;
+ private RectF mViewArea;
public ViewInfo(int id, View v) {
v.setPivotX(0f);
@@ -169,6 +171,7 @@ public class FilmStripView extends ViewGroup {
mDataID = id;
mView = v;
mLeftPosition = -1;
+ mViewArea = new RectF();
}
public int getID() {
@@ -232,6 +235,17 @@ public class FilmStripView extends ViewGroup {
layoutAt(left, top);
mView.setScaleX(scale);
mView.setScaleY(scale);
+
+ // update mViewArea for touch detection.
+ int l = mView.getLeft();
+ int t = mView.getTop();
+ mViewArea.set(l, t,
+ l + mView.getWidth() * scale,
+ t + mView.getHeight() * scale);
+ }
+
+ public boolean areaContains(float x, float y) {
+ return mViewArea.contains(x, y);
}
}
@@ -260,7 +274,7 @@ public class FilmStripView extends ViewGroup {
mContext = context;
mScale = 1.0f;
mController = new MyController(context);
- mViewAnimInterpolator = new LinearInterpolator();
+ mViewAnimInterpolator = new DecelerateInterpolator();
mGestureRecognizer =
new FilmStripGestureRecognizer(context, new MyGestureReceiver());
mSlop = (int) getContext().getResources().getDimension(R.dimen.pie_touch_slop);
@@ -409,6 +423,11 @@ public class FilmStripView extends ViewGroup {
// We try to keep the one closest to the center of the screen at position mCurrentInfo.
private void stepIfNeeded() {
+ if (!inFilmStrip() && !inFullScreen()) {
+ // The good timing to step to the next view is when everything is not in
+ // transition.
+ return;
+ }
int nearest = findTheNearestView(mCenterX);
// no change made.
if (nearest == -1 || nearest == mCurrentInfo) return;
@@ -444,7 +463,7 @@ public class FilmStripView extends ViewGroup {
}
// Don't go beyond the bound.
- private void adjustCenterX() {
+ private void clampCenterX() {
ViewInfo curr = mViewInfo[mCurrentInfo];
if (curr == null) return;
@@ -455,7 +474,7 @@ public class FilmStripView extends ViewGroup {
}
if (getCurrentType() == ImageData.TYPE_CAMERA_PREVIEW
&& !mController.isScalling()
- && mScale != MAX_SCALE) {
+ && mScale != FULLSCREEN_SCALE) {
mController.gotoFullScreen();
}
}
@@ -468,6 +487,13 @@ public class FilmStripView extends ViewGroup {
}
}
+ private void adjustChildZOrder() {
+ for (int i = BUFFER_SIZE - 1; i >= 0; i--) {
+ if (mViewInfo[i] == null) continue;
+ bringChildToFront(mViewInfo[i].getView());
+ }
+ }
+
private void layoutChildren() {
if (mAnchorPending) {
mCenterX = mViewInfo[mCurrentInfo].getCenterX();
@@ -479,33 +505,58 @@ public class FilmStripView extends ViewGroup {
mScale = mController.getNewScale();
}
- adjustCenterX();
+ clampCenterX();
mViewInfo[mCurrentInfo].layoutIn(mDrawArea, mCenterX, mScale);
+ int currentViewLeft = mViewInfo[mCurrentInfo].getLeftPosition();
+ int currentViewCenter = mViewInfo[mCurrentInfo].getCenterX();
+ int fullScreenWidth = mDrawArea.width() + mViewGap;
+ float scaleFraction = mViewAnimInterpolator.getInterpolation(
+ (mScale - FILM_STRIP_SCALE) / (FULLSCREEN_SCALE - FILM_STRIP_SCALE));
+
// images on the left
for (int infoID = mCurrentInfo - 1; infoID >= 0; infoID--) {
ViewInfo curr = mViewInfo[infoID];
- if (curr != null) {
- ViewInfo next = mViewInfo[infoID + 1];
- curr.setLeftPosition(
- next.getLeftPosition() - curr.getView().getMeasuredWidth() - mViewGap);
- curr.layoutIn(mDrawArea, mCenterX, mScale);
- }
+ if (curr == null) continue;
+
+ ViewInfo next = mViewInfo[infoID + 1];
+ int myLeft =
+ next.getLeftPosition() - curr.getView().getMeasuredWidth() - mViewGap;
+ curr.setLeftPosition(myLeft);
+ curr.layoutIn(mDrawArea, mCenterX, mScale);
+ curr.getView().setAlpha(1f);
+ int infoDiff = mCurrentInfo - infoID;
+ curr.setTranslationX(
+ (currentViewCenter
+ - fullScreenWidth * infoDiff - curr.getCenterX()) * scaleFraction,
+ mScale);
}
// images on the right
for (int infoID = mCurrentInfo + 1; infoID < BUFFER_SIZE; infoID++) {
ViewInfo curr = mViewInfo[infoID];
- if (curr != null) {
- ViewInfo prev = mViewInfo[infoID - 1];
- curr.setLeftPosition(
- prev.getLeftPosition() + prev.getView().getMeasuredWidth() + mViewGap);
- curr.layoutIn(mDrawArea, mCenterX, mScale);
+ if (curr == null) continue;
+
+ ViewInfo prev = mViewInfo[infoID - 1];
+ int myLeft =
+ prev.getLeftPosition() + prev.getView().getMeasuredWidth() + mViewGap;
+ curr.setLeftPosition(myLeft);
+ curr.layoutIn(mDrawArea, mCenterX, mScale);
+ if (infoID == mCurrentInfo + 1) {
+ curr.getView().setAlpha(1f - scaleFraction);
+ } else {
+ if (scaleFraction == 0f) {
+ curr.getView().setAlpha(1f);
+ } else {
+ curr.getView().setAlpha(0f);
+ }
}
+ curr.setTranslationX((currentViewLeft - myLeft) * scaleFraction, mScale);
}
stepIfNeeded();
+ adjustChildZOrder();
invalidate();
}
@@ -760,13 +811,23 @@ public class FilmStripView extends ViewGroup {
});
}
- public boolean isInCameraFullscreen() {
- return (isAnchoredTo(0) && mScale == 1f
+ public boolean inFilmStrip() {
+ return (mScale == FILM_STRIP_SCALE);
+ }
+
+ public boolean inFullScreen() {
+ return (mScale == FULLSCREEN_SCALE);
+ }
+
+ public boolean inCameraFullscreen() {
+ return (isAnchoredTo(0) && inFullScreen()
&& getCurrentType() == ImageData.TYPE_CAMERA_PREVIEW);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
+ if (inFilmStrip()) return true;
+
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
mCheckToIntercept = true;
mDown = MotionEvent.obtain(ev);
@@ -995,13 +1056,22 @@ public class FilmStripView extends ViewGroup {
}
@Override
+ public void scroll(float deltaX) {
+ if (mController.isScrolling()) {
+ return;
+ }
+ mCenterX += deltaX;
+ }
+
+ @Override
public void fling(float velocityX) {
if (!stopScrolling() || mIsPositionLocked) return;
ViewInfo info = mViewInfo[mCurrentInfo];
if (info == null) return;
float scaledVelocityX = velocityX / mScale;
- if (isInCameraFullscreen() && scaledVelocityX < 0) {
+ if (inCameraFullscreen() && scaledVelocityX < 0) {
+ // Swipe left in camera preview.
gotoFilmStrip();
}
@@ -1038,6 +1108,7 @@ public class FilmStripView extends ViewGroup {
stopScrolling();
mScroller.startScroll(mCenterX, 0, position - mCenterX,
0, duration);
+ invalidate();
}
void scrollTo(int position, int duration) {
@@ -1051,6 +1122,7 @@ public class FilmStripView extends ViewGroup {
mScaleAnimator.setInterpolator(mDecelerateInterpolator);
mScaleAnimator.start();
mHasNewScale = true;
+ layoutChildren();
}
@Override
@@ -1064,6 +1136,14 @@ public class FilmStripView extends ViewGroup {
@Override
public void gotoFullScreen() {
+ if (mViewInfo[mCurrentInfo] != null) {
+ mController.scrollTo(mViewInfo[mCurrentInfo].getCenterX(),
+ DURATION_GEOMETRY_ADJUST, false);
+ }
+ enterFullScreen();
+ }
+
+ private void enterFullScreen() {
if (mListener != null) {
// TODO: After full size images snapping to fill the screen at the
// end of a scroll/fling is implemented, we should only make
@@ -1071,7 +1151,7 @@ public class FilmStripView extends ViewGroup {
// camera preview
mListener.onSwitchMode(true);
}
- if (mScale == 1f) return;
+ if (inFullScreen()) return;
scaleTo(1f, DURATION_GEOMETRY_ADJUST);
}
@@ -1104,9 +1184,9 @@ public class FilmStripView extends ViewGroup {
public void onAnimationEnd(Animator anim) {
ViewInfo info = mViewInfo[mCurrentInfo];
if (info != null && mCenterX == info.getCenterX()) {
- if (mScale == 1f) {
+ if (inFullScreen()) {
lockAtCurrentView();
- } else if (mScale == FILM_STRIP_SCALE) {
+ } else if (inFilmStrip()) {
unlockPosition();
}
}
@@ -1127,17 +1207,40 @@ public class FilmStripView extends ViewGroup {
@Override
public boolean onSingleTapUp(float x, float y) {
+ if (inFilmStrip()) {
+ for (int i = 0; i < BUFFER_SIZE; i++) {
+ if (mViewInfo[i] == null) continue;
+
+ if (mViewInfo[i].areaContains(x, y)) {
+ mController.scrollTo(mViewInfo[i].getCenterX(),
+ DURATION_GEOMETRY_ADJUST, false);
+ return true;
+ }
+ }
+ }
return false;
}
@Override
public boolean onDoubleTap(float x, float y) {
+ if (inFilmStrip()) {
+ ViewInfo centerInfo = mViewInfo[mCurrentInfo];
+ if (centerInfo != null && centerInfo.areaContains(x, y)) {
+ mController.gotoFullScreen();
+ return true;
+ }
+ } else if (inFullScreen()) {
+ mController.gotoFilmStrip();
+ return true;
+ }
return false;
}
@Override
public boolean onDown(float x, float y) {
- mController.stopScrolling();
+ if (mController.isScrolling()) {
+ mController.stopScrolling();
+ }
return true;
}
@@ -1172,36 +1275,43 @@ public class FilmStripView extends ViewGroup {
@Override
public boolean onScroll(float x, float y, float dx, float dy) {
- if (Math.abs(dx) > Math.abs(dy)) {
- int deltaX = (int) (dx / mScale);
- if (deltaX > 0 && isInCameraFullscreen()) {
- mController.gotoFilmStrip();
- }
- mCenterX += deltaX;
- } else {
- // Vertical part. Promote or demote.
- //int scaledDeltaY = (int) (dy * mScale);
- int hit = 0;
- Rect hitRect = new Rect();
- for (; hit < BUFFER_SIZE; hit++) {
- if (mViewInfo[hit] == null) continue;
- mViewInfo[hit].getView().getHitRect(hitRect);
- if (hitRect.contains((int) x, (int) y)) break;
- }
- if (hit == BUFFER_SIZE) return false;
+ int deltaX = (int) (dx / mScale);
+ if (inFilmStrip()) {
+ if (Math.abs(dx) > Math.abs(dy)) {
+ if (deltaX > 0 && inCameraFullscreen()) {
+ mController.gotoFilmStrip();
+ }
+ mController.scroll(deltaX);
+ } else {
+ // Vertical part. Promote or demote.
+ //int scaledDeltaY = (int) (dy * mScale);
+ int hit = 0;
+ Rect hitRect = new Rect();
+ for (; hit < BUFFER_SIZE; hit++) {
+ if (mViewInfo[hit] == null) continue;
+ mViewInfo[hit].getView().getHitRect(hitRect);
+ if (hitRect.contains((int) x, (int) y)) break;
+ }
+ if (hit == BUFFER_SIZE) return false;
- ImageData data = mDataAdapter.getImageData(mViewInfo[hit].getID());
- float transY = mViewInfo[hit].getTranslationY(mScale) - dy / mScale;
- if (!data.isUIActionSupported(ImageData.ACTION_DEMOTE) && transY > 0f) {
- transY = 0f;
+ ImageData data = mDataAdapter.getImageData(mViewInfo[hit].getID());
+ float transY = mViewInfo[hit].getTranslationY(mScale) - dy / mScale;
+ if (!data.isUIActionSupported(ImageData.ACTION_DEMOTE) && transY > 0f) {
+ transY = 0f;
+ }
+ if (!data.isUIActionSupported(ImageData.ACTION_PROMOTE) && transY < 0f) {
+ transY = 0f;
+ }
+ mViewInfo[hit].setTranslationY(transY, mScale);
}
- if (!data.isUIActionSupported(ImageData.ACTION_PROMOTE) && transY < 0f) {
- transY = 0f;
+ } else if (inFullScreen()) {
+ if (deltaX > 0 && inCameraFullscreen()) {
+ mController.gotoFilmStrip();
}
- mViewInfo[hit].setTranslationY(transY, mScale);
+ mController.scroll(deltaX);
}
-
layoutChildren();
+
return true;
}
@@ -1210,29 +1320,29 @@ public class FilmStripView extends ViewGroup {
if (Math.abs(velocityX) > Math.abs(velocityY)) {
mController.fling(velocityX);
} else {
- // ignore horizontal fling.
+ // ignore vertical fling.
}
return true;
}
@Override
public boolean onScaleBegin(float focusX, float focusY) {
- if (isInCameraFullscreen()) return false;
+ if (inCameraFullscreen()) return false;
mScaleTrend = 1f;
return true;
}
@Override
public boolean onScale(float focusX, float focusY, float scale) {
- if (isInCameraFullscreen()) return false;
+ if (inCameraFullscreen()) return false;
mScaleTrend = mScaleTrend * 0.3f + scale * 0.7f;
mScale *= scale;
if (mScale <= FILM_STRIP_SCALE) {
mScale = FILM_STRIP_SCALE;
}
- if (mScale >= MAX_SCALE) {
- mScale = MAX_SCALE;
+ if (mScale >= FULLSCREEN_SCALE) {
+ mScale = FULLSCREEN_SCALE;
}
layoutChildren();
return true;
@@ -1242,23 +1352,10 @@ public class FilmStripView extends ViewGroup {
public void onScaleEnd() {
if (mScaleTrend >= 1f) {
mController.gotoFullScreen();
- if (getCurrentType() == ImageData.TYPE_CAMERA_PREVIEW) {
- if (isAnchoredTo(0)) {
- mController.lockAtCurrentView();
- } else {
- mController.scrollTo(
- mViewInfo[mCurrentInfo].getCenterX(),
- DURATION_GEOMETRY_ADJUST, false);
- }
- }
} else {
- // Scale down to film strip mode.
- if (mScale == FILM_STRIP_SCALE) {
- mController.unlockPosition();
- } else {
- mController.gotoFilmStrip();
- }
+ mController.gotoFilmStrip();
}
+ mScaleTrend = 1f;
}
}
}
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index ebefa015f..7b226099d 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -49,7 +49,6 @@ public class ImagePreset {
private static final String LOGTAG = "ImagePreset";
- private FilterRepresentation mBorder = null;
public static final int STYLE_ICON = 3;
public static final String PRESET_NAME = "PresetName";
@@ -88,9 +87,6 @@ public class ImagePreset {
public ImagePreset(ImagePreset source) {
try {
- if (source.mBorder != null) {
- mBorder = source.mBorder.clone();
- }
for (int i = 0; i < source.mFilters.size(); i++) {
FilterRepresentation representation = source.mFilters.elementAt(i).clone();
addFilter(representation);
@@ -126,23 +122,25 @@ public class ImagePreset {
return -1;
}
+ private FilterRepresentation getFilterRepresentationForType(int type) {
+ for (int i = 0; i < mFilters.size(); i++) {
+ if (mFilters.elementAt(i).getFilterType() == type) {
+ return mFilters.elementAt(i);
+ }
+ }
+ return null;
+ }
+
public FilterRepresentation getFilterRepresentationCopyFrom(FilterRepresentation filterRepresentation) {
// TODO: add concept of position in the filters (to allow multiple instances)
if (filterRepresentation == null) {
return null;
}
- FilterRepresentation representation = null;
- if ((mBorder != null)
- && (mBorder.getFilterClass() == filterRepresentation.getFilterClass())) {
- // TODO: instead of special casing for border, we should correctly implements "filters priority set"
- representation = mBorder;
- } else {
- int position = getPositionForRepresentation(filterRepresentation);
- if (position == -1) {
- return null;
- }
- representation = mFilters.elementAt(position);
+ int position = getPositionForRepresentation(filterRepresentation);
+ if (position == -1) {
+ return null;
}
+ FilterRepresentation representation = mFilters.elementAt(position);
if (representation != null) {
try {
representation = representation.clone();
@@ -161,17 +159,12 @@ public class ImagePreset {
if (representation instanceof GeometryMetadata) {
setGeometry((GeometryMetadata) representation);
} else {
- if ((mBorder != null)
- && (mBorder.getFilterClass() == representation.getFilterClass())) {
- mBorder.updateTempParametersFrom(representation);
- } else {
- int position = getPositionForRepresentation(representation);
- if (position == -1) {
- return;
- }
- FilterRepresentation old = mFilters.elementAt(position);
- old.updateTempParametersFrom(representation);
+ int position = getPositionForRepresentation(representation);
+ if (position == -1) {
+ return;
}
+ FilterRepresentation old = mFilters.elementAt(position);
+ old.updateTempParametersFrom(representation);
}
}
MasterImage.getImage().invalidatePreview();
@@ -195,9 +188,6 @@ public class ImagePreset {
}
public boolean hasModifications() {
- if (mBorder != null && !mBorder.isNil()) {
- return true;
- }
if (mGeoData.hasModifications()) {
return true;
}
@@ -211,13 +201,14 @@ public class ImagePreset {
}
public boolean isPanoramaSafe() {
- if (mBorder != null && !mBorder.isNil()) {
- return false;
- }
if (mGeoData.hasModifications()) {
return false;
}
for (FilterRepresentation representation : mFilters) {
+ if (representation.getFilterType() == FilterRepresentation.TYPE_BORDER
+ && !representation.isNil()) {
+ return false;
+ }
if (representation.getFilterType() == FilterRepresentation.TYPE_VIGNETTE
&& !representation.isNil()) {
return false;
@@ -235,14 +226,6 @@ public class ImagePreset {
MasterImage.getImage().notifyGeometryChange();
}
- private void setBorder(FilterRepresentation filter) {
- mBorder = filter;
- }
-
- public void resetBorder() {
- mBorder = null;
- }
-
public boolean isFx() {
return mIsFxPreset;
}
@@ -305,14 +288,6 @@ public class ImagePreset {
return false;
}
- if (mDoApplyGeometry && mBorder != preset.mBorder) {
- return false;
- }
-
- if (mBorder != null && !mBorder.equals(preset.mBorder)) {
- return false;
- }
-
if (mDoApplyFilters != preset.mDoApplyFilters) {
if (mFilters.size() > 0 || preset.mFilters.size() > 0) {
return false;
@@ -381,17 +356,23 @@ public class ImagePreset {
public void removeFilter(FilterRepresentation filterRepresentation) {
if (filterRepresentation.getFilterType() == FilterRepresentation.TYPE_BORDER) {
- setBorder(null);
- setHistoryName("Remove");
- return;
- }
- for (int i = 0; i < mFilters.size(); i++) {
- if (mFilters.elementAt(i).getFilterClass() == filterRepresentation.getFilterClass()) {
- mFilters.remove(i);
- setHistoryName("Remove");
- return;
+ for (int i = 0; i < mFilters.size();i++) {
+ if (mFilters.elementAt(i).getFilterType()
+ == filterRepresentation.getFilterType()) {
+ mFilters.remove(i);
+ break;
+ }
+ }
+ } else {
+ for (int i = 0; i < mFilters.size(); i++) {
+ if (mFilters.elementAt(i).getFilterClass()
+ == filterRepresentation.getFilterClass()) {
+ mFilters.remove(i);
+ break;
+ }
}
}
+ setHistoryName("Remove");
}
public void addFilter(FilterRepresentation representation) {
@@ -400,8 +381,9 @@ public class ImagePreset {
return;
}
if (representation.getFilterType() == FilterRepresentation.TYPE_BORDER) {
+ removeFilter(representation);
+ mFilters.add(representation);
setHistoryName(representation.getName());
- setBorder(representation);
} else if (representation.getFilterType() == FilterRepresentation.TYPE_FX) {
boolean found = false;
for (int i = 0; i < mFilters.size(); i++) {
@@ -439,9 +421,6 @@ public class ImagePreset {
return representation;
}
}
- if (mBorder != null && mBorder.getFilterClass() == filterRepresentation.getFilterClass()) {
- return mBorder;
- }
return null;
}
@@ -466,12 +445,15 @@ public class ImagePreset {
}
public Bitmap applyBorder(Bitmap bitmap, FilterEnvironment environment) {
- if (mBorder != null && mDoApplyGeometry) {
- mBorder.synchronizeRepresentation();
- bitmap = environment.applyRepresentation(mBorder, bitmap);
+ // get the border from the list of filters.
+ FilterRepresentation border = getFilterRepresentationForType(
+ FilterRepresentation.TYPE_BORDER);
+ if (border != null && mDoApplyGeometry) {
+ border.synchronizeRepresentation();
+ bitmap = environment.applyRepresentation(border, bitmap);
if (environment.getQuality() == FilterEnvironment.QUALITY_FINAL) {
UsageStatistics.onEvent(UsageStatistics.COMPONENT_EDITOR,
- "SaveBorder", mBorder.getSerializationName(), 1);
+ "SaveBorder", border.getSerializationName(), 1);
}
}
return bitmap;
@@ -499,6 +481,11 @@ public class ImagePreset {
representation = mFilters.elementAt(i);
representation.synchronizeRepresentation();
}
+ if (representation.getFilterType() == FilterRepresentation.TYPE_BORDER) {
+ // for now, let's skip the border as it will be applied in applyBorder()
+ // TODO: might be worth getting rid of applyBorder.
+ continue;
+ }
bitmap = environment.applyRepresentation(representation, bitmap);
if (environment.getQuality() == FilterEnvironment.QUALITY_FINAL) {
UsageStatistics.onEvent(UsageStatistics.COMPONENT_EDITOR,
@@ -515,8 +502,10 @@ public class ImagePreset {
public void applyBorder(Allocation in, Allocation out,
boolean copyOut, FilterEnvironment environment) {
- if (mBorder != null && mDoApplyGeometry) {
- mBorder.synchronizeRepresentation();
+ FilterRepresentation border = getFilterRepresentationForType(
+ FilterRepresentation.TYPE_BORDER);
+ if (border != null && mDoApplyGeometry) {
+ border.synchronizeRepresentation();
// TODO: should keep the bitmap around
Allocation bitmapIn = in;
if (copyOut) {
@@ -524,7 +513,7 @@ public class ImagePreset {
CachingPipeline.getRenderScriptContext(), in.getType());
bitmapIn.copyFrom(out);
}
- environment.applyRepresentation(mBorder, bitmapIn, out);
+ environment.applyRepresentation(border, bitmapIn, out);
}
}
@@ -543,6 +532,10 @@ public class ImagePreset {
representation = mFilters.elementAt(i);
representation.synchronizeRepresentation();
}
+ if (representation.getFilterType() == FilterRepresentation.TYPE_BORDER) {
+ // for now, let's skip the border as it will be applied in applyBorder()
+ continue;
+ }
if (i > from) {
in.copyFrom(out);
}
@@ -555,9 +548,6 @@ public class ImagePreset {
if (mGeoData.hasModifications()) {
return false;
}
- if (mBorder != null && !mBorder.supportsPartialRendering()) {
- return false;
- }
if (ImageLoader.getZoomOrientation() != ImageLoader.ORI_NORMAL) {
return false;
}
@@ -589,11 +579,6 @@ public class ImagePreset {
state.setFilterRepresentation(filter);
states.add(state);
}
- if (mBorder != null) {
- State border = new State(mBorder.getName());
- border.setFilterRepresentation(mBorder);
- states.add(border);
- }
imageStateAdapter.fill(states);
}