summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/photoeditor
diff options
context:
space:
mode:
authorYuli Huang <yuli@google.com>2011-12-02 19:55:05 +0800
committerYuli Huang <yuli@google.com>2011-12-03 00:21:34 +0800
commit72f77e4e3147cc856a472f31999d98d08fc19edc (patch)
treec3d0e91296e6cbad62ec4c54591b858ca1f2772f /src/com/android/gallery3d/photoeditor
parent5fa9a3dc0c61ee80363125db5029f3683c3813d3 (diff)
downloadandroid_packages_apps_Snap-72f77e4e3147cc856a472f31999d98d08fc19edc.tar.gz
android_packages_apps_Snap-72f77e4e3147cc856a472f31999d98d08fc19edc.tar.bz2
android_packages_apps_Snap-72f77e4e3147cc856a472f31999d98d08fc19edc.zip
Simplify EffectAction.
1. Make the whole effect item clickable instead of just the icon. 2. Rename interfaces/methods to improve readability. Change-Id: I647a13dae88b4527b7baba85bb83b9bd15bbe997
Diffstat (limited to 'src/com/android/gallery3d/photoeditor')
-rw-r--r--src/com/android/gallery3d/photoeditor/EffectsBar.java27
-rw-r--r--src/com/android/gallery3d/photoeditor/EffectsMenu.java10
-rw-r--r--src/com/android/gallery3d/photoeditor/actions/AutoFixAction.java2
-rw-r--r--src/com/android/gallery3d/photoeditor/actions/CrossProcessAction.java2
-rw-r--r--src/com/android/gallery3d/photoeditor/actions/DocumentaryAction.java2
-rw-r--r--src/com/android/gallery3d/photoeditor/actions/DuotoneAction.java2
-rw-r--r--src/com/android/gallery3d/photoeditor/actions/EffectAction.java33
-rw-r--r--src/com/android/gallery3d/photoeditor/actions/GrayscaleAction.java2
-rw-r--r--src/com/android/gallery3d/photoeditor/actions/LomoishAction.java2
-rw-r--r--src/com/android/gallery3d/photoeditor/actions/NegativeAction.java2
-rw-r--r--src/com/android/gallery3d/photoeditor/actions/PosterizeAction.java2
-rw-r--r--src/com/android/gallery3d/photoeditor/actions/SepiaAction.java2
-rw-r--r--src/com/android/gallery3d/photoeditor/actions/TintAction.java2
13 files changed, 39 insertions, 51 deletions
diff --git a/src/com/android/gallery3d/photoeditor/EffectsBar.java b/src/com/android/gallery3d/photoeditor/EffectsBar.java
index 1aafc4e5d..0fd6b758c 100644
--- a/src/com/android/gallery3d/photoeditor/EffectsBar.java
+++ b/src/com/android/gallery3d/photoeditor/EffectsBar.java
@@ -75,18 +75,18 @@ public class EffectsBar extends LinearLayout {
ViewGroup scrollView = (ViewGroup) effectsGallery.findViewById(R.id.scroll_view);
ViewGroup effects = (ViewGroup) inflater.inflate(effectsId, scrollView, false);
for (int i = 0; i < effects.getChildCount(); i++) {
- setupEffectListener((EffectAction) effects.getChildAt(i));
+ setupEffect((EffectAction) effects.getChildAt(i));
}
scrollView.addView(effects);
scrollView.scrollTo(0, 0);
addView(effectsGallery, 0);
}
- private void setupEffectListener(final EffectAction effect) {
- effect.setListener(new EffectAction.Listener() {
+ private void setupEffect(final EffectAction effect) {
+ effect.setOnClickListener(new View.OnClickListener() {
@Override
- public void onClick() {
+ public void onClick(View v) {
if (isEnabled()) {
// Set the clicked effect active before exiting effects-gallery.
activeEffect = effect;
@@ -94,15 +94,17 @@ public class EffectsBar extends LinearLayout {
// Create effect tool panel first before the factory could create tools within.
// TODO: Refactor to encapsulate effect-tool panel in effect-tool factory.
createEffectToolPanel();
- activeEffect.begin(filterStack,
- new EffectToolFactory(effectToolPanel, inflater));
+ EffectAction.ActionListener listener = new EffectAction.ActionListener() {
+
+ @Override
+ public void onOk() {
+ exit(null);
+ }
+ };
+ activeEffect.begin(filterStack, new EffectToolFactory(
+ effectToolPanel, inflater), listener);
}
}
-
- @Override
- public void onDone() {
- exit(null);
- }
});
}
@@ -117,8 +119,7 @@ public class EffectsBar extends LinearLayout {
if (effectsGallery != null) {
if (activeEffect != null) {
// Detach the active effect to prevent it stopping effects-gallery from gc.
- ViewGroup scrollView = (ViewGroup) effectsGallery.findViewById(R.id.scroll_view);
- ((ViewGroup) scrollView.getChildAt(0)).removeView(activeEffect);
+ ((ViewGroup) activeEffect.getParent()).removeView(activeEffect);
}
removeView(effectsGallery);
effectsGallery = null;
diff --git a/src/com/android/gallery3d/photoeditor/EffectsMenu.java b/src/com/android/gallery3d/photoeditor/EffectsMenu.java
index 71614b105..6578849aa 100644
--- a/src/com/android/gallery3d/photoeditor/EffectsMenu.java
+++ b/src/com/android/gallery3d/photoeditor/EffectsMenu.java
@@ -51,13 +51,13 @@ public class EffectsMenu extends RestorableView {
}
public void setOnToggleListener(OnToggleListener listener) {
- setToggleRunnalbe(listener, R.id.exposure_button, R.layout.photoeditor_effects_exposure);
- setToggleRunnalbe(listener, R.id.artistic_button, R.layout.photoeditor_effects_artistic);
- setToggleRunnalbe(listener, R.id.color_button, R.layout.photoeditor_effects_color);
- setToggleRunnalbe(listener, R.id.fix_button, R.layout.photoeditor_effects_fix);
+ setToggleRunnable(listener, R.id.exposure_button, R.layout.photoeditor_effects_exposure);
+ setToggleRunnable(listener, R.id.artistic_button, R.layout.photoeditor_effects_artistic);
+ setToggleRunnable(listener, R.id.color_button, R.layout.photoeditor_effects_color);
+ setToggleRunnable(listener, R.id.fix_button, R.layout.photoeditor_effects_fix);
}
- private void setToggleRunnalbe(final OnToggleListener listener, final int toggleId,
+ private void setToggleRunnable(final OnToggleListener listener, final int toggleId,
final int effectsId) {
setClickRunnable(toggleId, new Runnable() {
diff --git a/src/com/android/gallery3d/photoeditor/actions/AutoFixAction.java b/src/com/android/gallery3d/photoeditor/actions/AutoFixAction.java
index 6b3f184b4..a41984084 100644
--- a/src/com/android/gallery3d/photoeditor/actions/AutoFixAction.java
+++ b/src/com/android/gallery3d/photoeditor/actions/AutoFixAction.java
@@ -37,6 +37,6 @@ public class AutoFixAction extends EffectAction {
AutoFixFilter filter = new AutoFixFilter();
filter.setScale(DEFAULT_SCALE);
notifyChanged(filter);
- notifyDone();
+ notifyOk();
}
}
diff --git a/src/com/android/gallery3d/photoeditor/actions/CrossProcessAction.java b/src/com/android/gallery3d/photoeditor/actions/CrossProcessAction.java
index 7369dc552..b61f6fae1 100644
--- a/src/com/android/gallery3d/photoeditor/actions/CrossProcessAction.java
+++ b/src/com/android/gallery3d/photoeditor/actions/CrossProcessAction.java
@@ -33,6 +33,6 @@ public class CrossProcessAction extends EffectAction {
@Override
public void prepare() {
notifyChanged(new CrossProcessFilter());
- notifyDone();
+ notifyOk();
}
}
diff --git a/src/com/android/gallery3d/photoeditor/actions/DocumentaryAction.java b/src/com/android/gallery3d/photoeditor/actions/DocumentaryAction.java
index d1fd61171..b7f9a9049 100644
--- a/src/com/android/gallery3d/photoeditor/actions/DocumentaryAction.java
+++ b/src/com/android/gallery3d/photoeditor/actions/DocumentaryAction.java
@@ -33,6 +33,6 @@ public class DocumentaryAction extends EffectAction {
@Override
public void prepare() {
notifyChanged(new DocumentaryFilter());
- notifyDone();
+ notifyOk();
}
}
diff --git a/src/com/android/gallery3d/photoeditor/actions/DuotoneAction.java b/src/com/android/gallery3d/photoeditor/actions/DuotoneAction.java
index 57082c064..3ba8aa5c3 100644
--- a/src/com/android/gallery3d/photoeditor/actions/DuotoneAction.java
+++ b/src/com/android/gallery3d/photoeditor/actions/DuotoneAction.java
@@ -39,6 +39,6 @@ public class DuotoneAction extends EffectAction {
DuotoneFilter filter = new DuotoneFilter();
filter.setDuotone(DEFAULT_FIRST_COLOR, DEFAULT_SECOND_COLOR);
notifyChanged(filter);
- notifyDone();
+ notifyOk();
}
}
diff --git a/src/com/android/gallery3d/photoeditor/actions/EffectAction.java b/src/com/android/gallery3d/photoeditor/actions/EffectAction.java
index c17ec232e..08b46e97f 100644
--- a/src/com/android/gallery3d/photoeditor/actions/EffectAction.java
+++ b/src/com/android/gallery3d/photoeditor/actions/EffectAction.java
@@ -19,7 +19,6 @@ package com.android.gallery3d.photoeditor.actions;
import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
-import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -37,46 +36,36 @@ public abstract class EffectAction extends LinearLayout {
/**
* Listener of effect action.
*/
- public interface Listener {
+ public interface ActionListener {
- void onClick();
-
- void onDone();
+ /**
+ * Invoked when the action is okayed (effect is applied and completed).
+ */
+ void onOk();
}
protected EffectToolFactory factory;
- private Listener listener;
private Toast tooltip;
private FilterStack filterStack;
private boolean pushedFilter;
private boolean disableFilterOutput;
private FilterChangedCallback lastFilterChangedCallback;
+ private ActionListener listener;
public EffectAction(Context context, AttributeSet attrs) {
super(context, attrs);
}
- public void setListener(Listener l) {
- listener = l;
- findViewById(R.id.effect_button).setOnClickListener(
- (listener == null) ? null : new View.OnClickListener() {
-
- @Override
- public void onClick(View v) {
- listener.onClick();
- }
- });
- }
-
public CharSequence name() {
return ((TextView) findViewById(R.id.effect_label)).getText();
}
- public void begin(FilterStack filterStack, EffectToolFactory factory) {
+ public void begin(FilterStack filterStack, EffectToolFactory factory, ActionListener listener) {
// This view is already detached from UI view hierarchy by reaching here; findViewById()
// could only access its own child views from here.
this.filterStack = filterStack;
this.factory = factory;
+ this.listener = listener;
// Shows the tooltip if it's available.
if (getTag() != null) {
@@ -151,10 +140,8 @@ public abstract class EffectAction extends LinearLayout {
}
}
- protected void notifyDone() {
- if (listener != null) {
- listener.onDone();
- }
+ protected void notifyOk() {
+ listener.onOk();
}
/**
diff --git a/src/com/android/gallery3d/photoeditor/actions/GrayscaleAction.java b/src/com/android/gallery3d/photoeditor/actions/GrayscaleAction.java
index 3ec468c52..f534ca87e 100644
--- a/src/com/android/gallery3d/photoeditor/actions/GrayscaleAction.java
+++ b/src/com/android/gallery3d/photoeditor/actions/GrayscaleAction.java
@@ -33,6 +33,6 @@ public class GrayscaleAction extends EffectAction {
@Override
public void prepare() {
notifyChanged(new GrayscaleFilter());
- notifyDone();
+ notifyOk();
}
}
diff --git a/src/com/android/gallery3d/photoeditor/actions/LomoishAction.java b/src/com/android/gallery3d/photoeditor/actions/LomoishAction.java
index 2061f282d..17af4297c 100644
--- a/src/com/android/gallery3d/photoeditor/actions/LomoishAction.java
+++ b/src/com/android/gallery3d/photoeditor/actions/LomoishAction.java
@@ -33,6 +33,6 @@ public class LomoishAction extends EffectAction {
@Override
public void prepare() {
notifyChanged(new LomoishFilter());
- notifyDone();
+ notifyOk();
}
}
diff --git a/src/com/android/gallery3d/photoeditor/actions/NegativeAction.java b/src/com/android/gallery3d/photoeditor/actions/NegativeAction.java
index f7de8718b..889315495 100644
--- a/src/com/android/gallery3d/photoeditor/actions/NegativeAction.java
+++ b/src/com/android/gallery3d/photoeditor/actions/NegativeAction.java
@@ -33,6 +33,6 @@ public class NegativeAction extends EffectAction {
@Override
public void prepare() {
notifyChanged(new NegativeFilter());
- notifyDone();
+ notifyOk();
}
}
diff --git a/src/com/android/gallery3d/photoeditor/actions/PosterizeAction.java b/src/com/android/gallery3d/photoeditor/actions/PosterizeAction.java
index 5fde60203..9a9f87481 100644
--- a/src/com/android/gallery3d/photoeditor/actions/PosterizeAction.java
+++ b/src/com/android/gallery3d/photoeditor/actions/PosterizeAction.java
@@ -33,6 +33,6 @@ public class PosterizeAction extends EffectAction {
@Override
public void prepare() {
notifyChanged(new PosterizeFilter());
- notifyDone();
+ notifyOk();
}
}
diff --git a/src/com/android/gallery3d/photoeditor/actions/SepiaAction.java b/src/com/android/gallery3d/photoeditor/actions/SepiaAction.java
index 96b33a080..5f551c8fc 100644
--- a/src/com/android/gallery3d/photoeditor/actions/SepiaAction.java
+++ b/src/com/android/gallery3d/photoeditor/actions/SepiaAction.java
@@ -33,6 +33,6 @@ public class SepiaAction extends EffectAction {
@Override
public void prepare() {
notifyChanged(new SepiaFilter());
- notifyDone();
+ notifyOk();
}
}
diff --git a/src/com/android/gallery3d/photoeditor/actions/TintAction.java b/src/com/android/gallery3d/photoeditor/actions/TintAction.java
index 886b172a0..54c234384 100644
--- a/src/com/android/gallery3d/photoeditor/actions/TintAction.java
+++ b/src/com/android/gallery3d/photoeditor/actions/TintAction.java
@@ -47,8 +47,8 @@ public class TintAction extends EffectAction {
}
}
});
- // Tint photo with the default color.
colorPicker.setColorIndex(DEFAULT_COLOR_INDEX);
+
filter.setTint(colorPicker.getColor());
notifyChanged(filter);
}