/**
   * Migration for existing users to assert that the "hide always" section divider exists in the
   * preferences. Knowing that this section will always be in the constructed list of controls
   * simplifies the logic a bit.
   *
   * @param c
   */
  public static void assertHideUntilSectionExists(Context c, long latestSetVersion) {
    if (latestSetVersion == 0) Preferences.setBoolean(BEAST_MODE_ASSERTED_HIDE_ALWAYS, true);

    if (Preferences.getBoolean(BEAST_MODE_ASSERTED_HIDE_ALWAYS, false)) return;

    String order = Preferences.getStringValue(BEAST_MODE_ORDER_PREF);
    String hideSectionPref = c.getString(R.string.TEA_ctrl_hide_section_pref);
    if (TextUtils.isEmpty(order)) {
      // create preference and stick hide always at the end of it
      String[] items = c.getResources().getStringArray(R.array.TEA_control_sets_prefs);
      StringBuilder builder = new StringBuilder();
      for (String item : items) {
        if (item.equals(hideSectionPref)) continue;
        builder.append(item);
        builder.append(BEAST_MODE_PREF_ITEM_SEPARATOR);
      }

      builder.append(hideSectionPref);
      builder.append(BEAST_MODE_PREF_ITEM_SEPARATOR);
      order = builder.toString();
    } else if (!order.contains(hideSectionPref)) {
      order += (hideSectionPref + BEAST_MODE_PREF_ITEM_SEPARATOR);
    }
    Preferences.setString(BEAST_MODE_ORDER_PREF, order);

    Preferences.setBoolean(BEAST_MODE_ASSERTED_HIDE_ALWAYS, true);
  }
Exemple #2
0
 private static void accept(Activity activity) {
   if (activity instanceof EulaCallback) {
     ((EulaCallback) activity).eulaAccepted();
   }
   Preferences.setBoolean(PREFERENCE_EULA_ACCEPTED, true);
   StatisticsService.reportEvent(StatisticsConstants.EULA_ACCEPTED);
 }
Exemple #3
0
 private void showTaskCreateHelpPopover() {
   if (!AstridPreferences.canShowPopover()) return;
   if (!Preferences.getBoolean(R.string.p_showed_add_task_help, false)) {
     Preferences.setBoolean(R.string.p_showed_add_task_help, true);
     HelpInfoPopover.showPopover(
         getActivity(), quickAddBar.getQuickAddBox(), R.string.help_popover_add_task, null);
   }
 }
 private void onVoiceReminderStatusChanged(final Preference preference, boolean newValue) {
   try {
     VoiceOutputService.getVoiceOutputInstance();
     if (newValue) VoiceOutputService.getVoiceOutputInstance().checkIsTTSInstalled();
   } catch (VerifyError e) {
     // doesn't work :(
     preference.setEnabled(false);
     Preferences.setBoolean(preference.getKey(), false);
   }
 }
 private static void setShowFriendsView() {
   // Show friends view if necessary
   boolean showFriends = false;
   TodorooCursor<User> users = PluginServices.getUserDao().query(Query.select(User.ID).limit(1));
   try {
     showFriends = users.getCount() > 0;
   } finally {
     users.close();
   }
   Preferences.setBoolean(R.string.p_show_friends_view, showFriends);
 }
Exemple #6
0
  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_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);
    }
  }
Exemple #7
0
  @Override
  public boolean persist(Metadata item) {
    if (!item.containsValue(Metadata.CREATION_DATE))
      item.setValue(Metadata.CREATION_DATE, DateUtilities.now());

    boolean state = super.persist(item);
    if (Preferences.getBoolean(AstridPreferences.P_FIRST_LIST, true)) {
      if (state && item.getValue(Metadata.KEY).equals(TagService.KEY)) {
        StatisticsService.reportEvent(StatisticsConstants.USER_FIRST_LIST);
        Preferences.setBoolean(AstridPreferences.P_FIRST_LIST, false);
      }
    }
    Astrid2TaskProvider.notifyDatabaseModification();
    return state;
  }
