From bbcf54daac7a4f377d669e7695107513cd89a4d3 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Wed, 29 Aug 2012 14:18:38 -0700 Subject: [PATCH] Show swipe between lists helper dialog to help with discovery --- astrid/res/values/strings-core.xml | 15 ++++++++---- .../astrid/activity/EditPreferences.java | 10 +++++++- .../astrid/activity/TaskListActivity.java | 3 +++ .../astrid/ui/TaskListFragmentPager.java | 23 +++++++++++++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index 897f34ea8..791027d26 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -651,10 +651,6 @@ Try and configure experimental features - - Swipe between lists - Controls the memory performance of swipe between lists - Use contact picker @@ -682,6 +678,12 @@ You will need to restart Astrid for this change to take effect + + + + Swipe between lists + Controls the memory performance of swipe between lists + No swipe Conserve Memory @@ -689,7 +691,6 @@ High Performance - Swipe between lists is disabled @@ -698,6 +699,10 @@ Uses more system resources + Swipe between lists + Swipe left or right to quickly move between lists + Change settings in Settings -> Appearance + %1$s - %2$s diff --git a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java index 970337a79..843dd7ba6 100644 --- a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java +++ b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java @@ -63,6 +63,7 @@ import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.sync.SyncProviderPreferences; import com.todoroo.astrid.ui.ContactListAdapter; +import com.todoroo.astrid.ui.TaskListFragmentPager; import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.utility.Flags; import com.todoroo.astrid.voice.VoiceInputAssistant; @@ -505,7 +506,14 @@ public class EditPreferences extends TodorooPreferenceActivity { else if (booleanPreference(preference, value, R.string.p_autoIdea, R.string.EPr_ideaAuto_desc_disabled, R.string.EPr_ideaAuto_desc_enabled)); else if (r.getString(R.string.p_swipe_lists_performance_key).equals(preference.getKey())) { - preference.setOnPreferenceChangeListener(new SetResultOnPreferenceChangeListener(RESULT_CODE_PERFORMANCE_PREF_CHANGED)); + preference.setOnPreferenceChangeListener(new SetResultOnPreferenceChangeListener(RESULT_CODE_PERFORMANCE_PREF_CHANGED) { + @Override + public boolean onPreferenceChange(Preference p, Object newValue) { + // If the user changes the setting themselves, no need to show the helper + Preferences.setBoolean(TaskListFragmentPager.PREF_SHOWED_SWIPE_HELPER, true); + return super.onPreferenceChange(p, newValue); + } + }); int index = 0; if(value instanceof String && !TextUtils.isEmpty((String)value)) diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index f0bebccf5..6f6cf72f3 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -374,6 +374,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener setCommentsCount(0); if (swipeIsEnabled()) { + TaskListFragmentPager.showSwipeBetweenHelper(this); tlfPager.showFilter((Filter) item); return true; } @@ -501,6 +502,8 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener fragment.initiateAutomaticSync(); fragment.requestCommentCountUpdate(); } + if (position != 0) + Preferences.setBoolean(TaskListFragmentPager.PREF_SHOWED_SWIPE_HELPER, true); } } diff --git a/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java b/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java index 537020da0..6dfecbbd4 100644 --- a/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java +++ b/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java @@ -5,6 +5,7 @@ */ package com.todoroo.astrid.ui; +import android.app.Activity; import android.content.Context; import android.graphics.Rect; import android.support.v4.view.PagerAdapter; @@ -14,14 +15,18 @@ import android.view.MotionEvent; import android.view.View; import com.timsu.astrid.R; +import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.adapter.TaskListFragmentPagerAdapter; import com.todoroo.astrid.api.Filter; +import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.utility.Flags; public class TaskListFragmentPager extends ViewPager { + public static final String PREF_SHOWED_SWIPE_HELPER = "showed_swipe_helper"; //$NON-NLS-1$ + public TaskListFragmentPager(Context context, AttributeSet attrs) { super(context, attrs); int offscreenPageLimit = Preferences.getIntegerFromString(R.string.p_swipe_lists_performance_key, 3); @@ -104,4 +109,22 @@ public class TaskListFragmentPager extends ViewPager { } return false; } + + @SuppressWarnings("nls") + public static void showSwipeBetweenHelper(Activity activity) { + if (!Preferences.getBoolean(PREF_SHOWED_SWIPE_HELPER, false)) { + String body = String.format("

%s



%s", + activity.getString(R.string.swipe_lists_helper_header), + "subtasks_horizontal.png", + activity.getString(R.string.swipe_lists_helper_subtitle)); + + String color = ThemeService.getDialogTextColor(); + String html = String.format("%s", + color, body); + + DialogUtilities.htmlDialog(activity, html, R.string.swipe_lists_helper_title); + + Preferences.setBoolean(PREF_SHOWED_SWIPE_HELPER, true); + } + } }