diff options
Diffstat (limited to 'src/com')
10 files changed, 173 insertions, 47 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 10650b9e6..37115a5f7 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -210,19 +210,11 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, ((ViewStub) findViewById(R.id.statePanelStub)).inflate(); setupHistoryPanel(); setupStatePanel(); - - mPanelController.setRowPanel(findViewById(R.id.secondRowPanel)); - mPanelController.setUtilityPanel(this, findViewById(R.id.filterButtonsList), - findViewById(R.id.panelAccessoryViewList), - findViewById(R.id.applyEffect)); - - mPanelController.setCurrentPanel(R.id.fxButton); } public void setupHistoryPanel() { findViewById(R.id.resetOperationsButton).setOnClickListener( createOnClickResetOperationsButton()); - ListView operationsList = (ListView) findViewById(R.id.operationsList); operationsList.setAdapter(mMasterImage.getHistory()); operationsList.setOnItemClickListener(this); @@ -232,6 +224,9 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, ListView imageStateList = (ListView) findViewById(R.id.imageStateList); imageStateList.setAdapter(mMasterImage.getState()); mImageLoader.setAdapter(mMasterImage.getHistory()); + mPanelController.setRowPanel(findViewById(R.id.secondRowPanel)); + mPanelController.setUtilityPanel(this, findViewById(R.id.filterButtonsList)); + mPanelController.setCurrentPanel(R.id.fxButton); } private void fillPanel(Vector<FilterRepresentation> representations, int layoutId, int buttonId) { diff --git a/src/com/android/gallery3d/filtershow/PanelController.java b/src/com/android/gallery3d/filtershow/PanelController.java index 3c4470ad0..645334c75 100644 --- a/src/com/android/gallery3d/filtershow/PanelController.java +++ b/src/com/android/gallery3d/filtershow/PanelController.java @@ -21,6 +21,7 @@ import android.text.Html; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewPropertyAnimator; +import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; @@ -158,10 +159,11 @@ public class PanelController implements OnClickListener { private int mParameterValue = 0; private boolean mShowParameterValue = false; - public UtilityPanel(Context context, View view, View accessoryViewList, - View textView) { + public UtilityPanel(Context context, View utilityPanel) { + mView = utilityPanel; + View accessoryViewList = mView.findViewById(R.id.panelAccessoryViewList); + Button textView = (Button) mView.findViewById(R.id.applyEffect); mContext = context; - mView = view; mAccessoryViewList = (LinearLayout) accessoryViewList; mTextView = (TextView) textView; } @@ -193,14 +195,34 @@ public class PanelController implements OnClickListener { updateText(); } + public void showMenu(boolean show) { + mTextView.setOnClickListener(null); + if (show){ + mAccessoryViewList.setVisibility(View.VISIBLE); + mTextView.setVisibility(View.VISIBLE); + } else { + mAccessoryViewList.setVisibility(View.VISIBLE); + mTextView.setVisibility(View.VISIBLE); + } + + } + + public View getActionControl() { + return mView.findViewById(R.id.panelAccessoryViewList); + } + + public View getEditControl() { + return mView.findViewById(R.id.controlArea); + } public void updateText() { - String apply = mContext.getString(R.string.apply_effect); - if (mShowParameterValue) { - mTextView.setText(Html.fromHtml(apply + " " + mEffectName + " " - + mParameterValue)); + String s; + if (mCurrentEditor == null) { + String apply = mContext.getString(R.string.apply_effect); + s = apply + " " + mEffectName + " " + mParameterValue; } else { - mTextView.setText(Html.fromHtml(apply + " " + mEffectName)); + s = mCurrentEditor.calculateUserMessage(mContext, mEffectName, mParameterValue); } + mTextView.setText(Html.fromHtml(s)); } public ViewPropertyAnimator unselect() { @@ -363,10 +385,12 @@ public class PanelController implements OnClickListener { mRowPanel = rowPanel; } - public void setUtilityPanel(Context context, View utilityPanel, - View accessoryViewList, View textView) { - mUtilityPanel = new UtilityPanel(context, utilityPanel, - accessoryViewList, textView); + public void setUtilityPanel(Context context, View utilityPanel) { + addView(utilityPanel.findViewById(R.id.applyEffect)); + addView(utilityPanel.findViewById(R.id.applyFilter)); + // TODO rename applyFilter to panelFilterDescription + addView(utilityPanel.findViewById(R.id.cancelFilter)); + mUtilityPanel = new UtilityPanel(context, utilityPanel); } @Override @@ -552,8 +576,8 @@ public class PanelController implements OnClickListener { mCurrentImage.unselect(); } mUtilityPanel.hideAccessoryViews(); - - if (view instanceof FilterIconButton && view.getId() != R.id.applyEffect) { + mUtilityPanel.showMenu(false); + if (view instanceof FilterIconButton) { mCurrentEditor = null; FilterIconButton component = (FilterIconButton) view; FilterRepresentation representation = component.getFilterRepresentation(); @@ -563,9 +587,13 @@ public class PanelController implements OnClickListener { if (representation.getEditorId() != 0) { if (mEditorPlaceHolder.contains(representation.getEditorId())) { - mCurrentEditor = mEditorPlaceHolder.showEditor(representation.getEditorId()); + mCurrentEditor = mEditorPlaceHolder.showEditor( + representation.getEditorId()); + mCurrentEditor.setUtilityPanelUI( + mUtilityPanel.getActionControl(), mUtilityPanel.getEditControl()); mCurrentImage = mCurrentEditor.getImageShow(); mCurrentEditor.setPanelController(this); + } else { mCurrentImage = showImageView(representation.getEditorId()); } @@ -576,6 +604,7 @@ public class PanelController implements OnClickListener { if (mCurrentEditor != null) { mCurrentEditor.reflectCurrentFilter(); if (mCurrentEditor.useUtilityPanel()) { + mUtilityPanel.showMenu(true); mCurrentEditor.openUtilityPanel(mUtilityPanel.mAccessoryViewList); } } else if (mCurrentImage.useUtilityPanel()) { @@ -592,7 +621,9 @@ public class PanelController implements OnClickListener { mUtilityPanel.setEffectName(ename); } else { - if (id == R.id.applyEffect) { + if (id == R.id.cancelFilter) { + cancelCurrentFilter(); + } else if (id == R.id.applyEffect || id == R.id.applyFilter) { if (MasterImage.getImage().getCurrentFilter() instanceof ImageFilterTinyPlanet) { mActivity.saveImage(); } else { @@ -611,7 +642,16 @@ public class PanelController implements OnClickListener { } else if (mCurrentImage.useUtilityPanel()) { mCurrentImage.openUtilityPanel(mUtilityPanel.mAccessoryViewList); } + } + + public void cancelCurrentFilter() { + resetParameters(); + MasterImage masterImage = MasterImage.getImage(); + HistoryAdapter adapter = masterImage.getHistory(); + int position = adapter.undo(); + masterImage.onHistoryItemClick(position); + mActivity.invalidateViews(); } public void setEditorPlaceHolder(EditorPlaceHolder editorPlaceHolder) { 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); } diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java index c7d08d887..b64cf567e 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java +++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java @@ -68,6 +68,7 @@ public class GeometryMetadata extends FilterRepresentation { setEditorId(EditorCrop.ID); setName("Crop"); setTextId(0); + setShowParameterValue(true); } @Override diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java index 92d6c7435..38d415633 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java @@ -695,7 +695,7 @@ public class ImageShow extends View implements OnGestureListener, } public boolean useUtilityPanel() { - return true; + return false; } public void openUtilityPanel(final LinearLayout accessoryViewList) { diff --git a/src/com/android/gallery3d/filtershow/ui/ImageCurves.java b/src/com/android/gallery3d/filtershow/ui/ImageCurves.java index 3e52f5ee5..04eed946b 100644 --- a/src/com/android/gallery3d/filtershow/ui/ImageCurves.java +++ b/src/com/android/gallery3d/filtershow/ui/ImageCurves.java @@ -30,6 +30,7 @@ import android.view.LayoutInflater; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; +import android.widget.Button; import android.widget.LinearLayout; import android.widget.PopupMenu; @@ -41,11 +42,14 @@ import com.android.gallery3d.filtershow.filters.ImageFilterCurves; import com.android.gallery3d.filtershow.imageshow.ImageShow; import com.android.gallery3d.filtershow.presets.ImagePreset; +import java.util.HashMap; + public class ImageCurves extends ImageShow { private static final String LOGTAG = "ImageCurves"; Paint gPaint = new Paint(); Path gPathSpline = new Path(); + HashMap<Integer, String> mIdStrLut; private int mCurrentCurveIndex = Spline.RGB; private boolean mDidAddPoint = false; @@ -80,18 +84,29 @@ public class ImageCurves extends ImageShow { } private void showPopupMenu(LinearLayout accessoryViewList) { - final FramedTextButton button = (FramedTextButton) accessoryViewList.findViewById( - R.id.curvesUtilityButton); + final Button button = (Button) accessoryViewList.findViewById( + R.id.applyEffect); if (button == null) { return; } + if (mIdStrLut == null){ + mIdStrLut = new HashMap<Integer, String>(); + mIdStrLut.put(R.id.curve_menu_rgb, + getContext().getString(R.string.curves_channel_rgb)); + mIdStrLut.put(R.id.curve_menu_red, + getContext().getString(R.string.curves_channel_red)); + mIdStrLut.put(R.id.curve_menu_green, + getContext().getString(R.string.curves_channel_green)); + mIdStrLut.put(R.id.curve_menu_blue, + getContext().getString(R.string.curves_channel_blue)); + } PopupMenu popupMenu = new PopupMenu(getActivity(), button); popupMenu.getMenuInflater().inflate(R.menu.filtershow_menu_curves, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { setChannel(item.getItemId()); - button.setTextFrom(item.getItemId()); + button.setText(mIdStrLut.get(item.getItemId())); return true; } }); @@ -100,19 +115,17 @@ public class ImageCurves extends ImageShow { @Override public void openUtilityPanel(final LinearLayout accessoryViewList) { - View view = accessoryViewList.findViewById(R.id.curvesUtilityButton); - if (view == null) { - LayoutInflater inflater = (LayoutInflater)getActivity().getSystemService - (Context.LAYOUT_INFLATER_SERVICE); - view = inflater.inflate(R.layout.filtershow_curves_button, accessoryViewList, false); - accessoryViewList.addView(view, view.getLayoutParams()); - view.setOnClickListener(new OnClickListener() { + Context context = accessoryViewList.getContext(); + Button view = (Button) accessoryViewList.findViewById(R.id.applyEffect); + view.setText(context.getString(R.string.curves_channel_rgb)); + view.setVisibility(View.VISIBLE); + + view.setOnClickListener(new OnClickListener() { @Override - public void onClick(View arg0) { - showPopupMenu(accessoryViewList); - } - }); - } + public void onClick(View arg0) { + showPopupMenu(accessoryViewList); + } + }); if (view != null) { view.setVisibility(View.VISIBLE); |