diff --git a/astrid/src/com/todoroo/astrid/service/StartupService.java b/astrid/src/com/todoroo/astrid/service/StartupService.java index 66b0b8095..88c61199d 100644 --- a/astrid/src/com/todoroo/astrid/service/StartupService.java +++ b/astrid/src/com/todoroo/astrid/service/StartupService.java @@ -50,6 +50,7 @@ import com.todoroo.astrid.reminders.ReengagementService; import com.todoroo.astrid.reminders.ReminderStartupReceiver; import com.todoroo.astrid.service.abtesting.ABChooser; import com.todoroo.astrid.service.abtesting.ABTestInvoker; +import com.todoroo.astrid.service.abtesting.ABTests; import com.todoroo.astrid.utility.AstridPreferences; import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.widget.TasksWidget.WidgetUpdateService; @@ -93,6 +94,8 @@ public class StartupService { @Autowired ABChooser abChooser; + @Autowired ABTests abTests; + @Autowired ABTestInvoker abTestInvoker; /** @@ -188,6 +191,15 @@ public class StartupService { final int finalLatestVersion = latestSetVersion; // For any uninitialized ab test, make sure an option is chosen + if (!AstridPreferences.useTabletLayout(context) + && Preferences.getIntegerFromString(R.string.p_swipe_lists_performance_key, 0) == 0) { // Have to add this here because a non-null context is needed + abTests.addTest(ABTests.AB_SWIPE_BETWEEN, new int[] { 3, 1 }, + new int[] { 3, 1 }, new String[] { "swipe-disabled", "swipe-enabled" }); //$NON-NLS-1$ //$NON-NLS-2$ + + // Haven't yet initialized this test--need to clear the pref once so setIfUnset will trigger correctly in setPreferenceDefaults + if (ABChooser.readChoiceForTest(ABTests.AB_SWIPE_BETWEEN) == ABChooser.NO_OPTION) + Preferences.clear(context.getString(R.string.p_swipe_lists_performance_key)); + } abChooser.makeChoicesForAllTests(latestSetVersion == 0, taskService.getUserActivationStatus()); abTestInvoker.reportAcquisition(); diff --git a/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java b/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java index bf8de3438..8e1eebef9 100644 --- a/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java +++ b/astrid/src/com/todoroo/astrid/service/abtesting/ABTests.java @@ -121,8 +121,12 @@ public class ABTests { public static final String AB_TASK_EDIT_TOAST = "android_task_edit_toast"; //$NON-NLS-1$ + public static final String AB_SWIPE_BETWEEN = "android_swipe_v2"; //$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$ + + // AB_SWIPE_BETWEEN has to be added in the startup service since it needs a non-null context for initialization } } diff --git a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java index 0db683fa9..2764430c1 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java @@ -61,7 +61,6 @@ public class AstridPreferences { Preferences.setIfUnset(prefs, editor, r, R.string.p_fontSize, 16); Preferences.setIfUnset(prefs, editor, r, R.string.p_showNotes, false); - Preferences.setIfUnset(prefs, editor, r, R.string.p_swipe_lists_performance_key, 0); Preferences.setIfUnset(prefs, editor, r, R.string.p_use_contact_picker, true); Preferences.setIfUnset(prefs, editor, r, R.string.p_field_missed_calls, true); @@ -75,6 +74,12 @@ public class AstridPreferences { Preferences.setIfUnset(prefs, editor, r, R.string.p_showEditToasts, ABChooser.readChoiceForTest(ABTests.AB_TASK_EDIT_TOAST) != 0); + int swipePerformance = 0; + if (ABChooser.readChoiceForTest(ABTests.AB_SWIPE_BETWEEN) == 1) + swipePerformance = 3; + + Preferences.setIfUnset(prefs, editor, r, R.string.p_swipe_lists_performance_key, swipePerformance); + 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); }