From bc0cc935c6b999bd6191e046c5f525f0e08da397 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Mon, 13 Feb 2012 00:07:29 -0800 Subject: [PATCH] Fix for multiple help popovers showing up on top of each other --- .../astrid/activity/TaskListFragment.java | 4 ++++ .../astrid/utility/AstridPreferences.java | 13 ++++++++++ .../welcome/tutorial/WelcomeWalkthrough.java | 24 +++++++++---------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java index 9f4ec3ced..12c80d1cc 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java @@ -1094,6 +1094,8 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, } private void showTaskEditHelpPopover() { + if(!AstridPreferences.canShowPopover()) + return; if (!Preferences.getBoolean(R.string.p_showed_tap_task_help, false)) { InputMethodManager imm = (InputMethodManager) getActivity().getSystemService( Context.INPUT_METHOD_SERVICE); @@ -1123,6 +1125,8 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, } private void showListsHelp() { + if(!AstridPreferences.canShowPopover()) + return; if (!Preferences.getBoolean( R.string.p_showed_lists_help, false)) { if (AndroidUtilities.isTabletSized(getActivity())) { diff --git a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java index bb911f8b8..a8b42650e 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java @@ -23,6 +23,10 @@ public class AstridPreferences { public static final String P_FIRST_LAUNCH = "fltime"; //$NON-NLS-1$ + public static final String P_LAST_POPOVER = "lpopover"; //$NON-NLS-1$ + + private static final long MIN_POPOVER_TIME = 3 * 1000L; + /** Set preference defaults, if unset. called at startup */ public static void setPreferenceDefaults() { Context context = ContextManager.getContext(); @@ -66,4 +70,13 @@ public class AstridPreferences { Preferences.setInt(P_CURRENT_VERSION, version); } + /** If true, can show a help popover. If false, another one was recently shown */ + public static boolean canShowPopover() { + long last = Preferences.getLong(P_LAST_POPOVER, 0); + if(System.currentTimeMillis() - last < MIN_POPOVER_TIME) + return false; + Preferences.setLong(P_LAST_POPOVER, System.currentTimeMillis()); + return true; + } + } diff --git a/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java b/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java index 2f4b01250..cdb30b89a 100644 --- a/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java +++ b/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java @@ -69,27 +69,25 @@ public class WelcomeWalkthrough extends ActFmLoginActivity { findViewById(R.id.next).setVisibility( position == mAdapter.getCount()-1 ? View.GONE : View.VISIBLE); + if(currentPage == mAdapter.getCount()-1) { + OnClickListener done = new OnClickListener() { + @Override + public void onClick(View arg0) { + finish(); + } + }; + currentView.findViewById(R.id.welcome_walkthrough_title).setOnClickListener(done); + currentView.findViewById(R.id.welcome_walkthrough_image).setOnClickListener(done); + } } @Override protected void initializeUI() { if(mAdapter == null) return; - if(currentPage == mAdapter.getCount()-1) { - if(findViewById(R.id.fb_login) != null) { + if(currentPage == mAdapter.getCount()-1 && findViewById(R.id.fb_login) != null) { super.initializeUI(); setupLoginLater(); - } else { - OnClickListener done = new OnClickListener() { - @Override - public void onClick(View arg0) { - finish(); - } - }; - currentView.findViewById(R.id.welcome_walkthrough_title).setOnClickListener(done); - currentView.findViewById(R.id.welcome_walkthrough_image).setOnClickListener(done); - } - } }