From 54f9393fd43fa81cee101b155160735f787d475b Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Wed, 29 Aug 2012 11:34:35 -0700 Subject: [PATCH] Add preference for showing task edit confirmation toasts, ab test --- .../com/todoroo/astrid/actfm/EditPeopleControlSet.java | 9 ++------- astrid/res/values/keys.xml | 3 +++ astrid/res/values/strings-core.xml | 3 +++ astrid/res/xml/preferences.xml | 5 +++++ .../com/todoroo/astrid/activity/TaskEditFragment.java | 10 ++++++---- .../com/todoroo/astrid/service/abtesting/ABTests.java | 5 ++++- .../com/todoroo/astrid/utility/AstridPreferences.java | 5 +++++ 7 files changed, 28 insertions(+), 12 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java b/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java index 726b12022..c68b6637f 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/EditPeopleControlSet.java @@ -831,7 +831,8 @@ public class EditPeopleControlSet extends PopupControlSet { } private void showSaveToast(String saveToast) { - if(saveToast == null) return; + if(saveToast == null || !Preferences.getBoolean(R.string.p_showEditToasts, false)) + return; int length = saveToast.contains("\n") ? //$NON-NLS-1$ Toast.LENGTH_LONG : Toast.LENGTH_SHORT; Toast.makeText(activity, saveToast, length).show(); @@ -882,12 +883,6 @@ public class EditPeopleControlSet extends PopupControlSet { values.add(message); } -// String tag = ((TextView) getSharedWithView().findViewById(R.id.tag_name)).getText().toString(); -// if(!TextUtils.isEmpty(tag)) { -// values.add("tag"); -// values.add(tag); -// } - return values.toArray(new Object[values.size()]); } diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index e85b7cca6..e5de6130e 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -70,6 +70,9 @@ account + + show_edit_toasts + 1 diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index eaa316074..897f34ea8 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -595,6 +595,9 @@ Font size on the main listing page + + Show task edit confirmations + Show Notes In Task diff --git a/astrid/res/xml/preferences.xml b/astrid/res/xml/preferences.xml index 5e0274704..1d6cce648 100644 --- a/astrid/res/xml/preferences.xml +++ b/astrid/res/xml/preferences.xml @@ -90,6 +90,11 @@ android:key="@string/p_show_featured_lists_labs" android:defaultValue="false"/> + + diff --git a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java index 8a652a712..65a37ae4e 100755 --- a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java @@ -971,8 +971,9 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { * Show toast for task edit canceling */ private void showCancelToast() { - Toast.makeText(getActivity(), R.string.TEA_onTaskCancel, - Toast.LENGTH_SHORT).show(); + if (Preferences.getBoolean(R.string.p_showEditToasts, false)) + Toast.makeText(getActivity(), R.string.TEA_onTaskCancel, + Toast.LENGTH_SHORT).show(); } protected void deleteButtonClick() { @@ -1005,8 +1006,9 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { * Show toast for task edit deleting */ private void showDeleteToast() { - Toast.makeText(getActivity(), R.string.TEA_onTaskDelete, - Toast.LENGTH_SHORT).show(); + if (Preferences.getBoolean(R.string.p_showEditToasts, false)) + Toast.makeText(getActivity(), R.string.TEA_onTaskDelete, + Toast.LENGTH_SHORT).show(); } private void startAttachFile() { diff --git a/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java b/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java index b3170c484..bf8de3438 100644 --- a/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java +++ b/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java @@ -119,7 +119,10 @@ public class ABTests { bundles.put(testKey, bundle); } + public static final String AB_TASK_EDIT_TOAST = "android_task_edit_toast"; //$NON-NLS-1$ + private void initialize() { - // + addTest(AB_TASK_EDIT_TOAST, new int[] { 1, 1 }, + new int[] { 1, 1 }, new String[] { "dont-show-toasts", "show-toasts" }); //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java index 746f85bb5..0db683fa9 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java @@ -23,6 +23,8 @@ import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.User; import com.todoroo.astrid.service.ThemeService; +import com.todoroo.astrid.service.abtesting.ABChooser; +import com.todoroo.astrid.service.abtesting.ABTests; public class AstridPreferences { @@ -70,6 +72,9 @@ public class AstridPreferences { Preferences.setIfUnset(prefs, editor, r, R.string.p_ideas_tab_enabled, true); + Preferences.setIfUnset(prefs, editor, r, R.string.p_showEditToasts, + ABChooser.readChoiceForTest(ABTests.AB_TASK_EDIT_TOAST) != 0); + if ("white-blue".equals(Preferences.getStringValue(R.string.p_theme))) { //$NON-NLS-1$ migrate from when white-blue wasn't the default Preferences.setString(R.string.p_theme, ThemeService.THEME_WHITE); }