Merge "add flexable ui for parameters" into gb-ub-photos-bryce
diff --git a/src/com/android/gallery3d/filtershow/PanelController.java b/src/com/android/gallery3d/filtershow/PanelController.java
index 8352032..6b20fe1 100644
--- a/src/com/android/gallery3d/filtershow/PanelController.java
+++ b/src/com/android/gallery3d/filtershow/PanelController.java
@@ -151,7 +151,7 @@
private final View mView;
private final LinearLayout mAccessoryViewList;
private Vector<View> mAccessoryViews = new Vector<View>();
- private final TextView mTextView;
+ private final Button mTextView;
private boolean mSelected = false;
private String mEffectName = null;
private int mParameterValue = 0;
@@ -160,10 +160,9 @@
public UtilityPanel(Context context, View utilityPanel) {
mView = utilityPanel;
View accessoryViewList = mView.findViewById(R.id.panelAccessoryViewList);
- Button textView = (Button) mView.findViewById(R.id.applyEffect);
+ mTextView = (Button) mView.findViewById(R.id.applyEffect);
mContext = context;
mAccessoryViewList = (LinearLayout) accessoryViewList;
- mTextView = (TextView) textView;
}
public boolean selected() {
@@ -212,6 +211,16 @@
public View getEditControl() {
return mView.findViewById(R.id.controlArea);
}
+
+ public void removeControlChildren() {
+ LinearLayout controlArea = (LinearLayout) mView.findViewById(R.id.controlArea);
+ controlArea.removeAllViews();
+ }
+
+ public Button getEditTitle() {
+ return mTextView;
+ }
+
public void updateText() {
String s;
if (mCurrentEditor == null) {
@@ -589,8 +598,10 @@
if (mEditorPlaceHolder.contains(representation.getEditorId())) {
mCurrentEditor = mEditorPlaceHolder.showEditor(
representation.getEditorId());
- mCurrentEditor.setUtilityPanelUI(
- mUtilityPanel.getActionControl(), mUtilityPanel.getEditControl());
+ mUtilityPanel.removeControlChildren();
+ mCurrentEditor.setUpEditorUI(
+ mUtilityPanel.getActionControl(), mUtilityPanel.getEditControl(),
+ mUtilityPanel.getEditTitle());
mCurrentImage = mCurrentEditor.getImageShow();
mCurrentEditor.setPanelController(this);
diff --git a/src/com/android/gallery3d/filtershow/controller/ActionSlider.java b/src/com/android/gallery3d/filtershow/controller/ActionSlider.java
new file mode 100644
index 0000000..6ed2467
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/ActionSlider.java
@@ -0,0 +1,56 @@
+/*
+ * 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.controller;
+
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.ImageButton;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.Editor;
+
+public class ActionSlider extends TitledSlider {
+ private static final String LOGTAG = "ActionSlider";
+ ImageButton mActionButton;
+ public ActionSlider() {
+ mLayoutID = R.layout.filtershow_control_action_slider;
+ }
+
+ @Override
+ public void setUp(ViewGroup container, Parameter parameter, Editor editor) {
+ super.setUp(container, parameter, editor);
+ mActionButton = (ImageButton) mTopView.findViewById(R.id.actionButton);
+ mActionButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ ((ParameterActionAndInt) mParameter).fireAction();
+ }
+ });
+ }
+
+ @Override
+ public void updateUI() {
+ super.updateUI();
+ if (mActionButton != null) {
+ int iconId = ((ParameterActionAndInt) mParameter).getActionIcon();
+ mActionButton.setImageResource(iconId);
+ }
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/BasicSlider.java b/src/com/android/gallery3d/filtershow/controller/BasicSlider.java
new file mode 100644
index 0000000..c54fe77
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/BasicSlider.java
@@ -0,0 +1,87 @@
+/*
+ * 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.controller;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.Editor;
+
+public class BasicSlider implements Control {
+ private SeekBar mSeekBar;
+ private ParameterInteger mParameter;
+ Editor mEditor;
+
+ @Override
+ public void setUp(ViewGroup container, Parameter parameter, Editor editor) {
+ mEditor = editor;
+ Context context = container.getContext();
+ mParameter = (ParameterInteger) parameter;
+ LayoutInflater inflater =
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout lp = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_seekbar, container, true);
+ mSeekBar = (SeekBar) lp.findViewById(R.id.primarySeekBar);
+
+ updateUI();
+ mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ if (mParameter != null) {
+ mParameter.setValue(progress + mParameter.getMinimum());
+ mEditor.commitLocalRepresentation();
+
+ }
+ }
+ });
+ }
+
+ @Override
+ public View getTopView() {
+ return mSeekBar;
+ }
+
+ @Override
+ public void setPrameter(Parameter parameter) {
+ mParameter = (ParameterInteger) parameter;
+ if (mSeekBar != null) {
+ updateUI();
+ }
+ }
+
+ @Override
+ public void updateUI() {
+ mSeekBar.setMax(mParameter.getMaximum() - mParameter.getMinimum());
+ mSeekBar.setProgress(mParameter.getValue() - mParameter.getMinimum());
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/Control.java b/src/com/android/gallery3d/filtershow/controller/Control.java
new file mode 100644
index 0000000..4342290
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/Control.java
@@ -0,0 +1,32 @@
+/*
+ * 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.controller;
+
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.android.gallery3d.filtershow.editors.Editor;
+
+public interface Control {
+ public void setUp(ViewGroup container, Parameter parameter, Editor editor);
+
+ public View getTopView();
+
+ public void setPrameter(Parameter parameter);
+
+ public void updateUI();
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/Parameter.java b/src/com/android/gallery3d/filtershow/controller/Parameter.java
new file mode 100644
index 0000000..1e8694a
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/Parameter.java
@@ -0,0 +1,27 @@
+/*
+ * 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.controller;
+
+public interface Parameter {
+ String getParameterName();
+
+ String getParameterType();
+
+ String getValueString();
+
+ public void setController(Control c);
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/ParameterActionAndInt.java b/src/com/android/gallery3d/filtershow/controller/ParameterActionAndInt.java
new file mode 100644
index 0000000..04567e2
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/ParameterActionAndInt.java
@@ -0,0 +1,25 @@
+/*
+ * 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.controller;
+
+public interface ParameterActionAndInt extends ParameterInteger {
+ static String sParameterType = "ParameterActionAndInt";
+
+ public void fireAction();
+
+ public int getActionIcon();
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/ParameterInteger.java b/src/com/android/gallery3d/filtershow/controller/ParameterInteger.java
new file mode 100644
index 0000000..0bfd201
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/ParameterInteger.java
@@ -0,0 +1,31 @@
+/*
+ * 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.controller;
+
+public interface ParameterInteger extends Parameter {
+ static String sParameterType = "ParameterInteger";
+
+ int getMaximum();
+
+ int getMinimum();
+
+ int getDefaultValue();
+
+ int getValue();
+
+ void setValue(int value);
+}
diff --git a/src/com/android/gallery3d/filtershow/controller/TitledSlider.java b/src/com/android/gallery3d/filtershow/controller/TitledSlider.java
new file mode 100644
index 0000000..30b6fdb
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/controller/TitledSlider.java
@@ -0,0 +1,105 @@
+/*
+ * 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.controller;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.editors.Editor;
+
+public class TitledSlider implements Control {
+ private final String LOGTAG = "ParametricEditor";
+ private SeekBar mSeekBar;
+ private TextView mControlName;
+ private TextView mControlValue;
+ protected ParameterInteger mParameter;
+ Editor mEditor;
+ View mTopView;
+ protected int mLayoutID = R.layout.filtershow_control_title_slider;
+
+ @Override
+ public void setUp(ViewGroup container, Parameter parameter, Editor editor) {
+ mEditor = editor;
+ Context context = container.getContext();
+ mParameter = (ParameterInteger) parameter;
+ LayoutInflater inflater =
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ mTopView = inflater.inflate(mLayoutID, container, true);
+ mTopView.setVisibility(View.VISIBLE);
+ mSeekBar = (SeekBar) mTopView.findViewById(R.id.controlValueSeekBar);
+ mControlName = (TextView) mTopView.findViewById(R.id.controlName);
+ mControlValue = (TextView) mTopView.findViewById(R.id.controlValue);
+ updateUI();
+ mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ if (mParameter != null) {
+ mParameter.setValue(progress + mParameter.getMinimum());
+ if (mControlName != null) {
+ mControlName.setText(mParameter.getParameterName());
+ }
+ if (mControlValue != null) {
+ mControlValue.setText(Integer.toString(mParameter.getValue()));
+ }
+ mEditor.commitLocalRepresentation();
+ }
+ }
+ });
+ }
+
+ @Override
+ public void setPrameter(Parameter parameter) {
+ mParameter = (ParameterInteger) parameter;
+ if (mSeekBar != null)
+ updateUI();
+ }
+
+ @Override
+ public void updateUI() {
+ if (mControlName != null) {
+ mControlName.setText(mParameter.getParameterName());
+ }
+ if (mControlValue != null) {
+ mControlValue.setText(
+ Integer.toString(mParameter.getValue()));
+ }
+ mSeekBar.setMax(mParameter.getMaximum() - mParameter.getMinimum());
+ mSeekBar.setProgress(mParameter.getValue() - mParameter.getMinimum());
+ mEditor.commitLocalRepresentation();
+ }
+
+ @Override
+ public View getTopView() {
+ return mTopView;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/Editor.java b/src/com/android/gallery3d/filtershow/editors/Editor.java
index 69266ff..013590c 100644
--- a/src/com/android/gallery3d/filtershow/editors/Editor.java
+++ b/src/com/android/gallery3d/filtershow/editors/Editor.java
@@ -17,18 +17,22 @@
package com.android.gallery3d.filtershow.editors;
import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.text.Html;
+import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.*;
+import android.widget.Button;
+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.controller.Control;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.imageshow.ImageShow;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
@@ -43,6 +47,7 @@
protected ImageShow mImageShow;
protected FrameLayout mFrameLayout;
protected SeekBar mSeekBar;
+ Button mEditTitle;
protected PanelController mPanelController;
protected int mID;
private final String LOGTAG = "Editor";
@@ -57,7 +62,7 @@
}
public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
- String apply = context.getString(R.string.apply_effect);
+ String apply = "";
if (mShowParameter == SHOW_VALUE_INT) {
apply += " " + effectName + " " + parameterValue;
} else {
@@ -83,6 +88,12 @@
return true;
}
+ public void setUpEditorUI(View actionButton, View editControl, Button editTitle) {
+ this.mEditTitle = editTitle;
+ setMenuIcon(true);
+ setUtilityPanelUI(actionButton, editControl);
+ }
+
public boolean showsPopupIndicator() {
return true;
}
@@ -92,17 +103,28 @@
* @param editControl this is the black area for sliders etc
*/
public void setUtilityPanelUI(View actionButton, View editControl) {
- mSeekBar = (SeekBar) editControl.findViewById(R.id.primarySeekBar);
+
+ AttributeSet aset;
+ Context context = editControl.getContext();
+ LayoutInflater inflater =
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout lp = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_seekbar, (ViewGroup) editControl, true);
+ mSeekBar = (SeekBar) lp.findViewById(R.id.primarySeekBar);
+ mSeekBar.setOnSeekBarChangeListener(this);
+
if (showsSeekBar()) {
mSeekBar.setOnSeekBarChangeListener(this);
mSeekBar.setVisibility(View.VISIBLE);
} else {
mSeekBar.setVisibility(View.INVISIBLE);
}
+
Button button = (Button) actionButton.findViewById(R.id.applyEffect);
if (button != null) {
if (showsPopupIndicator()) {
- button.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, R.drawable.filtershow_menu_marker, 0);
+ button.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0,
+ R.drawable.filtershow_menu_marker, 0);
} else {
button.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0);
}
@@ -205,19 +227,29 @@
}
public void openUtilityPanel(LinearLayout mAccessoryViewList) {
+ setMenuIcon(false);
if (mImageShow != null) {
mImageShow.openUtilityPanel(mAccessoryViewList);
}
}
+ protected void setMenuIcon(boolean on) {
+ mEditTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(
+ 0, 0, on ? R.drawable.filtershow_menu_marker : 0, 0);
+ }
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]));
}
+ setMenuIcon(true);
+
}
+ public Control[] getControls() {
+ return null;
+ }
@Override
public void onStartTrackingTouch(SeekBar arg0) {
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorVignette.java b/src/com/android/gallery3d/filtershow/editors/EditorVignette.java
index a7d99e4..7127b21 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorVignette.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorVignette.java
@@ -24,7 +24,7 @@
import com.android.gallery3d.filtershow.filters.FilterVignetteRepresentation;
import com.android.gallery3d.filtershow.imageshow.ImageVignette;
-public class EditorVignette extends BasicEditor {
+public class EditorVignette extends ParametricEditor {
public static final int ID = R.id.vignetteEditor;
private static final String LOGTAG = "EditorVignettePlanet";
ImageVignette mImageVignette;
diff --git a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
new file mode 100644
index 0000000..cf00f4a
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
@@ -0,0 +1,197 @@
+/*
+ * 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.editors;
+
+import android.content.Context;
+import android.graphics.Point;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
+import android.view.WindowManager;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.controller.ActionSlider;
+import com.android.gallery3d.filtershow.controller.BasicSlider;
+import com.android.gallery3d.filtershow.controller.Control;
+import com.android.gallery3d.filtershow.controller.Parameter;
+import com.android.gallery3d.filtershow.controller.ParameterActionAndInt;
+import com.android.gallery3d.filtershow.controller.ParameterInteger;
+import com.android.gallery3d.filtershow.controller.TitledSlider;
+import com.android.gallery3d.filtershow.filters.FilterBasicRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+
+public class ParametricEditor extends Editor {
+ private int mLayoutID;
+ private int mViewID;
+ public static int ID = R.id.editorParametric;
+ private final String LOGTAG = "ParametricEditor";
+ protected Control mControl;
+ public static final int MINIMUM_WIDTH = 600;
+ public static final int MINIMUM_HEIGHT = 800;
+
+ static HashMap<String, Class> portraitMap = new HashMap<String, Class>();
+ static HashMap<String, Class> landscapeMap = new HashMap<String, Class>();
+ static {
+ portraitMap.put(ParameterInteger.sParameterType, BasicSlider.class);
+ landscapeMap.put(ParameterInteger.sParameterType, TitledSlider.class);
+ portraitMap.put(ParameterActionAndInt.sParameterType, ActionSlider.class);
+ landscapeMap.put(ParameterActionAndInt.sParameterType, ActionSlider.class);
+ }
+
+ static Constructor getConstructor(Class cl) {
+ try {
+ return cl.getConstructor(Context.class, ViewGroup.class);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public ParametricEditor() {
+ super(ID);
+ }
+
+ protected ParametricEditor(int id) {
+ super(id);
+ }
+
+ protected ParametricEditor(int id, int layoutID, int viewID) {
+ super(id);
+ mLayoutID = layoutID;
+ mViewID = viewID;
+ }
+
+ @Override
+ public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
+ String apply = "";
+
+ if (mShowParameter == SHOW_VALUE_INT & useCompact(context)) {
+ if (getLocalRepresentation() instanceof FilterBasicRepresentation) {
+ FilterBasicRepresentation interval = (FilterBasicRepresentation) getLocalRepresentation();
+ apply += " " + effectName + " " + interval.getStateRepresentation();
+ } else {
+ apply += " " + effectName + " " + parameterValue;
+ }
+ } else {
+ apply += " " + effectName;
+ }
+ return apply;
+ }
+
+ @Override
+ public void createEditor(Context context, FrameLayout frameLayout) {
+ super.createEditor(context, frameLayout);
+ unpack(mViewID, mLayoutID);
+ }
+
+ @Override
+ public void reflectCurrentFilter() {
+ super.reflectCurrentFilter();
+ if (getLocalRepresentation() != null
+ && getLocalRepresentation() instanceof FilterBasicRepresentation) {
+ FilterBasicRepresentation interval = (FilterBasicRepresentation) getLocalRepresentation();
+ mControl.setPrameter(interval);
+ }
+ }
+
+ @Override
+ public Control[] getControls() {
+ BasicSlider slider = new BasicSlider();
+ return new Control[] {
+ slider
+ };
+ }
+
+ // TODO: need a better way to decide when which representation
+ static boolean useCompact(Context context) {
+ WindowManager w = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE));
+ Point size = new Point();
+ w.getDefaultDisplay().getSize(size);
+ if (size.x < size.y) { // if tall than wider
+ return true;
+ }
+ if (size.x < MINIMUM_WIDTH) {
+ return true;
+ }
+ if (size.y < MINIMUM_HEIGHT) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void setUtilityPanelUI(View actionButton, View editControl) {
+ FilterRepresentation rep = getLocalRepresentation();
+ if (this instanceof Parameter) {
+ control((Parameter) this, editControl);
+ } else if (rep instanceof Parameter) {
+ control((Parameter) rep, editControl);
+ } else {
+ mSeekBar = new SeekBar(editControl.getContext());
+ LayoutParams lp = new LinearLayout.LayoutParams(
+ LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
+ mSeekBar.setLayoutParams(lp);
+ ((LinearLayout) editControl).addView(mSeekBar);
+ mSeekBar.setOnSeekBarChangeListener(this);
+ }
+ }
+
+ protected void control(Parameter p, View editControl) {
+ String pType = p.getParameterType();
+ Context context = editControl.getContext();
+ Class c = ((useCompact(context)) ? portraitMap : landscapeMap).get(pType);
+
+ if (c != null) {
+ try {
+ mControl = (Control) c.newInstance();
+ mControl.setUp((ViewGroup) editControl, p, this);
+
+ } catch (Exception e) {
+ Log.e(LOGTAG, "Error in loading Control ", e);
+ }
+ } else {
+ Log.e(LOGTAG, "Unable to find class for " + pType);
+ for (String string : portraitMap.keySet()) {
+ Log.e(LOGTAG, "for " + string + " use " + portraitMap.get(string));
+ }
+ }
+ }
+
+ @Override
+ public void commitLocalRepresentation() {
+ super.commitLocalRepresentation();
+ FilterRepresentation rep = getLocalRepresentation();
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar sbar, int progress, boolean arg2) {
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar arg0) {
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar arg0) {
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
index 2410ebe..34323c4 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterBasicRepresentation.java
@@ -17,8 +17,10 @@
package com.android.gallery3d.filtershow.filters;
import com.android.gallery3d.app.Log;
+import com.android.gallery3d.filtershow.controller.Control;
+import com.android.gallery3d.filtershow.controller.ParameterInteger;
-public class FilterBasicRepresentation extends FilterRepresentation {
+public class FilterBasicRepresentation extends FilterRepresentation implements ParameterInteger {
private static final String LOGTAG = "FilterBasicRepresentation";
private int mMinimum;
private int mValue;
@@ -33,6 +35,7 @@
setValue(value);
}
+ @Override
public String toString() {
return getName() + " : " + mMinimum + " < " + mValue + " < " + mMaximum;
}
@@ -47,6 +50,7 @@
return representation;
}
+ @Override
public void useParametersFrom(FilterRepresentation a) {
if (a instanceof FilterBasicRepresentation) {
FilterBasicRepresentation representation = (FilterBasicRepresentation) a;
@@ -76,6 +80,7 @@
return false;
}
+ @Override
public int getMinimum() {
return mMinimum;
}
@@ -84,10 +89,12 @@
mMinimum = minimum;
}
+ @Override
public int getValue() {
return mValue;
}
+ @Override
public void setValue(int value) {
mValue = value;
if (mValue < mMinimum) {
@@ -98,6 +105,7 @@
}
}
+ @Override
public int getMaximum() {
return mMaximum;
}
@@ -110,6 +118,7 @@
mDefaultValue = defaultValue;
}
+ @Override
public int getDefaultValue() {
return mDefaultValue;
}
@@ -122,7 +131,27 @@
mPreviewValue = previewValue;
}
+ @Override
public String getStateRepresentation() {
return "" + getValue();
}
+
+ @Override
+ public String getParameterType(){
+ return sParameterType;
+ }
+
+ @Override
+ public void setController(Control control) {
+ }
+
+ @Override
+ public String getValueString() {
+ return getStateRepresentation();
+ }
+
+ @Override
+ public String getParameterName() {
+ return getName();
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageVignette.java b/src/com/android/gallery3d/filtershow/imageshow/ImageVignette.java
index 1149263..7ce9e51 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageVignette.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageVignette.java
@@ -65,10 +65,6 @@
mActiveHandle = -1;
break;
case MotionEvent.ACTION_DOWN:
- if (event.getPointerCount() == 1) {
- Log.v(LOGTAG, "################### ACTION_DOWN odd " + mActiveHandle
- + " touches=1");
- }
break;
}
}