From f8f27a3cb7af5e38005c2e87a89e24bbd1241f03 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Fri, 7 Dec 2012 14:38:15 -0800 Subject: [PATCH] Adjusted reengagement reminder intervals for new users --- .../astrid/reminders/ReengagementService.java | 12 +++++--- .../src/com/todoroo/astrid/dao/TaskDao.java | 29 +------------------ .../astrid/service/StartupService.java | 2 -- .../astrid/service/StatisticsConstants.java | 5 ---- 4 files changed, 9 insertions(+), 39 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementService.java b/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementService.java index 43c0c4a0d..aa4c324fc 100644 --- a/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementService.java +++ b/astrid/plugin-src/com/todoroo/astrid/reminders/ReengagementService.java @@ -14,6 +14,7 @@ import android.content.Intent; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.Preferences; +import com.todoroo.astrid.utility.AstridPreferences; import com.todoroo.astrid.utility.Constants; public final class ReengagementService { @@ -38,10 +39,13 @@ public final class ReengagementService { private static long getNextReminderTime() { int reengagementReminders = Preferences.getInt(PREF_REENGAGEMENT_COUNT, 1); int days; - if (reengagementReminders >= 4) - days = 10; - else - days = 2 + reengagementReminders * 2; + if (DateUtilities.now() - Preferences.getLong(AstridPreferences.P_FIRST_LAUNCH, 0) > DateUtilities.ONE_DAY * 30) { // Installed longer than 30 days + // Sequence: every 6, 8, 10 days + days = Math.min(10, 4 + 2 * reengagementReminders); + } else { + // Sequence: every 2, 3, 4, 5 days + days = Math.min(5, 1 + reengagementReminders); + } Date date = new Date(DateUtilities.now() + DateUtilities.ONE_DAY * days / 1000L * 1000L); date.setHours(18); diff --git a/astrid/src/com/todoroo/astrid/dao/TaskDao.java b/astrid/src/com/todoroo/astrid/dao/TaskDao.java index 79eaaceba..ad10fc4f5 100644 --- a/astrid/src/com/todoroo/astrid/dao/TaskDao.java +++ b/astrid/src/com/todoroo/astrid/dao/TaskDao.java @@ -29,9 +29,6 @@ import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.TaskApiDao; import com.todoroo.astrid.reminders.Notifications; import com.todoroo.astrid.reminders.ReminderService; -import com.todoroo.astrid.service.StatisticsConstants; -import com.todoroo.astrid.service.StatisticsService; -import com.todoroo.astrid.utility.AstridPreferences; /** * Data Access layer for {@link Task}-related operations. @@ -230,9 +227,9 @@ public class TaskDao extends DatabaseDao { ContentValues values = item.getSetValues(); boolean result = super.createNew(item); if(result) { - userRetentionMetrics(); afterSave(item, values); } + return result; } @@ -244,30 +241,6 @@ public class TaskDao extends DatabaseDao { } } - private void userRetentionMetrics() { - if(Preferences.getBoolean(AstridPreferences.P_FIRST_TASK, true)) { - StatisticsService.reportEvent(StatisticsConstants.USER_FIRST_TASK); - Preferences.setBoolean(AstridPreferences.P_FIRST_TASK, false); - } - - long firstLaunchTime = Preferences.getLong(AstridPreferences.P_FIRST_LAUNCH, 0); - long now = DateUtilities.now(); - long timeSinceFirst = now - firstLaunchTime; - if (timeSinceFirst < DateUtilities.ONE_DAY * 3 && !Preferences.getBoolean(StatisticsConstants.TASK_THREE_DAYS, false)) { - StatisticsService.reportEvent(StatisticsConstants.TASK_THREE_DAYS); - Preferences.setBoolean(StatisticsConstants.TASK_THREE_DAYS, true); - } else if (timeSinceFirst < DateUtilities.ONE_WEEK && !Preferences.getBoolean(StatisticsConstants.TASK_ONE_WEEK, false)) { - StatisticsService.reportEvent(StatisticsConstants.TASK_ONE_WEEK); - Preferences.setBoolean(StatisticsConstants.TASK_ONE_WEEK, true); - } else if (timeSinceFirst < 2 * DateUtilities.ONE_WEEK && !Preferences.getBoolean(StatisticsConstants.TASK_TWO_WEEKS, false)) { - StatisticsService.reportEvent(StatisticsConstants.TASK_TWO_WEEKS); - Preferences.setBoolean(StatisticsConstants.TASK_TWO_WEEKS, true); - } else if (timeSinceFirst < 3 * DateUtilities.ONE_WEEK && !Preferences.getBoolean(StatisticsConstants.TASK_THREE_WEEKS, false)) { - StatisticsService.reportEvent(StatisticsConstants.TASK_THREE_WEEKS); - Preferences.setBoolean(StatisticsConstants.TASK_THREE_WEEKS, true); - } - } - /** * Sets default reminders for the given task if reminders are not set * @param item diff --git a/astrid/src/com/todoroo/astrid/service/StartupService.java b/astrid/src/com/todoroo/astrid/service/StartupService.java index ca306f1f0..9c4ab8382 100644 --- a/astrid/src/com/todoroo/astrid/service/StartupService.java +++ b/astrid/src/com/todoroo/astrid/service/StartupService.java @@ -165,8 +165,6 @@ public class StartupService { if (Preferences.getLong(AstridPreferences.P_FIRST_LAUNCH, -1) < 0) { Preferences.setLong(AstridPreferences.P_FIRST_LAUNCH, DateUtilities.now()); } - } else { - Preferences.setLong(AstridPreferences.P_FIRST_LAUNCH, 0); } BeastModePreferences.assertHideUntilSectionExists(context, latestSetVersion); diff --git a/astrid/src/com/todoroo/astrid/service/StatisticsConstants.java b/astrid/src/com/todoroo/astrid/service/StatisticsConstants.java index 777f03aa5..63d82a974 100644 --- a/astrid/src/com/todoroo/astrid/service/StatisticsConstants.java +++ b/astrid/src/com/todoroo/astrid/service/StatisticsConstants.java @@ -93,9 +93,4 @@ public class StatisticsConstants { public static final String PREF_SHOW_FEATURED_LISTS = "pref-show-featured-lists"; public static final String PREF_CHANGED_PREFIX = "pref-changed-"; - - public static final String TASK_THREE_DAYS = "task-created-three-days"; - public static final String TASK_ONE_WEEK = "task-created-one-week"; - public static final String TASK_TWO_WEEKS = "task-created-two-weeks"; - public static final String TASK_THREE_WEEKS = "task-created-three-weeks"; }