diff --git a/astrid/src/com/todoroo/astrid/service/AstridDependencyInjector.java b/astrid/src/com/todoroo/astrid/service/AstridDependencyInjector.java index ec7d46c18..bc355cebf 100644 --- a/astrid/src/com/todoroo/astrid/service/AstridDependencyInjector.java +++ b/astrid/src/com/todoroo/astrid/service/AstridDependencyInjector.java @@ -25,6 +25,7 @@ import com.todoroo.astrid.gtasks.GtasksTaskListUpdater; import com.todoroo.astrid.gtasks.sync.GtasksSyncOnSaveService; import com.todoroo.astrid.service.abtesting.ABChooser; import com.todoroo.astrid.service.abtesting.ABOptions; +import com.todoroo.astrid.service.abtesting.FeatureFlipper; import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.utility.Constants; @@ -96,6 +97,7 @@ public class AstridDependencyInjector extends AbstractDependencyInjector { // AB testing injectables.put("abChooser", ABChooser.class); injectables.put("abOptions", new ABOptions()); + injectables.put("featureFlipper", FeatureFlipper.class); // com.todoroo.astrid.tags injectables.put("tagService", TagService.class); diff --git a/astrid/src/com/todoroo/astrid/service/StartupService.java b/astrid/src/com/todoroo/astrid/service/StartupService.java index fe646a714..3675364f0 100644 --- a/astrid/src/com/todoroo/astrid/service/StartupService.java +++ b/astrid/src/com/todoroo/astrid/service/StartupService.java @@ -82,6 +82,8 @@ public class StartupService { @Autowired GtasksSyncOnSaveService gtasksSyncOnSaveService; + @Autowired FeatureFlipper featureFlipper; + /** * bit to prevent multiple initializations */ @@ -182,7 +184,7 @@ public class StartupService { new UpdateMessageService().processUpdates(context); // Check for feature flips - new FeatureFlipper().updateFeatures(); + featureFlipper.updateFeatures(); } }).start(); diff --git a/astrid/src/com/todoroo/astrid/service/abtesting/ABOptions.java b/astrid/src/com/todoroo/astrid/service/abtesting/ABOptions.java index c8c4c08f1..0f4ea9438 100644 --- a/astrid/src/com/todoroo/astrid/service/abtesting/ABOptions.java +++ b/astrid/src/com/todoroo/astrid/service/abtesting/ABOptions.java @@ -177,7 +177,7 @@ public class ABOptions { 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_RELEVANT_EVENTS = { StatisticsConstants.CREATE_TASK, StatisticsConstants.TASK_CREATED_TASKLIST, @@ -186,7 +186,7 @@ public class ABOptions { StatisticsConstants.ACTFM_NEW_USER };//*/ 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_RELEVANT_EVENTS = { StatisticsConstants.CREATE_TASK, StatisticsConstants.TASK_CREATED_TASKLIST, diff --git a/astrid/src/com/todoroo/astrid/service/abtesting/FeatureFlipper.java b/astrid/src/com/todoroo/astrid/service/abtesting/FeatureFlipper.java index 59284f626..d95457d78 100644 --- a/astrid/src/com/todoroo/astrid/service/abtesting/FeatureFlipper.java +++ b/astrid/src/com/todoroo/astrid/service/abtesting/FeatureFlipper.java @@ -15,7 +15,6 @@ import android.text.TextUtils; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.service.DependencyInjectionService; -import com.todoroo.andlib.service.HttpRestClient; import com.todoroo.andlib.service.RestClient; 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_PROBABILITIES = "probabilities"; - private final RestClient restClient = new HttpRestClient(4000); + @Autowired private RestClient restClient; @Autowired private ABChooser abChooser; @Autowired private ABOptions abOptions; @@ -41,7 +40,7 @@ public class FeatureFlipper { * parses the result, and updates the AB settings for the corresponding features * @throws JSONException */ - public void updateFeatures() { + public synchronized void updateFeatures() { JSONArray settingsBundle = requestOverrideSettings(); if (settingsBundle == null || settingsBundle.length() == 0) return; @@ -76,7 +75,7 @@ public class FeatureFlipper { PackageInfo pi = pm.getPackageInfo(Constants.PACKAGE, PackageManager.GET_META_DATA); int versionCode = pi.versionCode; String result = restClient.get(URL + "?version=" + versionCode + "&" + - "language=" + Locale.getDefault().getISO3Language()); //$NON-NLS-1$ + "language=" + Locale.getDefault().getISO3Language()); if(TextUtils.isEmpty(result)) return null; diff --git a/astrid/src/com/todoroo/astrid/welcome/SplashScreenLauncher.java b/astrid/src/com/todoroo/astrid/welcome/SplashScreenLauncher.java index 5a4243268..7399fd218 100644 --- a/astrid/src/com/todoroo/astrid/welcome/SplashScreenLauncher.java +++ b/astrid/src/com/todoroo/astrid/welcome/SplashScreenLauncher.java @@ -15,14 +15,10 @@ import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.service.StartupService; import com.todoroo.astrid.service.abtesting.ABChooser; import com.todoroo.astrid.service.abtesting.ABOptions; -import com.todoroo.astrid.service.abtesting.FeatureFlipper; import com.todoroo.astrid.utility.AstridPreferences; public class SplashScreenLauncher extends Activity { - private boolean isNewUser = false; - private int latestSetVersion = 0; - @Autowired ABChooser abChooser; static { @@ -35,33 +31,14 @@ public class SplashScreenLauncher extends Activity { super.onCreate(savedInstanceState); DependencyInjectionService.getInstance().inject(this); setContentView(R.layout.splash_screen_launcher); - latestSetVersion = AstridPreferences.getCurrentVersion(); - isNewUser = (latestSetVersion == 0); + int latestSetVersion = AstridPreferences.getCurrentVersion(); + boolean isNewUser = (latestSetVersion == 0); 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); - finishAndShowNext(); + finishAndShowNext(isNewUser); } - private void finishAndShowNext() { + private void finishAndShowNext(boolean isNewUser) { if (isNewUser) { int welcomeLoginChoice = abChooser.getChoiceForOption(ABOptions.AB_OPTION_WELCOME_LOGIN); welcomeLoginPath(welcomeLoginChoice);