summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/editors
diff options
context:
space:
mode:
authornicolasroard <nicolasroard@google.com>2013-04-19 17:13:30 -0700
committernicolasroard <nicolasroard@google.com>2013-04-24 20:23:36 -0700
commit61ef319ade6d32f35e2f61a20c6208e6fbac8076 (patch)
tree3fd5d946392d65e9a8c8e69a8cd2d480202aec91 /src/com/android/gallery3d/filtershow/editors
parentb341bb5ddda66c8df047cb5a7ad7a2f6bb9b2991 (diff)
downloadandroid_packages_apps_Snap-61ef319ade6d32f35e2f61a20c6208e6fbac8076.tar.gz
android_packages_apps_Snap-61ef319ade6d32f35e2f61a20c6208e6fbac8076.tar.bz2
android_packages_apps_Snap-61ef319ade6d32f35e2f61a20c6208e6fbac8076.zip
UI changes
bug:8664728 Change-Id: I133328543af534c745526d0d58aa7a61f5748a9d
Diffstat (limited to 'src/com/android/gallery3d/filtershow/editors')
-rw-r--r--src/com/android/gallery3d/filtershow/editors/BasicEditor.java3
-rw-r--r--src/com/android/gallery3d/filtershow/editors/Editor.java47
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorPanel.java145
-rw-r--r--src/com/android/gallery3d/filtershow/editors/ParametricEditor.java9
4 files changed, 176 insertions, 28 deletions
diff --git a/src/com/android/gallery3d/filtershow/editors/BasicEditor.java b/src/com/android/gallery3d/filtershow/editors/BasicEditor.java
index 987b499bf..44296e2ef 100644
--- a/src/com/android/gallery3d/filtershow/editors/BasicEditor.java
+++ b/src/com/android/gallery3d/filtershow/editors/BasicEditor.java
@@ -51,9 +51,6 @@ public class BasicEditor extends ParametricEditor implements ParameterInteger {
super.reflectCurrentFilter();
if (getLocalRepresentation() != null && getLocalRepresentation() instanceof FilterBasicRepresentation) {
FilterBasicRepresentation interval = (FilterBasicRepresentation) getLocalRepresentation();
- Context context = mContext;
- interval.getTextId();
-
}
}
diff --git a/src/com/android/gallery3d/filtershow/editors/Editor.java b/src/com/android/gallery3d/filtershow/editors/Editor.java
index dc13b3e37..b543750f3 100644
--- a/src/com/android/gallery3d/filtershow/editors/Editor.java
+++ b/src/com/android/gallery3d/filtershow/editors/Editor.java
@@ -32,7 +32,6 @@ 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;
@@ -50,19 +49,16 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
protected FrameLayout mFrameLayout;
protected SeekBar mSeekBar;
Button mEditTitle;
- protected PanelController mPanelController;
+ protected Button mFilterTitle;
protected int mID;
private final String LOGTAG = "Editor";
protected FilterRepresentation mLocalRepresentation = null;
protected byte mShowParameter = SHOW_VALUE_UNDEFINED;
+ private Button mButton;
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) {
return effectName + " " + parameterValue;
}
@@ -83,8 +79,11 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
return true;
}
- public void setUpEditorUI(View actionButton, View editControl, Button editTitle) {
- this.mEditTitle = editTitle;
+ public void setUpEditorUI(View actionButton, View editControl,
+ Button editTitle, Button stateButton) {
+ mEditTitle = editTitle;
+ mFilterTitle = stateButton;
+ mButton = editTitle;
setMenuIcon(true);
setUtilityPanelUI(actionButton, editControl);
}
@@ -115,13 +114,12 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
mSeekBar.setVisibility(View.INVISIBLE);
}
- Button button = (Button) actionButton.findViewById(R.id.applyEffect);
- if (button != null) {
+ if (mButton != null) {
if (showsPopupIndicator()) {
- button.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0,
+ mButton.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0,
R.drawable.filtershow_menu_marker, 0);
} else {
- button.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0);
+ mButton.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0);
}
}
}
@@ -200,17 +198,25 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
boolean show = filterRepresentation.showParameterValue();
mShowParameter = show ? SHOW_VALUE_INT : SHOW_VALUE_OFF;
}
- }
+ }
return mLocalRepresentation;
}
public void commitLocalRepresentation() {
ImagePreset preset = MasterImage.getImage().getPreset();
preset.updateFilterRepresentation(getLocalRepresentation());
- if (mPanelController != null) {
- mPanelController.onNewValue(-1);
+ if (mButton != null) {
+ updateText();
+ }
+ }
+
+ protected void updateText() {
+ String s = "";
+ if (mLocalRepresentation != null) {
+ s = mContext.getString(mLocalRepresentation.getTextId());
}
+ mButton.setText(calculateUserMessage(mContext, s, ""));
}
/**
@@ -218,6 +224,12 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
*/
public void reflectCurrentFilter() {
mLocalRepresentation = null;
+ FilterRepresentation representation = getLocalRepresentation();
+ if (representation != null && mFilterTitle != null && representation.getTextId() != 0) {
+ String text = mContext.getString(representation.getTextId()).toUpperCase();
+ mFilterTitle.setText(text);
+ updateText();
+ }
}
public boolean useUtilityPanel() {
@@ -235,6 +247,7 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
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();
@@ -269,6 +282,8 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
}
public void detach() {
-
+ if (mImageShow != null) {
+ mImageShow.unselect();
+ }
}
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorPanel.java b/src/com/android/gallery3d/filtershow/editors/EditorPanel.java
new file mode 100644
index 000000000..e35bc8fb3
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorPanel.java
@@ -0,0 +1,145 @@
+/*
+ * 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.app.Activity;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.HistoryAdapter;
+import com.android.gallery3d.filtershow.category.MainPanel;
+import com.android.gallery3d.filtershow.imageshow.MasterImage;
+import com.android.gallery3d.filtershow.state.StatePanel;
+
+public class EditorPanel extends Fragment {
+
+ private static final String LOGTAG = "EditorPanel";
+
+ private LinearLayout mMainView;
+ private Editor mEditor;
+ private int mEditorID;
+
+ public void setEditor(int editor) {
+ mEditorID = editor;
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ FilterShowActivity filterShowActivity = (FilterShowActivity) activity;
+ mEditor = filterShowActivity.getEditor(mEditorID);
+ }
+
+ public void cancelCurrentFilter() {
+ MasterImage masterImage = MasterImage.getImage();
+ HistoryAdapter adapter = masterImage.getHistory();
+
+ int position = adapter.undo();
+ masterImage.onHistoryItemClick(position);
+ ((FilterShowActivity)getActivity()).invalidateViews();
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ if (mMainView != null) {
+ if (mMainView.getParent() != null) {
+ ViewGroup parent = (ViewGroup) mMainView.getParent();
+ parent.removeView(mMainView);
+ }
+ showImageStatePanel(activity.isShowingImageStatePanel());
+ return mMainView;
+ }
+ mMainView = (LinearLayout) inflater.inflate(R.layout.filtershow_editor_panel, null);
+
+ View actionControl = mMainView.findViewById(R.id.panelAccessoryViewList);
+ View editControl = mMainView.findViewById(R.id.controlArea);
+ ImageButton cancelButton = (ImageButton) mMainView.findViewById(R.id.cancelFilter);
+ ImageButton applyButton = (ImageButton) mMainView.findViewById(R.id.applyFilter);
+ Button editTitle = (Button) mMainView.findViewById(R.id.applyEffect);
+ cancelButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ cancelCurrentFilter();
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ activity.backToMain();
+ }
+ });
+ applyButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MasterImage.getImage().invalidateFiltersOnly();
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ activity.backToMain();
+ }
+ });
+
+ Button toggleState = (Button) mMainView.findViewById(R.id.toggle_state);
+
+ mEditor = activity.getEditor(mEditorID);
+ if (mEditor != null) {
+ mEditor.setUpEditorUI(actionControl, editControl, editTitle, toggleState);
+ mEditor.getImageShow().select();
+ mEditor.reflectCurrentFilter();
+ if (mEditor.useUtilityPanel()) {
+ mEditor.openUtilityPanel((LinearLayout) actionControl);
+ }
+ }
+
+ showImageStatePanel(activity.isShowingImageStatePanel());
+ return mMainView;
+ }
+
+ @Override
+ public void onDetach() {
+ if (mEditor != null) {
+ mEditor.detach();
+ }
+ super.onDetach();
+ }
+
+ public void showImageStatePanel(boolean show) {
+ if (mMainView.findViewById(R.id.state_panel_container) == null) {
+ return;
+ }
+ FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
+ Fragment panel = getActivity().getSupportFragmentManager().findFragmentByTag(
+ MainPanel.FRAGMENT_TAG);
+ if (panel == null || panel instanceof MainPanel) {
+ transaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
+ }
+ if (show) {
+ StatePanel statePanel = new StatePanel();
+ transaction.replace(R.id.state_panel_container, statePanel, StatePanel.FRAGMENT_TAG);
+ } else {
+ Fragment statePanel = getChildFragmentManager().findFragmentByTag(StatePanel.FRAGMENT_TAG);
+ if (statePanel != null) {
+ transaction.remove(statePanel);
+ }
+ }
+ transaction.commit();
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
index 33ed143bd..02a1c7145 100644
--- a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
+++ b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
@@ -195,15 +195,6 @@ public class ParametricEditor extends Editor {
}
@Override
- public void commitLocalRepresentation() {
- super.commitLocalRepresentation();
- FilterRepresentation rep = getLocalRepresentation();
- if (mPanelController != null) {
- mPanelController.onNewValue(-1);
- }
- }
-
- @Override
public void onProgressChanged(SeekBar sbar, int progress, boolean arg2) {
}