diff options
18 files changed, 363 insertions, 159 deletions
diff --git a/res/drawable/filtershow_vertical_line.xml b/res/drawable/filtershow_vertical_line.xml new file mode 100644 index 000000000..611c7e03f --- /dev/null +++ b/res/drawable/filtershow_vertical_line.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2012 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. +--> + +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle" > + <size android:width="1dp" android:height="20dp"/> + <corners android:radius="0dp" /> + <solid android:color="@color/toolbar_separation_line"/> +</shape>
\ No newline at end of file diff --git a/res/layout-land/filtershow_activity.xml b/res/layout-land/filtershow_activity.xml index 957a36592..066dffad9 100644 --- a/res/layout-land/filtershow_activity.xml +++ b/res/layout-land/filtershow_activity.xml @@ -98,7 +98,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" - android:background="@color/background_main_toolbar" custom:max_width="600dip" android:orientation="vertical"> @@ -111,33 +110,94 @@ android:id="@+id/filterButtonsList" android:layout_width="fill_parent" android:layout_height="@dimen/thumbnail_size" - android:background="@color/background_main_toolbar" android:orientation="horizontal" android:visibility="gone" > - <FrameLayout - android:layout_width="fill_parent" - android:layout_height="fill_parent" > + <LinearLayout + android:id="@+id/top" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="0" + android:orientation="vertical" + android:visibility="visible" > <LinearLayout - android:id="@+id/panelAccessoryViewList" + android:id="@+id/controlArea" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="horizontal" + android:background="@android:color/transparent" + android:visibility="visible" > + + <SeekBar + android:id="@+id/primarySeekBar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@android:color/transparent" + android:layout_weight="1" /> + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:background="@color/filtershow_background" + android:orientation="horizontal" + android:visibility="visible" > + + <ImageButton + android:id="@+id/cancelFilter" android:layout_width="wrap_content" + android:layout_height="94dip" + android:layout_gravity="left" + android:layout_weight=".1" + android:background="@android:color/transparent" + android:gravity="center" + android:src="@drawable/ic_menu_cancel_holo_light" + android:textSize="18dip" /> + + <ImageView + android:layout_width="2dp" android:layout_height="fill_parent" + android:src="@drawable/filtershow_vertical_line" /> + + <LinearLayout + android:id="@+id/panelAccessoryViewList" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_weight="1" android:orientation="horizontal" - android:visibility="visible" /> + android:visibility="visible" > + + <Button + android:id="@+id/applyEffect" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:layout_gravity="center" + android:background="@android:color/transparent" + android:gravity="center" + android:text="@string/apply_effect" + android:textSize="18dip" /> + </LinearLayout> + + <ImageView + android:layout_width="2dp" + android:layout_height="fill_parent" + android:src="@drawable/filtershow_vertical_line" /> - <Button - android:id="@+id/applyEffect" + <ImageButton + android:id="@+id/applyFilter" android:layout_width="wrap_content" android:layout_height="94dip" - android:layout_gravity="center" - android:layout_weight="1" + android:layout_gravity="right" + android:layout_weight=".1" android:background="@android:color/transparent" android:gravity="center" - android:text="@string/apply_effect" + android:src="@drawable/ic_menu_done_holo_light" android:textSize="18dip" /> - </FrameLayout> - + </LinearLayout> + </LinearLayout> </LinearLayout> <HorizontalScrollView diff --git a/res/layout/filtershow_activity.xml b/res/layout/filtershow_activity.xml index c723aaba5..2833e0b90 100644 --- a/res/layout/filtershow_activity.xml +++ b/res/layout/filtershow_activity.xml @@ -74,47 +74,105 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" - android:background="@color/background_main_toolbar" custom:max_width="600dip" android:orientation="vertical"> - <FrameLayout - android:id="@+id/secondRowPanel" - android:layout_width="fill_parent" - android:layout_height="wrap_content" > - - <LinearLayout - android:id="@+id/filterButtonsList" - android:layout_width="fill_parent" - android:layout_height="@dimen/thumbnail_size" - android:background="@color/background_main_toolbar" - android:orientation="horizontal" - android:visibility="gone" > - - <FrameLayout + <FrameLayout + android:id="@+id/secondRowPanel" android:layout_width="fill_parent" - android:layout_height="fill_parent" > + android:layout_height="wrap_content" > <LinearLayout - android:id="@+id/panelAccessoryViewList" - android:layout_width="wrap_content" - android:layout_height="fill_parent" + android:id="@+id/filterButtonsList" + android:layout_width="fill_parent" + android:layout_height="@dimen/thumbnail_size" android:orientation="horizontal" - android:visibility="visible" /> - - <Button - android:id="@+id/applyEffect" - android:layout_width="wrap_content" - android:layout_height="94dip" - android:layout_gravity="center" - android:layout_weight="1" - android:background="@android:color/transparent" - android:gravity="center" - android:text="@string/apply_effect" - android:textSize="18dip" /> - </FrameLayout> - - </LinearLayout> + android:visibility="gone" > + + <LinearLayout + android:id="@+id/top" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="0" + android:orientation="vertical" + android:visibility="visible" > + + <LinearLayout + android:id="@+id/controlArea" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:orientation="horizontal" + android:visibility="visible" > + + <SeekBar + android:id="@+id/primarySeekBar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" /> + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:background="@color/filtershow_background" + android:orientation="horizontal" + android:visibility="visible" > + + <ImageButton + android:id="@+id/cancelFilter" + android:layout_width="wrap_content" + android:layout_height="94dip" + android:layout_gravity="left" + android:layout_weight=".1" + android:background="@android:color/transparent" + android:gravity="center" + android:src="@drawable/ic_menu_cancel_holo_light" + android:textSize="18dip" /> + + <ImageView + android:layout_width="2dp" + android:layout_height="fill_parent" + android:src="@drawable/filtershow_vertical_line" /> + + <LinearLayout + android:id="@+id/panelAccessoryViewList" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_weight="1" + android:orientation="horizontal" + android:visibility="visible" > + + <Button + android:id="@+id/applyEffect" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:layout_gravity="center" + android:background="@android:color/transparent" + android:gravity="center" + android:text="@string/apply_effect" + android:textSize="18dip" /> + </LinearLayout> + + <ImageView + android:layout_width="2dp" + android:layout_height="fill_parent" + android:src="@drawable/filtershow_vertical_line" /> + + <ImageButton + android:id="@+id/applyFilter" + android:layout_width="wrap_content" + android:layout_height="94dip" + android:layout_gravity="right" + android:layout_weight=".1" + android:background="@android:color/transparent" + android:gravity="center" + android:src="@drawable/ic_menu_done_holo_light" + android:textSize="18dip" /> + </LinearLayout> + </LinearLayout> + </LinearLayout> <HorizontalScrollView android:id="@+id/fxList" diff --git a/res/layout/filtershow_default_editor.xml b/res/layout/filtershow_default_editor.xml index 9f25529e1..b261ea35f 100644 --- a/res/layout/filtershow_default_editor.xml +++ b/res/layout/filtershow_default_editor.xml @@ -27,20 +27,4 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - <com.android.gallery3d.filtershow.CenteredLinearLayout - xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="center_horizontal|bottom" - android:background="@android:color/transparent" - custom:max_width="600dip" - android:orientation="vertical"> - - <SeekBar - android:id="@+id/filterSeekBar" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="bottom" - android:padding="16dip"/> - </com.android.gallery3d.filtershow.CenteredLinearLayout> </FrameLayout>
\ No newline at end of file diff --git a/res/layout/filtershow_tiny_planet_editor.xml b/res/layout/filtershow_tiny_planet_editor.xml index a99e406a9..61e0cf565 100644 --- a/res/layout/filtershow_tiny_planet_editor.xml +++ b/res/layout/filtershow_tiny_planet_editor.xml @@ -27,20 +27,4 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - <com.android.gallery3d.filtershow.CenteredLinearLayout - xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="center_horizontal|bottom" - android:background="@android:color/transparent" - custom:max_width="600dip" - android:orientation="vertical"> - - <SeekBar - android:id="@+id/filterSeekBar" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="bottom" - android:padding="16dip"/> - </com.android.gallery3d.filtershow.CenteredLinearLayout> </FrameLayout>
\ No newline at end of file diff --git a/res/layout/filtershow_vignette_editor.xml b/res/layout/filtershow_vignette_editor.xml index 6e5755928..72a615fb4 100644 --- a/res/layout/filtershow_vignette_editor.xml +++ b/res/layout/filtershow_vignette_editor.xml @@ -27,20 +27,4 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - <com.android.gallery3d.filtershow.CenteredLinearLayout - xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="center_horizontal|bottom" - android:background="@android:color/transparent" - custom:max_width="600dip" - android:orientation="vertical"> - - <SeekBar - android:id="@+id/filterSeekBar" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="bottom" - android:padding="16dip"/> - </com.android.gallery3d.filtershow.CenteredLinearLayout> </FrameLayout>
\ No newline at end of file diff --git a/res/layout/filtershow_zoom_editor.xml b/res/layout/filtershow_zoom_editor.xml index 3ef6f6bf7..9813a283d 100644 --- a/res/layout/filtershow_zoom_editor.xml +++ b/res/layout/filtershow_zoom_editor.xml @@ -27,20 +27,4 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> - <com.android.gallery3d.filtershow.CenteredLinearLayout - xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="center_horizontal|bottom" - android:background="@android:color/transparent" - custom:max_width="600dip" - android:orientation="vertical"> - - <SeekBar - android:id="@+id/filterSeekBar" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_gravity="bottom" - android:padding="16dip"/> - </com.android.gallery3d.filtershow.CenteredLinearLayout> </FrameLayout> diff --git a/res/values/filtershow_color.xml b/res/values/filtershow_color.xml index 175d3d3e0..70191fdc3 100644 --- a/res/values/filtershow_color.xml +++ b/res/values/filtershow_color.xml @@ -26,5 +26,7 @@ <color name="toolbar_separation_line">#333333</color> <color name="slider_dot_color">#6464FF</color> <color name="slider_line_color">#33B5E5</color> + <color name="filtershow_background">#333333</color> + <color name="filtershow_graphic">#717171</color> </resources>
\ No newline at end of file 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); |
