Adjusted feature flipper to run in background on startup and changed some ab probabilities

pull/14/head
Sam Bosley 14 years ago
parent fbdd8652db
commit e781bb3148

@ -25,6 +25,7 @@ import com.todoroo.astrid.gtasks.GtasksTaskListUpdater;
import com.todoroo.astrid.gtasks.sync.GtasksSyncOnSaveService; import com.todoroo.astrid.gtasks.sync.GtasksSyncOnSaveService;
import com.todoroo.astrid.service.abtesting.ABChooser; import com.todoroo.astrid.service.abtesting.ABChooser;
import com.todoroo.astrid.service.abtesting.ABOptions; import com.todoroo.astrid.service.abtesting.ABOptions;
import com.todoroo.astrid.service.abtesting.FeatureFlipper;
import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.utility.Constants;
@ -96,6 +97,7 @@ public class AstridDependencyInjector extends AbstractDependencyInjector {
// AB testing // AB testing
injectables.put("abChooser", ABChooser.class); injectables.put("abChooser", ABChooser.class);
injectables.put("abOptions", new ABOptions()); injectables.put("abOptions", new ABOptions());
injectables.put("featureFlipper", FeatureFlipper.class);
// com.todoroo.astrid.tags // com.todoroo.astrid.tags
injectables.put("tagService", TagService.class); injectables.put("tagService", TagService.class);

@ -82,6 +82,8 @@ public class StartupService {
@Autowired GtasksSyncOnSaveService gtasksSyncOnSaveService; @Autowired GtasksSyncOnSaveService gtasksSyncOnSaveService;
@Autowired FeatureFlipper featureFlipper;
/** /**
* bit to prevent multiple initializations * bit to prevent multiple initializations
*/ */
@ -182,7 +184,7 @@ public class StartupService {
new UpdateMessageService().processUpdates(context); new UpdateMessageService().processUpdates(context);
// Check for feature flips // Check for feature flips
new FeatureFlipper().updateFeatures(); featureFlipper.updateFeatures();
} }
}).start(); }).start();