Exemple #8
0
  @Override
  public boolean persist(Metadata item) {
    if (!item.containsValue(Metadata.CREATION_DATE)) {
      item.setValue(Metadata.CREATION_DATE, DateUtilities.now());
    }

    boolean state = super.persist(item);
    if (Preferences.getBoolean(AstridPreferences.P_FIRST_LIST, true)) {
      if (state
          && item.containsNonNullValue(Metadata.KEY)
          && item.getValue(Metadata.KEY).equals(TaskToTagMetadata.KEY)) {
        Preferences.setBoolean(AstridPreferences.P_FIRST_LIST, false);
      }
    }
    Astrid2TaskProvider.notifyDatabaseModification();
    return state;
  }
Exemple #9
0
 private void showListsHelp() {
   if (!AstridPreferences.canShowPopover()) return;
   if (!Preferences.getBoolean(R.string.p_showed_lists_help, false)) {
     AstridActivity activity = (AstridActivity) getActivity();
     if (activity != null) {
       if (AstridPreferences.useTabletLayout(activity)) {
         FilterListFragment flf = activity.getFilterListFragment();
         if (flf != null) flf.showAddListPopover();
       } else {
         ActionBar ab = activity.getSupportActionBar();
         View anchor = ab.getCustomView().findViewById(R.id.lists_nav);
         HelpInfoPopover.showPopover(activity, anchor, R.string.help_popover_switch_lists, null);
       }
       Preferences.setBoolean(R.string.p_showed_lists_help, true);
     }
   }
 }
 private static void setShowFeaturedLists() {
   // Show featured lists if necessary
   boolean showFeaturedLists = false;
   TodorooCursor<TagData> featLists =
       PluginServices.getTagDataService()
           .query(
               Query.select(TagData.ID)
                   .where(Functions.bitwiseAnd(TagData.FLAGS, TagData.FLAG_FEATURED).gt(0))
                   .limit(1));
   try {
     showFeaturedLists = featLists.getCount() > 0;
   } finally {
     featLists.close();
   }
   Preferences.setBoolean(
       FeaturedListFilterExposer.PREF_SHOULD_SHOW_FEATURED_LISTS, showFeaturedLists);
 }
Exemple #11
0
  @Override
  public void onResume() {
    super.onResume();

    getActivity()
        .registerReceiver(
            detailReceiver, new IntentFilter(AstridApiConstants.BROADCAST_SEND_DETAILS));
    getActivity()
        .registerReceiver(
            detailReceiver, new IntentFilter(AstridApiConstants.BROADCAST_SEND_DECORATIONS));
    getActivity()
        .registerReceiver(
            refreshReceiver, new IntentFilter(AstridApiConstants.BROADCAST_EVENT_REFRESH));
    syncActionHelper.register();

    if (Flags.checkAndClear(Flags.REFRESH)) {
      refresh();
    }

    setUpBackgroundJobs();

    if (!Preferences.getBoolean(WelcomeWalkthrough.KEY_SHOWED_WELCOME_LOGIN, false)) {
      Preferences.setBoolean(WelcomeWalkthrough.KEY_SHOWED_WELCOME_LOGIN, true);
      Intent showWelcomeLogin = new Intent(getActivity(), WelcomeWalkthrough.class);
      showWelcomeLogin.putExtra(ActFmLoginActivity.SHOW_TOAST, false);
      startActivity(showWelcomeLogin);
      return;
    }

    if (!Preferences.getBoolean(R.string.p_showed_add_task_help, false)) {
      showTaskCreateHelpPopover();
    } else if (!Preferences.getBoolean(R.string.p_showed_tap_task_help, false)) {
      showTaskEditHelpPopover();
    } else if (!Preferences.getBoolean(R.string.p_showed_lists_help, false)) {
      showListsHelp();
    }
    refreshFilterCount();
    initiateAutomaticSync();
  }
