Add AB tests for welcome login layout options

pull/14/head
Sam Bosley 13 years ago
parent b5cba05288
commit b2686e855c

@ -201,6 +201,8 @@ public class StartupService {
final int finalLatestVersion = latestSetVersion; final int finalLatestVersion = latestSetVersion;
abTests.externalInit(context);
abChooser.makeChoicesForAllTests(latestSetVersion == 0, taskService.getUserActivationStatus()); abChooser.makeChoicesForAllTests(latestSetVersion == 0, taskService.getUserActivationStatus());
abTestInvoker.reportAcquisition(); abTestInvoker.reportAcquisition();

@ -8,6 +8,11 @@ package com.todoroo.astrid.service.abtesting;
import java.util.HashMap; import java.util.HashMap;
import java.util.Set; import java.util.Set;
import android.accounts.Account;
import android.content.Context;
import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager;
/** /**
* Helper class to define options with their probabilities and descriptions * Helper class to define options with their probabilities and descriptions
* @author Sam Bosley <sam@astrid.com> * @author Sam Bosley <sam@astrid.com>
@ -20,6 +25,30 @@ public class ABTests {
initialize(); initialize();
} }
/**
* Initialization for any tests that require a context or other logic
* to be initialized should go here. This method is called from the startup
* service before any test choices are made, so it is safe to add
* tests here. It's also ok if this method is a no-op sometimes.
* @param context
*/
public void externalInit(Context context) {
// The outer 'if' statement is to prevent one test from being added one time
// and the other from being added later if the accounts changed
if (ABChooser.readChoiceForTest(AB_NEW_LOGIN_NO_GOOGLE) == ABChooser.NO_OPTION
&& ABChooser.readChoiceForTest(AB_NEW_LOGIN_YES_GOOGLE) == ABChooser.NO_OPTION) {
GoogleAccountManager am = new GoogleAccountManager(context);
Account[] accounts = am.getAccounts();
if (accounts == null || accounts.length == 0) {
addTest(AB_NEW_LOGIN_NO_GOOGLE, new int[] { 1, 1 },
new int[] { 1, 0 }, new String[] { "old-welcome", "new-welcome" }); //$NON-NLS-1$//$NON-NLS-2$
} else {
addTest(AB_NEW_LOGIN_YES_GOOGLE, new int[] { 1, 1, 1 },
new int[] { 1, 0, 0 }, new String[] { "old-welcome", "new-welcome", "new-quick-welcome" }); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
}
}
}
/** /**
* Gets the integer array of weighted probabilities for an option key * Gets the integer array of weighted probabilities for an option key
* @param key * @param key
@ -127,6 +156,10 @@ public class ABTests {
public static final String AB_DEFAULT_EDIT_TAB = "android_default_edit_tab"; //$NON-NLS-1$ public static final String AB_DEFAULT_EDIT_TAB = "android_default_edit_tab"; //$NON-NLS-1$
public static final String AB_NEW_LOGIN_NO_GOOGLE = "android_new_login_n_google"; //$NON-NLS-1$
public static final String AB_NEW_LOGIN_YES_GOOGLE = "android_new_login_y_google"; //$NON-NLS-1$
private void initialize() { private void initialize() {
addTest(AB_FEATURED_LISTS, new int[] { 1, 1 }, addTest(AB_FEATURED_LISTS, new int[] { 1, 1 },

@ -21,6 +21,8 @@ import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.service.abtesting.ABChooser;
import com.todoroo.astrid.service.abtesting.ABTests;
import com.viewpagerindicator.TitleProvider; import com.viewpagerindicator.TitleProvider;
public class WelcomePagerAdapter extends PagerAdapter implements TitleProvider public class WelcomePagerAdapter extends PagerAdapter implements TitleProvider
@ -59,7 +61,7 @@ public class WelcomePagerAdapter extends PagerAdapter implements TitleProvider
R.layout.welcome_walkthrough_page, R.layout.welcome_walkthrough_page,
R.layout.welcome_walkthrough_page, R.layout.welcome_walkthrough_page,
R.layout.welcome_walkthrough_page, R.layout.welcome_walkthrough_page,
R.layout.welcome_walkthrough_simple_login, R.layout.welcome_walkthrough_login_page,
}; };
private final Context context; private final Context context;
@ -77,6 +79,23 @@ public class WelcomePagerAdapter extends PagerAdapter implements TitleProvider
body[body.length - 1] = R.string.welcome_body_7_return; body[body.length - 1] = R.string.welcome_body_7_return;
} else { } else {
// Setup login page from AB tests // Setup login page from AB tests
if (ABChooser.readChoiceForTest(ABTests.AB_NEW_LOGIN_YES_GOOGLE) != ABChooser.NO_OPTION) {
int choice = ABChooser.readChoiceForTest(ABTests.AB_NEW_LOGIN_YES_GOOGLE);
switch (choice) {
case 1:
layouts[layouts.length - 1] = R.layout.actfm_login_activity;
break;
case 2:
layouts[layouts.length - 1] = R.layout.welcome_walkthrough_simple_login;
break;
default:
break;
}
} else if (ABChooser.readChoiceForTest(ABTests.AB_NEW_LOGIN_NO_GOOGLE) != ABChooser.NO_OPTION) {
int choice = ABChooser.readChoiceForTest(ABTests.AB_NEW_LOGIN_NO_GOOGLE);
if (choice == 1)
layouts[layouts.length - 1] = R.layout.actfm_login_activity;
}
} }
} }

Loading…
Cancel
Save