From 87e38b30c92f8c717a1ee319c4f43e4bfdd9ce18 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 9 Apr 2012 17:43:59 -0700 Subject: [PATCH] Introduce a flag to help TaskListFragmentPager not intercept touch events in subtasks mode --- astrid/src/com/todoroo/astrid/ui/DraggableListView.java | 3 +++ .../src/com/todoroo/astrid/ui/TaskListFragmentPager.java | 9 +++++++++ astrid/src/com/todoroo/astrid/utility/Flags.java | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/astrid/src/com/todoroo/astrid/ui/DraggableListView.java b/astrid/src/com/todoroo/astrid/ui/DraggableListView.java index cb454c67b..60de9a3ea 100644 --- a/astrid/src/com/todoroo/astrid/ui/DraggableListView.java +++ b/astrid/src/com/todoroo/astrid/ui/DraggableListView.java @@ -41,6 +41,7 @@ import com.commonsware.cwac.tlv.TouchListView.DropListener; import com.commonsware.cwac.tlv.TouchListView.GrabberClickListener; import com.commonsware.cwac.tlv.TouchListView.SwipeListener; import com.timsu.astrid.R; +import com.todoroo.astrid.utility.Flags; public class DraggableListView extends ListView { @@ -422,6 +423,7 @@ public class DraggableListView extends ListView { mWindowManager.addView(v, mWindowParams); mDragView = v; mDragging = true; + Flags.set(Flags.TLFP_NO_INTERCEPT_TOUCH); } private void dragView(MotionEvent ev) { @@ -505,6 +507,7 @@ public class DraggableListView extends ListView { } mDragging = false; + Flags.checkAndClear(Flags.TLFP_NO_INTERCEPT_TOUCH); } // --- getters and setters diff --git a/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java b/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java index 407871fb8..9731343e0 100644 --- a/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java +++ b/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java @@ -4,10 +4,12 @@ import android.content.Context; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.util.AttributeSet; +import android.view.MotionEvent; import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.adapter.TaskListFragmentPagerAdapter; import com.todoroo.astrid.api.Filter; +import com.todoroo.astrid.utility.Flags; public class TaskListFragmentPager extends ViewPager { @@ -52,4 +54,11 @@ public class TaskListFragmentPager extends ViewPager { public TaskListFragment getCurrentFragment() { return (TaskListFragment) ((TaskListFragmentPagerAdapter) getAdapter()).lookupFragmentForPosition(getCurrentItem()); } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + if (!Flags.check(Flags.TLFP_NO_INTERCEPT_TOUCH)) + return super.onInterceptTouchEvent(ev); + return false; + } } diff --git a/astrid/src/com/todoroo/astrid/utility/Flags.java b/astrid/src/com/todoroo/astrid/utility/Flags.java index f1125f3fc..6a32714e6 100644 --- a/astrid/src/com/todoroo/astrid/utility/Flags.java +++ b/astrid/src/com/todoroo/astrid/utility/Flags.java @@ -31,6 +31,11 @@ public class Flags { */ public static final int TLA_RESUMED_FROM_VOICE_ADD = 1 << 6; + /** + * If set, indicates that TaskListFragmentPager should not intercept touch events + */ + public static final int TLFP_NO_INTERCEPT_TOUCH = 1 << 7; + public static boolean checkAndClear(int flag) { boolean set = (state & flag) > 0; state &= ~flag;