Exemple #12
0
  /**
   * Return a change log string. Releases occur often enough that we don't expect change sets to be
   * localized.
   *
   * @param from
   * @param to
   * @return
   */
  @SuppressWarnings("nls")
  public void showChangeLog(Context context, int from) {
    if (!(context instanceof Activity) || from == 0) return;

    Preferences.clear(TagCaseMigrator.PREF_SHOW_MIGRATION_ALERT);

    Preferences.clear(AstridPreferences.P_UPGRADE_FROM);
    StringBuilder changeLog = new StringBuilder();

    if (from >= V4_2_0 && from < V4_2_1) {
      newVersionString(
          changeLog,
          "4.2.1 (6/08/12)",
          new String[] {
            "Fix for MyTouch 4G Lists",
            "Fixed a crash when adding tasks with due times to Google Calendar",
            "Better syncing of the people list",
            "Minor UI polish and bugfixes"
          });
    }

    if (from < V4_2_0) {
      newVersionString(
          changeLog,
          "4.2.0 (6/05/12)",
          new String[] {
            "Support for the Nook", "Fixed crash on large image attachments", "Minor bugfixes"
          });
    }

    if (from >= V4_1_3 && from < V4_1_3_1) {
      newVersionString(changeLog, "4.1.3.1 (5/18/12)", new String[] {"Fixed reminders for ICS"});
    }

    if (from >= V4_1_2 && from < V4_1_3) {
      newVersionString(
          changeLog,
          "4.1.3 (5/17/12)",
          new String[] {
            "Added ability to see shared tasks sorted by friend! Enable or disable "
                + "in Settings > Astrid Labs",
            "Fixed desktop shortcuts",
            "Fixed adding tasks from the Power Pack widget",
            "Fixed selecting photos on the Kindle Fire",
            "Various other minor bug and crash fixes"
          });
    }

    if (from >= V4_1_1 && from < V4_1_2) {
      newVersionString(
          changeLog, "4.1.2 (5/05/12)", new String[] {"Fixed some crashes and minor bugs"});
    }

    if (from < V4_1_1) {
      newVersionString(
          changeLog,
          "4.1.1 (5/04/12)",
          new String[] {
            "Respond to or set reminders for missed calls. This feature requires a new permission to read "
                + "the phone state.",
          });
    }

    if (from < V4_1_0) {
      newVersionString(
          changeLog,
          "4.1.0 (5/03/12)",
          new String[] {
            "Swipe between lists! Swipe left and right to move through your lists. Enable or adjust "
                + "in Settings > Astrid Labs",
            "Assign tasks to contacts without typing",
            "Links to tasks in comments",
            "Astrid.com sync improvements",
            "Other minor bugfixes",
          });
    }

    if (from >= V4_0_6 && from < V4_0_6_2) {
      newVersionString(
          changeLog,
          "4.0.6.2 (4/03/12)",
          new String[] {
            "Minor fix to backup migration fix to handle deleted tasks as well as completed tasks."
          });
    }

    if (from >= V4_0_6 && from < V4_0_6_1) {
      newVersionString(
          changeLog,
          "4.0.6.1 (4/03/12)",
          new String[] {
            "Fixed a bug where old tasks could become uncompleted. Sorry to those of you"
                + " who were affected by this! To recover, you can import your old tasks"
                + " from any backup file created before April 3 by clicking Menu -> Settings ->"
                + " Backups -> Manage Backups -> Import Tasks. Backup files from April 3 will start"
                + " with 'auto.120403'."
          });
    }

    if (from < V4_0_6) {
      newVersionString(
          changeLog,
          "4.0.6 (4/02/12)",
          new String[] {
            "Fixes and performance improvements to Astrid.com and Google Tasks sync",
            "Google TV support! (Beta)",
            "Fixed a bug that could put duetimes on tasks when changing timezones",
            "Fixed a rare crash when starting a task timer"
          });
    }

    if (from >= V4_0_0 && from < V4_0_5) {
      newVersionString(
          changeLog,
          "4.0.5 (3/22/12)",
          new String[] {
            "Better conflict resolution for Astrid.com sync",
            "Fixes and improvements to Gtasks sync",
            "Added option to report sync errors in sync preference screen"
          });
    }

    if (from >= V4_0_0 && from < V4_0_4) {
      newVersionString(
          changeLog,
          "4.0.4 (3/7/12)",
          new String[] {
            "Fixed crashes related to error reporting",
            "Fixed a crash when creating a task from the widget",
            "Fixed a bug where a manual sync wouldn't always start"
          });
    }

    if (from >= V4_0_0 && from < V4_0_3) {
      newVersionString(
          changeLog,
          "4.0.3 (3/6/12)",
          new String[] {
            "Fix some issues with Google Tasks sync. We're sorry to "
                + "everyone who's been having trouble with it!",
            "Updated translations for Portuguese, Chinese, German, Russian, and Dutch",
            "Centralize Android's menu key with in-app navigation",
            "Fixed crashes & improve crash logging",
          });
    }

    if (from >= V4_0_0 && from < V4_0_2) {
      newVersionString(
          changeLog,
          "4.0.2 (2/29/12)",
          new String[] {
            "Removed GPS permission - no longer needed",
            "Fixes for some subtasks issues",
            "No longer need to run the Crittercism service in the background",
            "Fixed a crash that could occur when cloning tasks",
            "Fixed a bug that prevented certain comments from syncing correctly",
            "Fixed issues where voice add wouldn't work correctly",
          });
    }

    if (from >= V4_0_0 && from < V4_0_1) {
      newVersionString(
          changeLog,
          "4.0.1 (2/23/12)",
          new String[] {
            "Fixed a database issue affecting Android 2.1 users",
            "Fixed a crash when using drag and drop in Google Tasks lists",
            "Other small bugfixes"
          });
    }

    if (from < V4_0_0) {
      newVersionString(
          changeLog,
          "4.0.0 (2/23/12)",
          new String[] {
            "Welcome to Astrid 4.0! Here's what's new:",
            "<b>Subtasks!!!</b><br>Press the Menu key and select 'Sort' to access",
            "<b>New Look!</b><br>Customize how Astrid looks from the Settings menu",
            "<b>Task Rabbit!</b><br>Outsource your tasks with the help of trustworthy people",
            "<b>More Reliable Sync</b><br>Including fixes to Astrid.com and Google Tasks sync",
            "<b>Tablet version</b><br>Enjoy Astrid on your luxurious Android tablet",
            "Many bug and usability fixes"
          });
    }

    // --- old messages

    if (from >= V3_0_0 && from < V3_9_0) {
      newVersionString(
          changeLog,
          "3.9 (12/09/11)",
          new String[] {
            "Cleaner design (especially the task edit page)!",
            "Customize the edit page (\"Beast Mode\" in preferences)",
            "Make shared lists with tasks open to anyone (perfect for potlucks, road trips etc)",
            "Fixes for some ICS crashes (full support coming soon)",
            "Google Tasks sync improvement - Note: If you have been experiencing \"Sync with errors\", try logging out and logging back in to Google Tasks.",
            "Other minor bug fixes",
            "Feedback welcomed!"
          });
    }

    if (from >= V3_0_0 && from < V3_8_0) {
      newVersionString(
          changeLog,
          "3.8.0 (7/15/11)",
          new String[] {
            "Astrid.com: sync & share tasks / lists with others!",
            "GTasks Sync using Google's official task API! Gtasks users "
                + "will need to perform a manual sync to set everything up.",
            "Renamed \"Tags\" to \"Lists\" (see blog.astrid.com for details)",
            "New style for \"Task Edit\" page!",
            "Purge completed or deleted tasks from settings menu!",
          });
      gtasksPreferenceService.setToken(null);
    }

    if (from >= V3_0_0 && from < V3_7_0) {
      newVersionString(
          changeLog,
          "3.7.0 (2/7/11)",
          new String[] {
            "Improved UI for displaying task actions. Tap a task to "
                + "bring up actions, tap again to dismiss.",
            "Task notes can be viewed by tapping the note icon to " + "the right of the task.",
            "Added Astrid as 'Send-To' choice in Android Browser and " + "other apps.",
            "Add tags and importance in quick-add, e.g. " + "\"call mom #family @phone !4\"",
            "Fixed bug with custom filters & tasks being hidden.",
          });
      upgrade3To3_7();
      if (gtasksPreferenceService.isLoggedIn()) taskService.clearDetails(Criterion.all);
      Preferences.setBoolean(Eula.PREFERENCE_EULA_ACCEPTED, true);
    }
    if (from >= V3_0_0 && from < V3_6_0) {
      newVersionString(
          changeLog,
          "3.6.0 (11/13/10)",
          new String[] {
            "Astrid Power Pack is now launched to the Android Market. "
                + "New Power Pack features include 4x2 and 4x4 widgets and voice "
                + "task reminders and creation. Go to the add-ons page to find out more!",
            "Fix for Google Tasks: due times got lost on sync, repeating tasks not repeated",
            "Fix for task alarms not always firing if multiple set",
            "Fix for various force closes",
          });
      upgrade3To3_6(context);
    }
    if (from >= V3_0_0 && from < V3_5_0)
      newVersionString(
          changeLog,
          "3.5.0 (10/25/10)",
          new String[] {
            "Google Tasks Sync (beta!)",
            "Bug fix with RMilk & new tasks not getting synced",
            "Fixed Force Closes and other bugs",
          });
    if (from >= V3_0_0 && from < V3_4_0) {
      newVersionString(
          changeLog,
          "3.4.0 (10/08/10)",
          new String[] {
            "End User License Agreement",
            "Option to disable usage statistics",
            "Bug fixes with Producteev",
          });
    }
    if (from >= V3_0_0 && from < V3_3_0)
      newVersionString(
          changeLog,
          "3.3.0 (9/17/10)",
          new String[] {
            "Fixed some RTM duplicated tasks issues",
            "UI updates based on your feedback",
            "Snooze now overrides other alarms",
            "Added preference option for selecting snooze style",
            "Hide until: now allows you to pick a specific time",
          });
    if (from >= V3_0_0 && from < V3_2_0)
      newVersionString(
          changeLog,
          "3.2.0 (8/16/10)",
          new String[] {
            "Build your own custom filters from the Filter page",
            "Easy task sorting (in the task list menu)",
            "Create widgets from any of your filters",
            "Synchronize with Producteev! (producteev.com)",
            "Select tags by drop-down box",
            "Cosmetic improvements, calendar & sync bug fixes",
          });
    if (from >= V3_0_0 && from < V3_1_0)
      newVersionString(
          changeLog,
          "3.1.0 (8/9/10)",
          new String[] {
            "Linkify phone numbers, e-mails, and web pages",
            "Swipe L => R to go from tasks to filters",
            "Moved task priority bar to left side",
            "Added ability to create fixed alerts for a task",
            "Restored tag hiding when tag begins with underscore (_)",
            "FROYO: disabled moving app to SD card, it would break alarms and widget",
            "Also gone: a couple force closes, bugs with repeating tasks",
          });

    if (changeLog.length() == 0) return;

    changeLog.append("Have a spectacular day!</body></html>");
    String color = ThemeService.getDialogTextColor();
    String changeLogHtml = "<html><body style='color: " + color + "'>" + changeLog;

    DialogUtilities.htmlDialog(context, changeLogHtml, R.string.UpS_changelog_title);
  }
  public void checkAndMigrateLegacy() throws IOException {
    if (!gtasksPreferenceService.migrationHasOccurred()) {

      // Fetch all tasks that have associated gtask metadata
      String defaultListTitle =
          gtasksListService.getListName(
              Preferences.getStringValue(GtasksPreferenceService.PREF_DEFAULT_LIST));
      String defaultListId = null;

      TodorooCursor<Task> allTasksWithGtaskData =
          taskService.query(
              Query.select(Task.PROPERTIES)
                  .where(
                      Task.ID.in(
                          Query.select(Metadata.TASK)
                              .from(Metadata.TABLE)
                              .where(Metadata.KEY.eq(GtasksMetadata.METADATA_KEY)))));

      try {
        if (allTasksWithGtaskData.getCount() > 0) {
          // Fetch all remote tasks from all remote lists (this may be an expensive operation)
          // and map their titles to their real remote ids
          HashMap<String, String> taskAndListTitlesToRemoteTaskIds = new HashMap<String, String>();

          List<TaskList> items = allLists.getItems();
          for (TaskList list : items) {
            if (list.getTitle().equals(defaultListTitle)) {
              defaultListId = list.getId();
            }

            Tasks allTasks = gtasksService.getAllGtasksFromListId(list.getId(), false, false, 0);

            List<com.google.api.services.tasks.model.Task> tasksItems = allTasks.getItems();
            if (tasksItems != null) {
              for (com.google.api.services.tasks.model.Task t : tasksItems) {
                String key = constructKeyFromTitles(t.getTitle(), list.getTitle());
                taskAndListTitlesToRemoteTaskIds.put(key, t.getId());
              }
            }
          }

          if (defaultListId == null) {
            com.google.api.services.tasks.model.TaskList defaultList =
                gtasksService.getGtaskList("@default"); // $NON-NLS-1$
            defaultListId = defaultList.getId();
          }
          Preferences.setString(GtasksPreferenceService.PREF_DEFAULT_LIST, defaultListId);

          // For each local task, check to see if its title paired with any list title has a match
          // in the map
          for (allTasksWithGtaskData.moveToFirst();
              !allTasksWithGtaskData.isAfterLast();
              allTasksWithGtaskData.moveToNext()) {
            GtasksTaskContainer container =
                gtasksMetadataService.readTaskAndMetadata(allTasksWithGtaskData);
            // memorize the original listname for the case that the task is not matched,
            // then it should at least be recreated in the correct list
            String originalListName =
                gtasksListService.getListName(
                    container.gtaskMetadata.getValue(GtasksMetadata.LIST_ID));
            String originalListId = null;

            // Search through lists to see if one of them has match
            String taskTitle = container.task.getValue(Task.TITLE);
            boolean foundMatch = false;
            items = allLists.getItems();
            for (TaskList list : items) {
              String expectedKey = constructKeyFromTitles(taskTitle, list.getTitle());

              // save the new id of the current list
              // if it matches the listname of the current task
              if (list.getTitle() != null && list.getTitle().equals(originalListName)) {
                originalListId = list.getId();
              }

              if (taskAndListTitlesToRemoteTaskIds.containsKey(expectedKey)) {
                foundMatch = true;
                String newRemoteTaskId = taskAndListTitlesToRemoteTaskIds.get(expectedKey);
                String newRemoteListId = list.getId();

                container.gtaskMetadata.setValue(GtasksMetadata.ID, newRemoteTaskId);
                container.gtaskMetadata.setValue(GtasksMetadata.LIST_ID, newRemoteListId);
                gtasksMetadataService.saveTaskAndMetadata(container);
                break;
              }
            }

            if (!foundMatch) {
              // For non-matches, make the task look newly created
              container.gtaskMetadata = GtasksMetadata.createEmptyMetadata(container.task.getId());
              container.gtaskMetadata.setValue(GtasksMetadata.ID, ""); // $NON-NLS-1$
              if (originalListId != null) {
                // set the list-id based on the original listname, saved above during for-loop
                container.gtaskMetadata.setValue(GtasksMetadata.LIST_ID, originalListId);
              } else {
                // remote list or local list was renamed, so put this unmatched task in the default
                // list
                container.gtaskMetadata.setValue(GtasksMetadata.LIST_ID, defaultListId);
              }
              gtasksMetadataService.saveTaskAndMetadata(container);
              break;
            }
          }
        }

        // migrate the list-id's afterwards, so that we can put the non-matched tasks in their
        // original lists
        // if the listnames didnt change before migration (defaultlist otherwise)
        listService.migrateListIds(allLists);

      } finally {
        allTasksWithGtaskData.close();
      }
      Preferences.setBoolean(
          GtasksPreferenceService.PREF_MIGRATION_HAS_OCCURRED, true); // Record successful migration
    }
  }
  private static void setNormalPreferenceDefaults() {
    Context context = ContextManager.getContext();
    SharedPreferences prefs = Preferences.getPrefs(context);
    Editor editor = prefs.edit();
    Resources r = context.getResources();

    Preferences.setIfUnset(prefs, editor, r, R.string.p_default_urgency_key, 0);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_default_importance_key, 2);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_default_hideUntil_key, 0);
    Preferences.setIfUnset(
        prefs,
        editor,
        r,
        R.string.p_default_reminders_key,
        Task.NOTIFY_AT_DEADLINE | Task.NOTIFY_AFTER_DEADLINE);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_rmd_default_random_hours, 0);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_fontSize, 16);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_showNotes, false);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_use_contact_picker, true);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_field_missed_calls, true);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_third_party_addons, false);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_end_at_deadline, true);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_rmd_persistent, true);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_ideas_tab_enabled, true);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_show_featured_lists, true);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_taskRowStyle, false);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_calendar_reminders, true);

    String dragDropTestInitialized = "android_drag_drop_initialized"; // $NON-NLS-1$
    if (!Preferences.getBoolean(dragDropTestInitialized, false)) {
      SharedPreferences publicPrefs = getPublicPrefs(context);
      if (publicPrefs != null) {
        Editor edit = publicPrefs.edit();
        if (edit != null) {
          edit.putInt(SortHelper.PREF_SORT_FLAGS, SortHelper.FLAG_DRAG_DROP);
          edit.putInt(SortHelper.PREF_SORT_SORT, SortHelper.SORT_AUTO);
          edit.commit();
          Preferences.setInt(P_SUBTASKS_HELP, 1);
        }
      }
      Preferences.setBoolean(dragDropTestInitialized, true);
    }

    if ("white-blue"
        .equals(
            Preferences.getStringValue(
                R.string.p_theme))) { // $NON-NLS-1$ migrate from when white-blue wasn't the default
      Preferences.setString(R.string.p_theme, ThemeService.THEME_WHITE);
    }

    if (Constants.MARKET_STRATEGY.defaultPhoneLayout()) {
      Preferences.setIfUnset(prefs, editor, r, R.string.p_force_phone_layout, true);
    }

    setShowFriendsView();

    setShowFeaturedLists();

    editor.commit();
  }
  private static void setLitePreferenceDefaults() {
    Context context = ContextManager.getContext();
    SharedPreferences prefs = Preferences.getPrefs(context);
    Editor editor = prefs.edit();
    Resources r = context.getResources();

    Preferences.setIfUnset(prefs, editor, r, R.string.p_default_urgency_key, 4);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_default_importance_key, 2);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_default_hideUntil_key, 0);

    Preferences.setIfUnset(
        prefs,
        editor,
        r,
        R.string.p_default_reminders_key,
        Task.NOTIFY_AT_DEADLINE | Task.NOTIFY_AFTER_DEADLINE);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_default_reminders_mode_key, 16);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_rmd_default_random_hours, 0);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_fontSize, 18);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_showNotes, false);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_use_contact_picker, false);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_field_missed_calls, true);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_third_party_addons, false);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_end_at_deadline, true);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_rmd_persistent, true);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_ideas_tab_enabled, false);
    Preferences.setIfUnset(prefs, editor, r, R.string.p_autoIdea, false);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_show_featured_lists, false);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_taskRowStyle, true);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_calendar_reminders, true);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_use_filters, false);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_simple_input_boxes, true);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_show_list_members, false);

    String dragDropTestInitialized = "android_drag_drop_initialized"; // $NON-NLS-1$
    if (!Preferences.getBoolean(dragDropTestInitialized, false)) {
      SharedPreferences publicPrefs = getPublicPrefs(context);
      if (publicPrefs != null) {
        Editor edit = publicPrefs.edit();
        if (edit != null) {
          edit.putInt(SortHelper.PREF_SORT_FLAGS, SortHelper.FLAG_DRAG_DROP);
          edit.putInt(SortHelper.PREF_SORT_SORT, SortHelper.SORT_AUTO);
          edit.commit();
          Preferences.setInt(P_SUBTASKS_HELP, 1);
        }
      }
      Preferences.setBoolean(dragDropTestInitialized, true);
    }

    BeastModePreferences.setDefaultLiteModeOrder(context);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_theme, ThemeService.THEME_WHITE_RED);

    Preferences.setIfUnset(prefs, editor, r, R.string.p_force_phone_layout, true);

    setShowFriendsView();

    setShowFeaturedLists();

    editor.commit();
  }