From 2b75a4de1e875933fecd000f66a72b24e3f1e897 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Thu, 17 May 2012 13:44:59 -0700 Subject: [PATCH] AB test the friends view, added descriptions for all the astrid labs features --- .../todoroo/astrid/core/LabsPreferences.java | 39 +++++++++++++++---- astrid/res/values/keys.xml | 3 ++ astrid/res/values/strings-core.xml | 13 +++++-- astrid/res/xml/preferences_labs.xml | 9 +++-- .../astrid/service/abtesting/ABTests.java | 5 ++- .../todoroo/astrid/ui/MainMenuPopover.java | 10 +++-- .../astrid/utility/AstridPreferences.java | 4 ++ 7 files changed, 64 insertions(+), 19 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java b/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java index 059719f31..558d3ea6b 100644 --- a/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java @@ -18,18 +18,22 @@ public class LabsPreferences extends TodorooPreferenceActivity { public static final int PERFORMANCE_SETTING_CHANGED = 3; + private final OnPreferenceChangeListener settingChangedListener = new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference p, Object newValue) { + setResult(PERFORMANCE_SETTING_CHANGED); + updatePreferences(p, newValue); + return true; + } + }; + @Override public void updatePreferences(Preference preference, Object value) { final Resources r = getResources(); - if (r.getString(R.string.p_swipe_lists_performance_key).equals(preference.getKey())) { - preference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference p, Object newValue) { - setResult(PERFORMANCE_SETTING_CHANGED); - return true; - } - }); + String key = preference.getKey(); + if (r.getString(R.string.p_swipe_lists_performance_key).equals(key)) { + preference.setOnPreferenceChangeListener(settingChangedListener); int index = 0; if(value instanceof String && !TextUtils.isEmpty((String)value)) @@ -40,6 +44,25 @@ public class LabsPreferences extends TodorooPreferenceActivity { String name = r.getStringArray(R.array.EPr_swipe_lists_performance_mode)[index]; String desc = r.getStringArray(R.array.EPr_swipe_lists_performance_desc)[index]; preference.setSummary(r.getString(R.string.EPr_swipe_lists_display, name, desc)); + } else if (r.getString(R.string.p_show_friends_view).equals(key)) { + preference.setOnPreferenceChangeListener(settingChangedListener); + if (value != null && (Boolean) value) { + preference.setSummary(R.string.EPr_show_friends_view_desc_enabled); + } else { + preference.setSummary(R.string.EPr_show_friends_view_desc_disabled); + } + } else if (r.getString(R.string.p_field_missed_calls).equals(key)) { + if (value != null && (Boolean) value) { + preference.setSummary(R.string.MCA_missed_calls_pref_desc_enabled); + } else { + preference.setSummary(R.string.MCA_missed_calls_pref_desc_disabled); + } + } else if (r.getString(R.string.p_use_contact_picker).equals(key)) { + if (value != null && (Boolean) value) { + preference.setSummary(R.string.EPr_use_contact_picker_desc_enabled); + } else { + preference.setSummary(R.string.EPr_use_contact_picker_desc_disabled); + } } } diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index 17c6ea356..a9e2cb513 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -49,6 +49,9 @@ field_missed_calls + + show_friends_view + 1 diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index 79004c201..130ba2d9f 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -496,7 +496,8 @@ Field missed calls - Astrid will notify you about missed calls and offer to remind you to call back + Astrid will notify you about missed calls and offer to remind you to call back + Astrid will not notify you about missed calls Call %1$s back at %2$s @@ -597,7 +598,7 @@ Astrid Labs - Try and configure upcoming features + Try and configure experimental features Swipe between lists @@ -605,7 +606,13 @@ Use contact picker - Display the system contact picker option in the task assignment window + The system contact picker option will be displayed in the task assignment window + The system contact picker option will not be displayed + + + Show Friends View + Friends menu item will be shown + Friends menu item will be hidden You will need to restart Astrid for this change to take effect diff --git a/astrid/res/xml/preferences_labs.xml b/astrid/res/xml/preferences_labs.xml index e5798c091..3b802ecc9 100644 --- a/astrid/res/xml/preferences_labs.xml +++ b/astrid/res/xml/preferences_labs.xml @@ -11,10 +11,11 @@ android:summary="@string/EPr_swipe_lists_performance_subtitle" /> + android:title="@string/EPr_use_contact_picker"/> + android:title="@string/MCA_missed_calls_pref_title"/> + diff --git a/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java b/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java index 7f24599d4..dbc45f1e8 100644 --- a/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java +++ b/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java @@ -115,7 +115,10 @@ public class ABTests { } private void initialize() { // Set up - //Calls to addTest go here + addTest(AB_TEST_FRIENDS_VIEW_AVAILABLE, new int[] { 1, 1 }, + new int[] { 8, 2 }, new String[] { "friends-view-disabled", "friends-view-enabled" }); //$NON-NLS-1$ //$NON-NLS-2$ } + public static final String AB_TEST_FRIENDS_VIEW_AVAILABLE = "friends-view"; //$NON-NLS-1$ + } diff --git a/astrid/src/com/todoroo/astrid/ui/MainMenuPopover.java b/astrid/src/com/todoroo/astrid/ui/MainMenuPopover.java index 8c9db62e0..e47292fae 100644 --- a/astrid/src/com/todoroo/astrid/ui/MainMenuPopover.java +++ b/astrid/src/com/todoroo/astrid/ui/MainMenuPopover.java @@ -16,6 +16,7 @@ import android.widget.TextView; import com.timsu.astrid.R; import com.todoroo.andlib.utility.AndroidUtilities; +import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.ui.TouchInterceptingFrameLayout.InterceptTouchListener; @@ -100,9 +101,12 @@ public class MainMenuPopover extends FragmentPopover implements InterceptTouchLi addMenuItem(R.string.TLA_menu_lists, ThemeService.getDrawable(R.drawable.icn_menu_lists, themeFlags), MAIN_MENU_ITEM_LISTS, null, topFixed); // Lists item - addMenuItem(R.string.TLA_menu_friends, - ThemeService.getDrawable(R.drawable.icn_menu_friends, themeFlags), - MAIN_MENU_ITEM_FRIENDS, null, topFixed); + + if (Preferences.getBoolean(R.string.p_show_friends_view, false)) + addMenuItem(R.string.TLA_menu_friends, + ThemeService.getDrawable(R.drawable.icn_menu_friends, themeFlags), + MAIN_MENU_ITEM_FRIENDS, null, topFixed); + addMenuItem(R.string.TLA_menu_search, ThemeService.getDrawable(R.drawable.icn_menu_search, themeFlags), MAIN_MENU_ITEM_SEARCH, null, topFixed); diff --git a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java index ab74289ba..0227592b9 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java @@ -11,6 +11,8 @@ import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.ThemeService; +import com.todoroo.astrid.service.abtesting.ABChooser; +import com.todoroo.astrid.service.abtesting.ABTests; public class AstridPreferences { @@ -51,6 +53,8 @@ public class AstridPreferences { Preferences.setIfUnset(prefs, editor, r, R.string.p_use_contact_picker, true); Preferences.setIfUnset(prefs, editor, r, R.string.p_field_missed_calls, true); + boolean friendsViewEnabled = (ABChooser.readChoiceForTest(ABTests.AB_TEST_FRIENDS_VIEW_AVAILABLE) == 1); + 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); }