summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/editors
diff options
context:
space:
mode:
authorJohn Hoford <hoford@google.com>2013-03-11 11:10:22 -0700
committerJohn Hoford <hoford@google.com>2013-03-11 14:22:57 -0700
commit887bde65742747aea7ab6dcf7c300ca8ec1f1ebf (patch)
tree0b838d6082f342154cdc55f625ad993cb43533af /src/com/android/gallery3d/filtershow/editors
parentb1aeb3963fb67b1ea251cb5f7790b2d2f8261a0c (diff)
downloadandroid_packages_apps_Snap-887bde65742747aea7ab6dcf7c300ca8ec1f1ebf.tar.gz
android_packages_apps_Snap-887bde65742747aea7ab6dcf7c300ca8ec1f1ebf.tar.bz2
android_packages_apps_Snap-887bde65742747aea7ab6dcf7c300ca8ec1f1ebf.zip
refactoring to make Editor classes do more
Change-Id: Id0885929cf3a9410bd0e5d3bf96eb99e8c7e1cf9
Diffstat (limited to 'src/com/android/gallery3d/filtershow/editors')
-rw-r--r--src/com/android/gallery3d/filtershow/editors/BasicEditor.java6
-rw-r--r--src/com/android/gallery3d/filtershow/editors/Editor.java70
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorCurves.java1
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorStraighten.java11
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java3
5 files changed, 84 insertions, 7 deletions
diff --git a/src/com/android/gallery3d/filtershow/editors/BasicEditor.java b/src/com/android/gallery3d/filtershow/editors/BasicEditor.java
index fb09101a6..2ff9c0449 100644
--- a/src/com/android/gallery3d/filtershow/editors/BasicEditor.java
+++ b/src/com/android/gallery3d/filtershow/editors/BasicEditor.java
@@ -28,9 +28,9 @@ import com.android.gallery3d.filtershow.filters.FilterBasicRepresentation;
/**
* The basic editor that all the one parameter filters
*/
-public class BasicEditor extends Editor implements OnSeekBarChangeListener {
+public class BasicEditor extends Editor {
public static int ID = R.id.basicEditor;
- private SeekBar mSeekBar;
+
private final String LOGTAG = "Editor";
private int mLayoutID = R.layout.filtershow_default_editor;
private int mViewID = R.id.basicEditor;
@@ -53,8 +53,6 @@ public class BasicEditor extends Editor implements OnSeekBarChangeListener {
public void createEditor(Context context, FrameLayout frameLayout) {
super.createEditor(context, frameLayout);
unpack(mViewID, mLayoutID);
- mSeekBar = (SeekBar) mView.findViewById(R.id.filterSeekBar);
- mSeekBar.setOnSeekBarChangeListener(this);
}
@Override
diff --git a/src/com/android/gallery3d/filtershow/editors/Editor.java b/src/com/android/gallery3d/filtershow/editors/Editor.java
index bea591c63..cefdfe6bf 100644
--- a/src/com/android/gallery3d/filtershow/editors/Editor.java
+++ b/src/com/android/gallery3d/filtershow/editors/Editor.java
@@ -17,12 +17,18 @@
package com.android.gallery3d.filtershow.editors;
import android.content.Context;
+import android.text.Html;
import android.view.LayoutInflater;
+import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
+import android.widget.PopupMenu;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.PanelController;
import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
@@ -33,27 +39,66 @@ import com.android.gallery3d.filtershow.presets.ImagePreset;
/**
* Base class for Editors Must contain a mImageShow and a top level view
*/
-public class Editor {
+public class Editor implements OnSeekBarChangeListener {
protected Context mContext;
protected View mView;
protected ImageShow mImageShow;
protected FrameLayout mFrameLayout;
+ protected SeekBar mSeekBar;
protected PanelController mPanelController;
protected int mID;
private final String LOGTAG = "Editor";
protected FilterRepresentation mLocalRepresentation = null;
+ protected byte mShowParameter = SHOW_VALUE_UNDEFINED;
+ public static byte SHOW_VALUE_UNDEFINED = -1;
+ public static byte SHOW_VALUE_OFF = 0;
+ public static byte SHOW_VALUE_INT = 1;
public void setPanelController(PanelController panelController) {
this.mPanelController = panelController;
}
+ public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
+ String apply = context.getString(R.string.apply_effect);
+ if (mShowParameter == SHOW_VALUE_INT) {
+ apply += " " + effectName + " " + parameterValue;
+ } else {
+ apply += " " + effectName;
+ }
+ return apply;
+ }
+
protected Editor(int id) {
mID = id;
}
+
public int getID() {
return mID;
}
+
+ public byte showParameterValue() {
+ return mShowParameter;
+ }
+
+ /**
+ * @param actionButton the would be the area for menu etc
+ * @param editControl this is the black area for sliders etc
+ */
+ public void setUtilityPanelUI(View actionButton, View editControl) {
+ mSeekBar = (SeekBar) editControl.findViewById(R.id.primarySeekBar);
+ mSeekBar.setOnSeekBarChangeListener(this);
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar sbar, int progress, boolean arg2) {
+
+ }
+
+ public void setPanel() {
+
+ }
+
public void createEditor(Context context,FrameLayout frameLayout) {
mContext = context;
mFrameLayout = frameLayout;
@@ -115,7 +160,12 @@ public class Editor {
ImagePreset preset = MasterImage.getImage().getPreset();
FilterRepresentation filterRepresentation = MasterImage.getImage().getCurrentFilterRepresentation();
mLocalRepresentation = preset.getFilterRepresentationCopyFrom(filterRepresentation);
+ if (mShowParameter == SHOW_VALUE_UNDEFINED) {
+ boolean show = filterRepresentation.showParameterValue();
+ mShowParameter = show ? SHOW_VALUE_INT : SHOW_VALUE_OFF;
+ }
}
+
return mLocalRepresentation;
}
@@ -144,4 +194,22 @@ public class Editor {
}
}
+ protected void createMenu(int[] strId, View button) {
+ PopupMenu pmenu = new PopupMenu(mContext, button);
+ Menu menu = pmenu.getMenu();
+ for (int i = 0; i < strId.length; i++) {
+ menu.add(Menu.NONE, Menu.FIRST + i, 0, mContext.getString(strId[i]));
+ }
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar arg0) {
+
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar arg0) {
+
+ }
+
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorCurves.java b/src/com/android/gallery3d/filtershow/editors/EditorCurves.java
index b6e7b2bd7..be35b9723 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorCurves.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorCurves.java
@@ -27,6 +27,7 @@ import com.android.gallery3d.filtershow.ui.ImageCurves;
public class EditorCurves extends Editor {
public static final int ID = R.id.imageCurves;
ImageCurves mImageCurves;
+
public EditorCurves() {
super(ID);
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java b/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java
index 46419704b..2dbab7ab9 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java
@@ -20,15 +20,26 @@ import android.content.Context;
import android.widget.FrameLayout;
import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
import com.android.gallery3d.filtershow.imageshow.ImageStraighten;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
public class EditorStraighten extends Editor implements EditorInfo {
public static final int ID = R.id.editorStraighten;
ImageStraighten mImageStraighten;
+ GeometryMetadata mGeometryMetadata;
public EditorStraighten() {
super(ID);
+ mShowParameter = SHOW_VALUE_INT;
+ }
+
+ // TODO use filter reflection like
+ @Override
+ public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
+ String apply = context.getString(R.string.apply_effect);
+ apply += " " + effectName + " " + parameterValue;
+ return apply;
}
@Override
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java b/src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java
index c0fcdffd6..4b005c459 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorTinyPlanet.java
@@ -43,9 +43,8 @@ public class EditorTinyPlanet extends BasicEditor {
@Override
public void reflectCurrentFilter() {
super.reflectCurrentFilter();
-
FilterRepresentation rep = getLocalRepresentation();
- if (rep != null && getLocalRepresentation() instanceof FilterTinyPlanetRepresentation) {
+ if (rep != null && rep instanceof FilterTinyPlanetRepresentation) {
FilterTinyPlanetRepresentation drawRep = (FilterTinyPlanetRepresentation) rep;
mImageTinyPlanet.setRepresentation(drawRep);
}