diff --git a/astrid/src/com/todoroo/astrid/service/StartupService.java b/astrid/src/com/todoroo/astrid/service/StartupService.java index ab5be0db9..b0d48348b 100644 --- a/astrid/src/com/todoroo/astrid/service/StartupService.java +++ b/astrid/src/com/todoroo/astrid/service/StartupService.java @@ -212,7 +212,7 @@ public class StartupService { } }).start(); - abChooser.makeChoicesForAllTests(); + abChooser.makeChoicesForAllTests(latestSetVersion == 0, taskService.getUserActivationStatus()); AstridPreferences.setPreferenceDefaults(); trackABTestingData(); diff --git a/astrid/src/com/todoroo/astrid/service/TaskService.java b/astrid/src/com/todoroo/astrid/service/TaskService.java index e44a72e37..1e74be88f 100644 --- a/astrid/src/com/todoroo/astrid/service/TaskService.java +++ b/astrid/src/com/todoroo/astrid/service/TaskService.java @@ -17,6 +17,7 @@ import com.todoroo.andlib.sql.Functions; import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.DateUtilities; +import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.PermaSql; @@ -54,6 +55,10 @@ public class TaskService { public static final String TRANS_EDIT_SAVE = "task-edit-save"; //$NON-NLS-1$ public static final String TRANS_REPEAT_COMPLETE = "repeat-complete"; //$NON-NLS-1$ + + private static final int TOTAL_TASKS_FOR_ACTIVATION = 3; + private static final int COMPLETED_TASKS_FOR_ACTIVATION = 1; + private static final String PREF_USER_ACTVATED = "user-activated"; //$NON-NLS-1$ @Autowired private TaskDao taskDao; @@ -267,6 +272,30 @@ public class TaskService { return taskDao.query(Query.select(properties).withQueryTemplate(sql)); } + public boolean getUserActivationStatus() { + if (Preferences.getBoolean(PREF_USER_ACTVATED, false)) + return true; + + TodorooCursor all = query(Query.select(Task.ID)); + try { + if (all.getCount() < TOTAL_TASKS_FOR_ACTIVATION) + return false; + + TodorooCursor completed = query(Query.select(Task.ID).where(TaskCriteria.completed())); + try { + if (completed.getCount() < COMPLETED_TASKS_FOR_ACTIVATION) + return false; + } finally { + completed.close(); + } + } finally { + all.close(); + } + + Preferences.setBoolean(PREF_USER_ACTVATED, true); + return true; + } + /** * @param query * @return how many tasks are matched by this query