summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java14
-rw-r--r--src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java1
-rw-r--r--src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java113
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java11
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java2
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java1
-rw-r--r--src/com/android/gallery3d/filtershow/ui/FilterIconButton.java6
-rw-r--r--src/com/android/gallery3d/filtershow/ui/ImageCurves.java2
-rw-r--r--src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java98
13 files changed, 133 insertions, 123 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index d7ec4c1..e2d3580 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -16,7 +16,6 @@
package com.android.gallery3d.filtershow;
-import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.app.ProgressDialog;
@@ -30,7 +29,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Point;
-import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
@@ -282,12 +280,14 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mPanelController.addPanel(mColorsButton, mListColors, 3);
Vector<FilterRepresentation> filtersRepresentations = new Vector<FilterRepresentation>();
- FiltersManager.addFilterRepresentations(filtersRepresentations);
+
+ FiltersManager filtersManager = FiltersManager.getManager();
+ filtersManager.addEffects(filtersRepresentations);
+
for (FilterRepresentation representation : filtersRepresentations) {
setupFilterRepresentationButton(representation, listColors, mColorsButton);
}
-
mPanelController.addView(findViewById(R.id.applyEffect));
findViewById(R.id.resetOperationsButton).setOnClickListener(
createOnClickResetOperationsButton());
@@ -775,6 +775,12 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mNullFxFilter = setupFilterRepresentationButton(nullFx, listFilters, mFxButton);
mNullFxFilter.setSelected(true);
+ Vector<FilterRepresentation> filtersRepresentations = new Vector<FilterRepresentation>();
+ FiltersManager.getManager().addLooks(filtersRepresentations);
+ for (FilterRepresentation representation : filtersRepresentations) {
+ setupFilterRepresentationButton(representation, listFilters, mFxButton);
+ }
+
for (int i = 0; i < p; i++) {
setupFilterRepresentationButton(fxArray[i], listFilters, mFxButton);
}
diff --git a/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java b/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
index b51d8b0..419abe8 100644
--- a/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
+++ b/src/com/android/gallery3d/filtershow/cache/FilteringPipeline.java
@@ -22,6 +22,7 @@ import android.os.Process;
import android.support.v8.renderscript.*;
import android.util.Log;
+import com.android.gallery3d.filtershow.filters.BaseFiltersManager;
import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilterRS;
import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
diff --git a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
new file mode 100644
index 0000000..43660d6
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
@@ -0,0 +1,113 @@
+/*
+ * 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.gallery3d.filtershow.filters;
+
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+public class BaseFiltersManager {
+
+ private static final String LOGTAG = "BaseFiltersManager";
+ private static HashMap<Class, ImageFilter> mFilters = new HashMap<Class, ImageFilter>();
+
+ protected BaseFiltersManager() {
+ Vector<ImageFilter> filters = new Vector<ImageFilter>();
+ addFilters(filters);
+ for (ImageFilter filter : filters) {
+ mFilters.put(filter.getClass(), filter);
+ }
+ }
+
+ protected void addFilters(Vector<ImageFilter> filters) {
+ filters.add(new ImageFilterTinyPlanet());
+ filters.add(new ImageFilterRedEye());
+ filters.add(new ImageFilterWBalance());
+ filters.add(new ImageFilterExposure());
+ filters.add(new ImageFilterVignette());
+ filters.add(new ImageFilterContrast());
+ filters.add(new ImageFilterShadows());
+ filters.add(new ImageFilterVibrance());
+ filters.add(new ImageFilterSharpen());
+ filters.add(new ImageFilterCurves());
+ filters.add(new ImageFilterDraw());
+ filters.add(new ImageFilterHue());
+ filters.add(new ImageFilterSaturated());
+ filters.add(new ImageFilterBwFilter());
+ filters.add(new ImageFilterNegative());
+ filters.add(new ImageFilterEdge());
+ filters.add(new ImageFilterKMeans());
+ filters.add(new ImageFilterFx());
+ filters.add(new ImageFilterBorder());
+ filters.add(new ImageFilterParametricBorder());
+ }
+
+ public ImageFilter getFilter(Class c) {
+ return mFilters.get(c);
+ }
+
+ public ImageFilter getFilterForRepresentation(FilterRepresentation representation) {
+ return mFilters.get(representation.getFilterClass());
+ }
+
+ public void addFilter(Class filterClass, ImageFilter filter) {
+ mFilters.put(filterClass, filter);
+ }
+
+ public FilterRepresentation getRepresentation(Class c) {
+ ImageFilter filter = mFilters.get(c);
+ if (filter != null) {
+ return filter.getDefaultRepresentation();
+ }
+ return null;
+ }
+
+ public void addLooks(Vector<FilterRepresentation> representations) {
+ // subclass can add representations
+ }
+
+ public void addEffects(Vector<FilterRepresentation> representations) {
+ representations.add(getRepresentation(ImageFilterTinyPlanet.class));
+ representations.add(getRepresentation(ImageFilterRedEye.class));
+ representations.add(getRepresentation(ImageFilterWBalance.class));
+ representations.add(getRepresentation(ImageFilterExposure.class));
+ representations.add(getRepresentation(ImageFilterVignette.class));
+ representations.add(getRepresentation(ImageFilterContrast.class));
+ representations.add(getRepresentation(ImageFilterShadows.class));
+ representations.add(getRepresentation(ImageFilterVibrance.class));
+ representations.add(getRepresentation(ImageFilterSharpen.class));
+ representations.add(getRepresentation(ImageFilterCurves.class));
+ representations.add(getRepresentation(ImageFilterDraw.class));
+ representations.add(getRepresentation(ImageFilterHue.class));
+ representations.add(getRepresentation(ImageFilterSaturated.class));
+ representations.add(getRepresentation(ImageFilterBwFilter.class));
+ representations.add(getRepresentation(ImageFilterNegative.class));
+ representations.add(getRepresentation(ImageFilterEdge.class));
+ representations.add(getRepresentation(ImageFilterKMeans.class));
+ }
+
+ public void resetBitmapsRS() {
+ for (Class c : mFilters.keySet()) {
+ ImageFilter filter = mFilters.get(c);
+ if (filter instanceof ImageFilterRS) {
+ ImageFilterRS filterRS = (ImageFilterRS) filter;
+ filterRS.resetBitmap();
+ }
+ }
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
index b2e1ed3..89ea5cc 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
@@ -50,7 +50,7 @@ public class FilterDrawRepresentation extends FilterRepresentation {
public FilterDrawRepresentation() {
super("Draw");
setFilterClass(ImageFilterDraw.class);
- setFilterType(FilterRepresentation.TYPE_VIGNETTE);
+ setPriority(FilterRepresentation.TYPE_VIGNETTE);
setTextId(R.string.imageDraw);
setButtonId(R.id.drawOnImageButton);
setEditorId(EditorDraw.ID);
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
index fa3fe72..859bf32 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterFxRepresentation.java
@@ -31,7 +31,7 @@ public class FilterFxRepresentation extends FilterRepresentation {
mBitmapResource = bitmapResource;
mNameResource = nameResource;
setFilterClass(ImageFilterFx.class);
- setFilterType(FilterRepresentation.TYPE_FX);
+ setPriority(FilterRepresentation.TYPE_FX);
setTextId(nameResource);
setEditorId(ImageOnlyEditor.ID);
setShowEditingControls(false);
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
index 38d3a69..2667cc8 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
@@ -31,7 +31,7 @@ public class FilterRedEyeRepresentation extends FilterRepresentation {
public FilterRedEyeRepresentation() {
super("RedEye");
setFilterClass(ImageFilterRedEye.class);
- setFilterType(FilterRepresentation.TYPE_NORMAL);
+ setPriority(FilterRepresentation.TYPE_NORMAL);
setButtonId(R.id.redEyeButton);
setTextId(R.string.redeye);
setEditorId(EditorRedEye.ID);
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index f282d29..2b6c3fe 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -23,7 +23,7 @@ import com.android.gallery3d.filtershow.presets.ImagePreset;
public class FilterRepresentation implements Cloneable {
private static final String LOGTAG = "FilterRepresentation";
private String mName;
- private int mPriority;
+ private int mPriority = TYPE_NORMAL;
private ImagePreset mPreset;
private Class mFilterClass;
private int mTextId = 0;
@@ -40,7 +40,6 @@ public class FilterRepresentation implements Cloneable {
public static final byte TYPE_VIGNETTE = 4;
public static final byte TYPE_NORMAL = 5;
public static final byte TYPE_TINYPLANET = 6;
- private byte filterType = TYPE_NORMAL;
public FilterRepresentation(String name) {
mName = name;
@@ -86,14 +85,6 @@ public class FilterRepresentation implements Cloneable {
return mName;
}
- public byte getFilterType() {
- return filterType;
- }
-
- protected void setFilterType(byte type) {
- filterType = type;
- }
-
public void setName(String name) {
mName = name;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
index 9bf2f0b..7b69ce9 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
@@ -27,7 +27,7 @@ public class FilterTinyPlanetRepresentation extends FilterBasicRepresentation {
super("TinyPlanet", 0, 50, 100);
setShowParameterValue(true);
setFilterClass(ImageFilterTinyPlanet.class);
- setFilterType(FilterRepresentation.TYPE_TINYPLANET);
+ setPriority(FilterRepresentation.TYPE_TINYPLANET);
setTextId(R.string.tinyplanet);
setButtonId(R.id.tinyplanetButton);
setEditorId(EditorTinyPlanet.ID);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
index e0bcfba..8b6dd54 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
@@ -30,7 +30,7 @@ public class ImageFilterWBalance extends ImageFilter {
public FilterRepresentation getDefaultRepresentation() {
FilterRepresentation representation = new FilterDirectRepresentation("WBalance");
representation.setFilterClass(ImageFilterWBalance.class);
- representation.setFilterType(FilterRepresentation.TYPE_WBALANCE);
+ representation.setPriority(FilterRepresentation.TYPE_WBALANCE);
representation.setTextId(R.string.wbalance);
representation.setButtonId(R.id.wbalanceButton);
representation.setShowEditingControls(false);
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index adea9de..b81659a 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -21,6 +21,7 @@ import android.util.Log;
import com.android.gallery3d.filtershow.ImageStateAdapter;
import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.filters.BaseFiltersManager;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilter;
diff --git a/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java b/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
index baf840f..de2e1e5 100644
--- a/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
+++ b/src/com/android/gallery3d/filtershow/ui/FilterIconButton.java
@@ -24,18 +24,12 @@ import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
-import com.android.gallery3d.app.Log;
-import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.PanelController;
-import com.android.gallery3d.filtershow.cache.FilteringPipeline;
import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.cache.RenderingRequest;
import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
-import com.android.gallery3d.filtershow.filters.FiltersManager;
-import com.android.gallery3d.filtershow.filters.ImageFilter;
import com.android.gallery3d.filtershow.imageshow.GeometryListener;
-import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
import com.android.gallery3d.filtershow.presets.ImagePreset;
diff --git a/src/com/android/gallery3d/filtershow/ui/ImageCurves.java b/src/com/android/gallery3d/filtershow/ui/ImageCurves.java
index ec2df6c..2e31db9 100644
--- a/src/com/android/gallery3d/filtershow/ui/ImageCurves.java
+++ b/src/com/android/gallery3d/filtershow/ui/ImageCurves.java
@@ -26,7 +26,6 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.os.AsyncTask;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
@@ -36,6 +35,7 @@ import android.widget.PopupMenu;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.editors.EditorCurves;
+import com.android.gallery3d.filtershow.filters.BaseFiltersManager;
import com.android.gallery3d.filtershow.filters.FilterCurvesRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilterCurves;
diff --git a/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java b/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
index 2a1a6da..988cf2d 100644
--- a/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
+++ b/src_pd/com/android/gallery3d/filtershow/filters/FiltersManager.java
@@ -16,39 +16,8 @@
package com.android.gallery3d.filtershow.filters;
-import com.android.gallery3d.filtershow.cache.ImageLoader;
-
-import java.util.HashMap;
-import java.util.Vector;
-
-public class FiltersManager {
-
- private static final String LOGTAG = "FiltersManager";
+public class FiltersManager extends BaseFiltersManager {
private static FiltersManager gInstance = null;
- private static HashMap<Class, ImageFilter> mFilters = new HashMap<Class, ImageFilter>();
-
- private FiltersManager() {
- Vector<ImageFilter> filters = new Vector<ImageFilter>();
- FiltersManager.addFilters(filters);
- filters.add(new ImageFilterFx());
- filters.add(new ImageFilterBorder());
- filters.add(new ImageFilterParametricBorder());
- for (ImageFilter filter : filters) {
- mFilters.put(filter.getClass(), filter);
- }
- }
-
- public ImageFilter getFilter(Class c) {
- return mFilters.get(c);
- }
-
- public ImageFilter getFilterForRepresentation(FilterRepresentation representation) {
- return mFilters.get(representation.getFilterClass());
- }
-
- public void addFilter(Class filterClass, ImageFilter filter) {
- mFilters.put(filterClass, filter);
- }
public static FiltersManager getManager() {
if (gInstance == null) {
@@ -56,69 +25,4 @@ public class FiltersManager {
}
return gInstance;
}
-
- public static FilterRepresentation getRepresentation(Class c) {
- ImageFilter filter = mFilters.get(c);
- if (filter != null) {
- return filter.getDefaultRepresentation();
- }
- return null;
- }
-
- public static void addFilterRepresentations(Vector<FilterRepresentation> representations) {
- representations.add(getRepresentation(ImageFilterTinyPlanet.class));
- representations.add(getRepresentation(ImageFilterRedEye.class));
- representations.add(getRepresentation(ImageFilterWBalance.class));
- representations.add(getRepresentation(ImageFilterExposure.class));
- representations.add(getRepresentation(ImageFilterVignette.class));
- representations.add(getRepresentation(ImageFilterContrast.class));
- representations.add(getRepresentation(ImageFilterShadows.class));
- representations.add(getRepresentation(ImageFilterVibrance.class));
- representations.add(getRepresentation(ImageFilterSharpen.class));
- representations.add(getRepresentation(ImageFilterCurves.class));
- representations.add(getRepresentation(ImageFilterDraw.class));
- representations.add(getRepresentation(ImageFilterHue.class));
- representations.add(getRepresentation(ImageFilterSaturated.class));
- representations.add(getRepresentation(ImageFilterBwFilter.class));
- representations.add(getRepresentation(ImageFilterNegative.class));
- representations.add(getRepresentation(ImageFilterEdge.class));
- representations.add(getRepresentation(ImageFilterKMeans.class));
- }
-
- public static void addFilters(Vector<ImageFilter> filters) {
- filters.add(new ImageFilterTinyPlanet());
- filters.add(new ImageFilterRedEye());
- filters.add(new ImageFilterWBalance());
- filters.add(new ImageFilterExposure());
- filters.add(new ImageFilterVignette());
- filters.add(new ImageFilterContrast());
- filters.add(new ImageFilterShadows());
- filters.add(new ImageFilterVibrance());
- filters.add(new ImageFilterSharpen());
- filters.add(new ImageFilterCurves());
- filters.add(new ImageFilterDraw());
- filters.add(new ImageFilterHue());
- filters.add(new ImageFilterSaturated());
- filters.add(new ImageFilterBwFilter());
- filters.add(new ImageFilterNegative());
- filters.add(new ImageFilterEdge());
- filters.add(new ImageFilterKMeans());
- }
-
- public static void addFilters(Vector<ImageFilter> filters, ImageLoader imageLoader) {
- FiltersManager.addFilters(filters);
- filters.add(new ImageFilterDownsample(imageLoader));
- FiltersManager.getManager().addFilter(ImageFilterDownsample.class,
- new ImageFilterDownsample(imageLoader));
- }
-
- public void resetBitmapsRS() {
- for (Class c : mFilters.keySet()) {
- ImageFilter filter = mFilters.get(c);
- if (filter instanceof ImageFilterRS) {
- ImageFilterRS filterRS = (ImageFilterRS) filter;
- filterRS.resetBitmap();
- }
- }
- }
}