From 0a2ff5de4b27283027493dc54fc55031e4aa4884 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Thu, 26 Apr 2012 16:42:57 -0700 Subject: [PATCH] Move retention tracking to TLA onCreate since startup service may not run if app has been living in background --- .../com/todoroo/astrid/activity/TaskListActivity.java | 8 ++++++++ .../src/com/todoroo/astrid/service/StartupService.java | 9 --------- .../service/abtesting/ABTestEventReportingService.java | 10 ++++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index 10a17361c..0e9f4b692 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -26,6 +26,8 @@ import android.widget.PopupWindow.OnDismissListener; import android.widget.TextView; import com.timsu.astrid.R; +import com.todoroo.andlib.service.Autowired; +import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.sql.Functions; import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.utility.AndroidUtilities; @@ -45,6 +47,7 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.service.StatisticsConstants; import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.service.ThemeService; +import com.todoroo.astrid.service.abtesting.ABTestEventReportingService; import com.todoroo.astrid.tags.TagService; import com.todoroo.astrid.ui.DateChangedAlerts; import com.todoroo.astrid.ui.FragmentPopover; @@ -61,6 +64,8 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener /** token for indicating source of TLA launch */ public static final String TOKEN_SOURCE = "source"; //$NON-NLS-1$ + @Autowired private ABTestEventReportingService abTestEventReportingService; + private View listsNav; private ImageView listsNavDisclosure; private TextView lists; @@ -136,6 +141,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener protected void onCreate(Bundle savedInstanceState) { ThemeService.applyTheme(this); super.onCreate(savedInstanceState); + DependencyInjectionService.getInstance().inject(this); if (AndroidUtilities.isTabletSized(this)) { setContentView(R.layout.task_list_wrapper_activity_3pane); @@ -198,6 +204,8 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener if (getIntent().hasExtra(TOKEN_SOURCE)) { trackActivitySource(); } + + abTestEventReportingService.trackUserRetention(); } private boolean swipeIsEnabled() { diff --git a/astrid/src/com/todoroo/astrid/service/StartupService.java b/astrid/src/com/todoroo/astrid/service/StartupService.java index 8a18995bc..052d1fb6c 100644 --- a/astrid/src/com/todoroo/astrid/service/StartupService.java +++ b/astrid/src/com/todoroo/astrid/service/StartupService.java @@ -35,7 +35,6 @@ import com.todoroo.astrid.actfm.sync.ActFmSyncService; import com.todoroo.astrid.backup.BackupConstants; import com.todoroo.astrid.backup.BackupService; import com.todoroo.astrid.backup.TasksXmlImporter; -import com.todoroo.astrid.dao.ABTestEventDao; import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.gtasks.GtasksPreferenceService; import com.todoroo.astrid.gtasks.sync.GtasksSyncService; @@ -43,7 +42,6 @@ import com.todoroo.astrid.opencrx.OpencrxCoreUtils; import com.todoroo.astrid.producteev.ProducteevUtilities; import com.todoroo.astrid.reminders.ReminderStartupReceiver; import com.todoroo.astrid.service.abtesting.ABChooser; -import com.todoroo.astrid.service.abtesting.ABTestEventReportingService; import com.todoroo.astrid.service.abtesting.FeatureFlipper; import com.todoroo.astrid.utility.AstridPreferences; import com.todoroo.astrid.utility.Constants; @@ -90,10 +88,6 @@ public class StartupService { @Autowired ABChooser abChooser; - @Autowired ABTestEventReportingService abTestEventReportingService; - - @Autowired ABTestEventDao abTestEventDao; - /** * bit to prevent multiple initializations */ @@ -218,9 +212,6 @@ public class StartupService { // Check for feature flips featureFlipper.updateFeatures(); - - abTestEventDao.createRelativeDateEvents(); - abTestEventReportingService.pushAllUnreportedABTestEvents(); } }).start(); diff --git a/astrid/src/com/todoroo/astrid/service/abtesting/ABTestEventReportingService.java b/astrid/src/com/todoroo/astrid/service/abtesting/ABTestEventReportingService.java index d1793d7b3..a4cff58e1 100644 --- a/astrid/src/com/todoroo/astrid/service/abtesting/ABTestEventReportingService.java +++ b/astrid/src/com/todoroo/astrid/service/abtesting/ABTestEventReportingService.java @@ -36,6 +36,16 @@ public final class ABTestEventReportingService { DependencyInjectionService.getInstance().inject(this); } + public void trackUserRetention() { + new Thread(new Runnable() { + @Override + public void run() { + abTestEventDao.createRelativeDateEvents(); + pushAllUnreportedABTestEvents(); + } + }).start(); + } + public void pushAllUnreportedABTestEvents() { final TodorooCursor unreported = abTestEventDao.query(Query.select(ABTestEvent.PROPERTIES) .where(ABTestEvent.REPORTED.eq(0))