diff options
-rw-r--r-- | src/com/android/gallery3d/photoeditor/actions/EffectAction.java | 16 | ||||
-rw-r--r-- | src/com/android/gallery3d/photoeditor/actions/EffectToolKit.java | 23 |
2 files changed, 32 insertions, 7 deletions
diff --git a/src/com/android/gallery3d/photoeditor/actions/EffectAction.java b/src/com/android/gallery3d/photoeditor/actions/EffectAction.java index e7ab3378b..92bcee4a9 100644 --- a/src/com/android/gallery3d/photoeditor/actions/EffectAction.java +++ b/src/com/android/gallery3d/photoeditor/actions/EffectAction.java @@ -83,8 +83,14 @@ public abstract class EffectAction extends LinearLayout { * Ends the effect and then executes the runnable after the effect is finished. */ public void end(final Runnable runnableOnODone) { - // Remove created tools before ending and output the pushed filter if it wasn't outputted. - toolKit.close(); + // Cancel the tooltip if it's still showing. + if ((tooltip != null) && (tooltip.getView().getParent() != null)) { + tooltip.cancel(); + tooltip = null; + } + // End tool editing by canceling unfinished touch events. + toolKit.cancel(); + // Output the pushed filter if it wasn't outputted. if (pushedFilter && disableFilterOutput) { outputFilter(); } @@ -104,11 +110,7 @@ public abstract class EffectAction extends LinearLayout { } private void finish(Runnable runnableOnDone) { - // Close the tooltip if it's still showing. - if ((tooltip != null) && (tooltip.getView().getParent() != null)) { - tooltip.cancel(); - tooltip = null; - } + toolKit.close(); pushedFilter = false; disableFilterOutput = false; lastFilterChangedCallback = null; diff --git a/src/com/android/gallery3d/photoeditor/actions/EffectToolKit.java b/src/com/android/gallery3d/photoeditor/actions/EffectToolKit.java index 59c90ede2..fbb54d948 100644 --- a/src/com/android/gallery3d/photoeditor/actions/EffectToolKit.java +++ b/src/com/android/gallery3d/photoeditor/actions/EffectToolKit.java @@ -17,7 +17,9 @@ package com.android.gallery3d.photoeditor.actions; import android.content.Context; +import android.os.SystemClock; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; @@ -64,6 +66,27 @@ public class EffectToolKit { } /** + * Cancel pending touch events and stop dispatching further touch events to tools. + */ + public void cancel() { + long now = SystemClock.uptimeMillis(); + MotionEvent cancelEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0, 0, 0); + toolFullscreen.dispatchTouchEvent(cancelEvent); + toolPanel.dispatchTouchEvent(cancelEvent); + cancelEvent.recycle(); + View.OnTouchListener listener = new View.OnTouchListener() { + + @Override + public boolean onTouch(View v, MotionEvent event) { + // Consume all further touch events and don't dispatch them. + return true; + } + }; + toolFullscreen.setOnTouchListener(listener); + toolPanel.setOnTouchListener(listener); + } + + /** * Close to remove all created tools. */ public void close() { |