@ -177,7 +177,7 @@ public class ABOptions {
public static final String AB_OPTION_FIRST_ACTIVITY = "ab_first_activity"; public static final String AB_OPTION_FIRST_ACTIVITY = "ab_first_activity";
private static final int[] AB_OPTION_FIRST_ACTIVITY_PROBS = { 1, 1 }; private static final int[] AB_OPTION_FIRST_ACTIVITY_PROBS = { 9, 1 };
private static final String[] AB_OPTION_FIRST_ACTIVITY_DESCRIPTIONS = { "ab-show-tasks-first", "ab-show-lists-first" }; private static final String[] AB_OPTION_FIRST_ACTIVITY_DESCRIPTIONS = { "ab-show-tasks-first", "ab-show-lists-first" };
private static final String[] AB_OPTION_FIRST_ACTIVITY_RELEVANT_EVENTS = { StatisticsConstants.CREATE_TASK, private static final String[] AB_OPTION_FIRST_ACTIVITY_RELEVANT_EVENTS = { StatisticsConstants.CREATE_TASK,
StatisticsConstants.TASK_CREATED_TASKLIST, StatisticsConstants.TASK_CREATED_TASKLIST,
@ -186,7 +186,7 @@ public class ABOptions {
StatisticsConstants.ACTFM_NEW_USER };//*/ StatisticsConstants.ACTFM_NEW_USER };//*/
public static final String AB_OPTION_WELCOME_LOGIN = "ab_welcome_login"; public static final String AB_OPTION_WELCOME_LOGIN = "ab_welcome_login";
private static final int[] AB_OPTION_WELCOME_LOGIN_PROBS = { 0, 1 }; private static final int[] AB_OPTION_WELCOME_LOGIN_PROBS = { 9, 1 };
private static final String[] AB_OPTION_WELCOME_LOGIN_DESCRIPTIONS = { "ab-welcome-login-show", "ab-welcome-login-skip" }; private static final String[] AB_OPTION_WELCOME_LOGIN_DESCRIPTIONS = { "ab-welcome-login-show", "ab-welcome-login-skip" };
private static final String[] AB_OPTION_WELCOME_LOGIN_RELEVANT_EVENTS = { StatisticsConstants.CREATE_TASK, private static final String[] AB_OPTION_WELCOME_LOGIN_RELEVANT_EVENTS = { StatisticsConstants.CREATE_TASK,
StatisticsConstants.TASK_CREATED_TASKLIST, StatisticsConstants.TASK_CREATED_TASKLIST,

@ -15,7 +15,6 @@ import android.text.TextUtils;
import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.HttpRestClient;
import com.todoroo.andlib.service.RestClient; import com.todoroo.andlib.service.RestClient;
import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.utility.Constants;
@ -28,7 +27,7 @@ public class FeatureFlipper {
private static final String KEY_SET_OPTION = "setOption"; private static final String KEY_SET_OPTION = "setOption";
private static final String KEY_PROBABILITIES = "probabilities"; private static final String KEY_PROBABILITIES = "probabilities";
private final RestClient restClient = new HttpRestClient(4000); @Autowired private RestClient restClient;
@Autowired private ABChooser abChooser; @Autowired private ABChooser abChooser;
@Autowired private ABOptions abOptions; @Autowired private ABOptions abOptions;
@ -41,7 +40,7 @@ public class FeatureFlipper {
* parses the result, and updates the AB settings for the corresponding features * parses the result, and updates the AB settings for the corresponding features
* @throws JSONException * @throws JSONException
*/ */
public void updateFeatures() { public synchronized void updateFeatures() {
JSONArray settingsBundle = requestOverrideSettings(); JSONArray settingsBundle = requestOverrideSettings();
if (settingsBundle == null || settingsBundle.length() == 0) if (settingsBundle == null || settingsBundle.length() == 0)
return; return;
@ -76,7 +75,7 @@ public class FeatureFlipper {
PackageInfo pi = pm.getPackageInfo(Constants.PACKAGE, PackageManager.GET_META_DATA); PackageInfo pi = pm.getPackageInfo(Constants.PACKAGE, PackageManager.GET_META_DATA);
int versionCode = pi.versionCode; int versionCode = pi.versionCode;
String result = restClient.get(URL + "?version=" + versionCode + "&" + String result = restClient.get(URL + "?version=" + versionCode + "&" +
"language=" + Locale.getDefault().getISO3Language()); //$NON-NLS-1$ "language=" + Locale.getDefault().getISO3Language());
if(TextUtils.isEmpty(result)) if(TextUtils.isEmpty(result))
return null; return null;

@ -15,14 +15,10 @@ import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.StartupService;
import com.todoroo.astrid.service.abtesting.ABChooser; import com.todoroo.astrid.service.abtesting.ABChooser;
import com.todoroo.astrid.service.abtesting.ABOptions; import com.todoroo.astrid.service.abtesting.ABOptions;
import com.todoroo.astrid.service.abtesting.FeatureFlipper;
import com.todoroo.astrid.utility.AstridPreferences; import com.todoroo.astrid.utility.AstridPreferences;
public class SplashScreenLauncher extends Activity { public class SplashScreenLauncher extends Activity {
private boolean isNewUser = false;
private int latestSetVersion = 0;
@Autowired ABChooser abChooser; @Autowired ABChooser abChooser;
static { static {
@ -35,33 +31,14 @@ public class SplashScreenLauncher extends Activity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
DependencyInjectionService.getInstance().inject(this); DependencyInjectionService.getInstance().inject(this);
setContentView(R.layout.splash_screen_launcher); setContentView(R.layout.splash_screen_launcher);
latestSetVersion = AstridPreferences.getCurrentVersion(); int latestSetVersion = AstridPreferences.getCurrentVersion();
isNewUser = (latestSetVersion == 0); boolean isNewUser = (latestSetVersion == 0);
ContextManager.setContext(this); ContextManager.setContext(this);
if (isNewUser) {
new Thread() {
@Override
public void run() {
new FeatureFlipper().updateFeatures();
runOnUiThread(new Runnable() {
@Override
public void run() {
startupServiceAndFinish();
}
});
}
}.start();
} else {
startupServiceAndFinish();
}
}
private void startupServiceAndFinish() {
new StartupService().onStartupApplication(this); new StartupService().onStartupApplication(this);
finishAndShowNext(); finishAndShowNext(isNewUser);
} }
private void finishAndShowNext() { private void finishAndShowNext(boolean isNewUser) {
if (isNewUser) { if (isNewUser) {
int welcomeLoginChoice = abChooser.getChoiceForOption(ABOptions.AB_OPTION_WELCOME_LOGIN); int welcomeLoginChoice = abChooser.getChoiceForOption(ABOptions.AB_OPTION_WELCOME_LOGIN);
welcomeLoginPath(welcomeLoginChoice); welcomeLoginPath(welcomeLoginChoice);

Loading…
Cancel
Save