summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java22
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java17
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java43
-rw-r--r--src/com/android/gallery3d/filtershow/category/Action.java13
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryView.java15
-rw-r--r--src/com/android/gallery3d/filtershow/editors/Editor.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java14
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java1
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java1
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java3
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/MasterImage.java14
-rw-r--r--src/com/android/gallery3d/filtershow/state/StateView.java80
13 files changed, 143 insertions, 84 deletions
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index ad757da9c..658abbbd4 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -538,27 +538,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
mSlotView.invalidate();
}
- private boolean canDoSlideShow() {
- if (mMediaSet == null) {
- return false;
- }
-
- final int[] count = new int[]{0};
- mMediaSet.enumerateMediaItems(new MediaSet.ItemConsumer() {
- @Override
- public void consume(int index, MediaItem item) {
- if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
- count[0]++;
- }
- }
- });
-
- if (count[0] < 2) { // you must have 2 pictures to go into slide show
- return false;
- }
- return true;
- }
-
@Override
protected boolean onCreateActionBar(Menu menu) {
GalleryActionBar actionBar = mActivity.getGalleryActionBar();
@@ -574,7 +553,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
FilterUtils.setupMenuItems(actionBar, mMediaSetPath, true);
- menu.findItem(R.id.action_slideshow).setVisible(canDoSlideShow());
menu.findItem(R.id.action_group_by).setVisible(mShowClusterMenu);
menu.findItem(R.id.action_camera).setVisible(
MediaSetUtils.isCameraSource(mMediaSetPath)
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 8f7b1ed73..e52e04491 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -777,33 +777,16 @@ public abstract class PhotoPage extends ActivityState implements
supportedOperations &= ~MediaObject.SUPPORT_EDIT;
}
}
-
MenuExecutor.updateMenuOperation(menu, supportedOperations);
}
private boolean canDoSlideShow() {
-
if (mMediaSet == null || mCurrentPhoto == null) {
return false;
}
if (mCurrentPhoto.getMediaType() != MediaObject.MEDIA_TYPE_IMAGE) {
return false;
}
- final int[] count = new int[]{0};
-
- mMediaSet.enumerateMediaItems(new MediaSet.ItemConsumer() {
- @Override
- public void consume(int index, MediaItem item) {
- if (item != null
- && item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
- count[0]++;
- }
- }
- });
-
- if (count[0] < 2) { // you must have 3 pictures to go into slide show
- return false;
- }
return true;
}
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index e17fda5a4..69c7c1058 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -90,6 +90,7 @@ import com.android.gallery3d.filtershow.editors.EditorRotate;
import com.android.gallery3d.filtershow.editors.EditorStraighten;
import com.android.gallery3d.filtershow.editors.EditorTinyPlanet;
import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
+import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation;
import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRotateRepresentation;
@@ -190,6 +191,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
private boolean mIsBound = false;
private Menu mMenu;
private DialogInterface mCurrentDialog = null;
+ private boolean mLoadingVisible = true;
public ProcessingService getProcessingService() {
return mBoundService;
@@ -473,8 +475,18 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
mCategoryGeometryAdapter.clear();
}
mCategoryGeometryAdapter = new CategoryAdapter(this);
+ boolean found = false;
for (FilterRepresentation representation : filtersRepresentations) {
mCategoryGeometryAdapter.add(new Action(this, representation));
+ if (representation instanceof FilterDrawRepresentation) {
+ found = true;
+ }
+ }
+ if (!found) {
+ FilterRepresentation representation = new FilterDrawRepresentation();
+ Action action = new Action(this, representation);
+ action.setIsDoubleAction(true);
+ mCategoryGeometryAdapter.add(action);
}
}
@@ -535,10 +547,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
}
private void startLoadBitmap(Uri uri) {
- final View loading = findViewById(R.id.loading);
final View imageShow = findViewById(R.id.imageShow);
imageShow.setVisibility(View.INVISIBLE);
- loading.setVisibility(View.VISIBLE);
+ startLoadingIndicator();
mShowingTinyPlanet = false;
mLoadBitmapTask = new LoadBitmapTask();
mLoadBitmapTask.execute(uri);
@@ -656,6 +667,18 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
FilterMirrorRepresentation r = (FilterMirrorRepresentation) representation;
r.cycle();
}
+ if (representation.isBooleanFilter()) {
+ ImagePreset preset = MasterImage.getImage().getPreset();
+ if (preset.getRepresentation(representation) != null) {
+ // remove
+ ImagePreset copy = new ImagePreset(preset);
+ copy.removeFilter(representation);
+ FilterRepresentation filterRepresentation = representation.copy();
+ MasterImage.getImage().setPreset(copy, filterRepresentation, true);
+ MasterImage.getImage().setCurrentFilterRepresentation(null);
+ return;
+ }
+ }
useFilterRepresentation(representation);
// show representation
@@ -732,9 +755,20 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
}
}
+ public boolean isLoadingVisible() {
+ return mLoadingVisible;
+ }
+
+ public void startLoadingIndicator() {
+ final View loading = findViewById(R.id.loading);
+ mLoadingVisible = true;
+ loading.setVisibility(View.VISIBLE);
+ }
+
public void stopLoadingIndicator() {
final View loading = findViewById(R.id.loading);
loading.setVisibility(View.GONE);
+ mLoadingVisible = false;
}
private class LoadBitmapTask extends AsyncTask<Uri, Boolean, Boolean> {
@@ -1201,7 +1235,11 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
+
setDefaultValues();
+ if (mMasterImage == null) {
+ return;
+ }
loadXML();
fillCategories();
loadMainPanel();
@@ -1226,7 +1264,6 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
mMasterImage.setHistoryManager(historyManager);
mMasterImage.setStateAdapter(imageStateAdapter);
mMasterImage.setActivity(this);
- mMasterImage.setFirstLoad(true);
if (Runtime.getRuntime().maxMemory() > LIMIT_SUPPORTS_HIGHRES) {
mMasterImage.setSupportsHighRes(true);
diff --git a/src/com/android/gallery3d/filtershow/category/Action.java b/src/com/android/gallery3d/filtershow/category/Action.java
index b3f35dab9..ef13ea53b 100644
--- a/src/com/android/gallery3d/filtershow/category/Action.java
+++ b/src/com/android/gallery3d/filtershow/category/Action.java
@@ -30,6 +30,7 @@ import android.widget.ListAdapter;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation;
import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation;
import com.android.gallery3d.filtershow.pipeline.RenderingRequest;
import com.android.gallery3d.filtershow.pipeline.RenderingRequestCaller;
@@ -55,6 +56,7 @@ public class Action implements RenderingRequestCaller {
private FilterShowActivity mContext;
private boolean mCanBeRemoved = false;
private int mTextSize = 32;
+ private boolean mIsDoubleAction = false;
public Action(FilterShowActivity context, FilterRepresentation representation, int type,
boolean canBeRemoved) {
@@ -79,6 +81,14 @@ public class Action implements RenderingRequestCaller {
this(context, representation, CROP_VIEW);
}
+ public boolean isDoubleAction() {
+ return mIsDoubleAction;
+ }
+
+ public void setIsDoubleAction(boolean value) {
+ mIsDoubleAction = value;
+ }
+
public boolean canBeRemoved() {
return mCanBeRemoved;
}
@@ -94,6 +104,9 @@ public class Action implements RenderingRequestCaller {
public void setRepresentation(FilterRepresentation representation) {
mRepresentation = representation;
mName = representation.getName();
+ if (mRepresentation instanceof FilterDrawRepresentation) {
+ setIsDoubleAction(true);
+ }
}
public String getName() {
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryView.java b/src/com/android/gallery3d/filtershow/category/CategoryView.java
index 22c50fd96..8dfe92f49 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryView.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryView.java
@@ -49,6 +49,8 @@ public class CategoryView extends IconView
private int mSelectionColor = Color.WHITE;
private int mSpacerColor = Color.WHITE;
private boolean mCanBeRemoved = false;
+ private long mDoubleActionLast = 0;
+ private long mDoubleTapDelay = 150;
public CategoryView(Context context) {
super(context);
@@ -109,6 +111,9 @@ public class CategoryView extends IconView
drawSpacer(canvas);
return;
}
+ if (mAction.isDoubleAction()) {
+ return;
+ }
mAction.setImageFrame(new Rect(0, 0, getWidth(), getHeight()), getOrientation());
if (mAction.getImage() != null) {
setBitmap(mAction.getImage());
@@ -145,7 +150,15 @@ public class CategoryView extends IconView
if (mAction.getType() == Action.ADD_ACTION) {
activity.addNewPreset();
} else if (mAction.getType() != Action.SPACER) {
- activity.showRepresentation(mAction.getRepresentation());
+ if (mAction.isDoubleAction()) {
+ long current = System.currentTimeMillis() - mDoubleActionLast;
+ if (current < mDoubleTapDelay) {
+ activity.showRepresentation(mAction.getRepresentation());
+ }
+ mDoubleActionLast = System.currentTimeMillis();
+ } else {
+ activity.showRepresentation(mAction.getRepresentation());
+ }
mAdapter.setSelected(this);
}
}
diff --git a/src/com/android/gallery3d/filtershow/editors/Editor.java b/src/com/android/gallery3d/filtershow/editors/Editor.java
index 59ad1b6a6..5f8e8f6f6 100644
--- a/src/com/android/gallery3d/filtershow/editors/Editor.java
+++ b/src/com/android/gallery3d/filtershow/editors/Editor.java
@@ -285,7 +285,7 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
protected void setMenuIcon(boolean on) {
mEditTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(
- 0, 0, 0, on ? R.drawable.filtershow_menu_marker : 0);
+ 0, 0, on ? R.drawable.filtershow_menu_marker : 0, 0);
}
protected void createMenu(int[] strId, View button) {
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index cc7ec881e..fc83e4f8c 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -38,6 +38,7 @@ public class FilterRepresentation {
private int mOverlayId = 0;
private boolean mOverlayOnly = false;
private boolean mShowParameterValue = true;
+ private boolean mIsBooleanFilter = false;
private String mSerializationName;
public static final byte TYPE_BORDER = 1;
public static final byte TYPE_FX = 2;
@@ -69,7 +70,7 @@ public class FilterRepresentation {
representation.setOverlayOnly(getOverlayOnly());
representation.setShowParameterValue(showParameterValue());
representation.mSerializationName = mSerializationName;
-
+ representation.setIsBooleanFilter(isBooleanFilter());
}
public boolean equals(FilterRepresentation representation) {
@@ -87,12 +88,21 @@ public class FilterRepresentation {
&& representation.mButtonId == mButtonId
&& representation.mOverlayId == mOverlayId
&& representation.mOverlayOnly == mOverlayOnly
- && representation.mShowParameterValue == mShowParameterValue) {
+ && representation.mShowParameterValue == mShowParameterValue
+ && representation.mIsBooleanFilter == mIsBooleanFilter) {
return true;
}
return false;
}
+ public boolean isBooleanFilter() {
+ return mIsBooleanFilter;
+ }
+
+ public void setIsBooleanFilter(boolean value) {
+ mIsBooleanFilter = value;
+ }
+
@Override
public String toString() {
return mName;
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java
index 2e362f8b5..d316adeed 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterVignetteRepresentation.java
@@ -43,7 +43,7 @@ public class FilterVignetteRepresentation extends FilterRepresentation implement
private static int MAX = 100;
private static int MAXFALLOF = 200;
- private BasicParameterInt mParamVignette = new BasicParameterInt(MODE_VIGNETTE, 0, MIN, MAX);
+ private BasicParameterInt mParamVignette = new BasicParameterInt(MODE_VIGNETTE, 50, MIN, MAX);
private BasicParameterInt mParamExposure = new BasicParameterInt(MODE_EXPOSURE, 0, MIN, MAX);
private BasicParameterInt mParamSaturation = new BasicParameterInt(MODE_SATURATION, 0, MIN, MAX);
private BasicParameterInt mParamContrast = new BasicParameterInt(MODE_CONTRAST, 0, MIN, MAX);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java
index 98497596b..9a1a84030 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java
@@ -19,6 +19,7 @@ public class ImageFilterNegative extends ImageFilter {
representation.setShowParameterValue(false);
representation.setEditorId(ImageOnlyEditor.ID);
representation.setSupportsPartialRendering(true);
+ representation.setIsBooleanFilter(true);
return representation;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
index 6bb88ec21..7aa19a4a9 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
@@ -38,6 +38,7 @@ public class ImageFilterWBalance extends ImageFilter {
representation.setShowParameterValue(false);
representation.setEditorId(ImageOnlyEditor.ID);
representation.setSupportsPartialRendering(true);
+ representation.setIsBooleanFilter(true);
return representation;
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index 281f19d23..3a799ef5d 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -243,11 +243,10 @@ public class ImageShow extends View implements OnGestureListener,
MasterImage img = MasterImage.getImage();
// Hide the loading indicator as needed
- if (img.isFirstLoad() && getFilteredImage() != null) {
+ if (mActivity.isLoadingVisible() && getFilteredImage() != null) {
if ((img.getLoadedPreset() == null)
|| (img.getLoadedPreset() != null
&& img.getLoadedPreset().equals(img.getCurrentPreset()))) {
- img.setFirstLoad(false);
mActivity.stopLoadingIndicator();
} else if (img.getLoadedPreset() != null) {
return;
diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
index 61d32b1ca..6c7bf3a28 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
@@ -117,8 +117,6 @@ public class MasterImage implements RenderingRequestCaller {
private List<ExifTag> mEXIF;
private BitmapCache mBitmapCache = new BitmapCache();
- private boolean mFirstLoad;
-
private MasterImage() {
}
@@ -134,14 +132,6 @@ public class MasterImage implements RenderingRequestCaller {
return sMasterImage;
}
- public void setFirstLoad(boolean firstLoad) {
- mFirstLoad = firstLoad;
- }
-
- public boolean isFirstLoad() {
- return mFirstLoad;
- }
-
public Bitmap getOriginalBitmapSmall() {
return mOriginalBitmapSmall;
}
@@ -559,9 +549,7 @@ public class MasterImage implements RenderingRequestCaller {
if (mPreset == null) {
return;
}
- if (mPreset.nbFilters() == 0) {
- MasterImage.getImage().setFirstLoad(false);
- }
+
mPreviewPreset.enqueuePreset(mPreset);
mPreviewBuffer.invalidate();
invalidatePartialPreview();
diff --git a/src/com/android/gallery3d/filtershow/state/StateView.java b/src/com/android/gallery3d/filtershow/state/StateView.java
index 73d57846a..56c97ab62 100644
--- a/src/com/android/gallery3d/filtershow/state/StateView.java
+++ b/src/com/android/gallery3d/filtershow/state/StateView.java
@@ -19,17 +19,17 @@ package com.android.gallery3d.filtershow.state;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.*;
-import android.util.AttributeSet;
-import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewParent;
import android.widget.LinearLayout;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.category.SwipableView;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.pipeline.ImagePreset;
-public class StateView extends View {
+public class StateView extends View implements SwipableView {
private static final String LOGTAG = "StateView";
private Path mPath = new Path();
@@ -51,6 +51,10 @@ public class StateView extends View {
private static int sMargin = 16;
private static int sArrowHeight = 16;
private static int sArrowWidth = 8;
+ private float mStartTouchX = 0;
+ private float mStartTouchY = 0;
+ private float mDeleteSlope = 20;
+
private int mOrientation = LinearLayout.VERTICAL;
private int mDirection = DOWN;
private boolean mDuplicateButton;
@@ -104,24 +108,6 @@ public class StateView extends View {
invalidate();
}
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
- ViewParent parent = getParent();
- if (parent instanceof PanelTrack) {
- ((PanelTrack) getParent()).onTouch(event, this);
- }
- if (mType == BEGIN) {
- MasterImage.getImage().setShowsOriginal(true);
- }
- }
- if (event.getActionMasked() == MotionEvent.ACTION_UP
- || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
- MasterImage.getImage().setShowsOriginal(false);
- }
- return true;
- }
-
public void drawText(Canvas canvas) {
if (mText == null) {
return;
@@ -288,4 +274,54 @@ public class StateView extends View {
public boolean isDraggable() {
return mState.isDraggable();
}
+
+ @Override
+ public void delete() {
+ FilterShowActivity activity = (FilterShowActivity) getContext();
+ FilterRepresentation representation = getState().getFilterRepresentation();
+ activity.removeFilterRepresentation(representation);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ boolean ret = super.onTouchEvent(event);
+ FilterShowActivity activity = (FilterShowActivity) getContext();
+
+ if (event.getActionMasked() == MotionEvent.ACTION_UP) {
+ activity.startTouchAnimation(this, event.getX(), event.getY());
+ }
+ if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ mStartTouchY = event.getY();
+ mStartTouchX = event.getX();
+ if (mType == BEGIN) {
+ MasterImage.getImage().setShowsOriginal(true);
+ }
+ }
+ if (event.getActionMasked() == MotionEvent.ACTION_UP
+ || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
+ setTranslationX(0);
+ setTranslationY(0);
+ MasterImage.getImage().setShowsOriginal(false);
+ if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_UP) {
+ setSelected(true);
+ FilterRepresentation representation = getState().getFilterRepresentation();
+ MasterImage image = MasterImage.getImage();
+ ImagePreset preset = image != null ? image.getCurrentPreset() : null;
+ if (getTranslationY() == 0
+ && image != null && preset != null
+ && representation != image.getCurrentFilterRepresentation()
+ && preset.getRepresentation(representation) != null) {
+ activity.showRepresentation(representation);
+ setSelected(false);
+ }
+ }
+ }
+ if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_MOVE) {
+ float delta = event.getY() - mStartTouchY;
+ if (Math.abs(delta) > mDeleteSlope) {
+ activity.setHandlesSwipeForView(this, mStartTouchX, mStartTouchY);
+ }
+ }
+ return true;
+ }
}