From 947f0fe1b73dac6846940b1407a68b4759fde6b7 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 6 Feb 2012 12:10:37 -0800 Subject: [PATCH] Fixed beast mode bugs and cleaned up some unecessary beast mode code --- astrid/res/values/keys.xml | 9 +-- .../astrid/activity/BeastModePreferences.java | 75 +------------------ .../astrid/activity/TaskEditFragment.java | 5 +- .../astrid/service/StartupService.java | 2 - 4 files changed, 8 insertions(+), 83 deletions(-) diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index 5e34d817f..aac97bbcb 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -355,8 +355,9 @@ @string/TEA_control_reminders @string/TEA_control_timer @string/TEA_control_share - - + + + @string/TEA_control_title @string/TEA_control_who @string/TEA_control_when @@ -369,8 +370,7 @@ @string/TEA_control_share - - TEA_ctrl_title_pref + TEA_ctrl_title_pref TEA_ctrl_who_pref TEA_ctrl_when_pref TEA_ctrl_more_pref @@ -382,7 +382,6 @@ TEA_ctrl_share_pref - @string/TEA_ctrl_who_pref @string/TEA_ctrl_when_pref @string/TEA_ctrl_more_pref diff --git a/astrid/src/com/todoroo/astrid/activity/BeastModePreferences.java b/astrid/src/com/todoroo/astrid/activity/BeastModePreferences.java index 1f8dc450e..8d290aa45 100644 --- a/astrid/src/com/todoroo/astrid/activity/BeastModePreferences.java +++ b/astrid/src/com/todoroo/astrid/activity/BeastModePreferences.java @@ -4,10 +4,8 @@ import java.util.ArrayList; import java.util.HashMap; import android.app.ListActivity; -import android.content.Context; import android.content.res.Resources; import android.os.Bundle; -import android.text.TextUtils; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; @@ -32,74 +30,8 @@ public class BeastModePreferences extends ListActivity { public static final String BEAST_MODE_PREF_ITEM_SEPARATOR = ";"; //$NON-NLS-1$ - private static final String BEAST_MODE_MORE_ITEM_SPECIAL_CHAR = "-"; //$NON-NLS-1$ - - private static final String BEAST_MODE_MIGRATE_PREF = "beast_mode_migrate"; //$NON-NLS-1$ - private HashMap prefsToDescriptions; - // Migration function to fix the fact that I stupidly chose to use the control - // set names (which are localized and subject to change) as the values in the beast - // mode preferences - public static void migrateBeastModePreferences(Context context) { - boolean hasMigratedBeastMode = Preferences.getBoolean(BEAST_MODE_MIGRATE_PREF, false); - if (hasMigratedBeastMode) return; - String setPref = Preferences.getStringValue(BEAST_MODE_ORDER_PREF); - if (setPref == null) { - Preferences.setBoolean(BEAST_MODE_MIGRATE_PREF, true); - return; - } - - ArrayList defaults = new ArrayList(); - String[] defaultOrder = context.getResources().getStringArray(R.array.TEA_control_sets); - for (int i = 1; i < defaultOrder.length; i++) { - String s = defaultOrder[i]; - if (s.contains(BEAST_MODE_MORE_ITEM_SPECIAL_CHAR)) { - String[] split = s.split(BEAST_MODE_MORE_ITEM_SPECIAL_CHAR); - for (String component : split) { - if (!TextUtils.isEmpty(component)) { - s = component; - break; - } - } - } - defaults.add(s); - } - - ArrayList setOrder = new ArrayList(); - String[] setOrderArray = setPref.split(BEAST_MODE_PREF_ITEM_SEPARATOR); - for (String s : setOrderArray) { - - setOrder.add(s); - } - - String[] prefKeys = context.getResources().getStringArray(R.array.TEA_control_sets_prefs); - - StringBuilder newPref = new StringBuilder(); - - //Try to match old preference string to new preference string by index in defaults array - for (String pref : setOrder) { - int index = defaults.indexOf(pref); - if (index > -1 && index < prefKeys.length) { - newPref.append(prefKeys[index]); - newPref.append(BEAST_MODE_PREF_ITEM_SEPARATOR); - } else { // Should never get here--weird error if we do - // Failed to successfully migrate--reset to defaults - StringBuilder resetToDefaults = new StringBuilder(); - for (String s : prefKeys) { - resetToDefaults.append(s); - resetToDefaults.append(BEAST_MODE_PREF_ITEM_SEPARATOR); - } - Preferences.setString(BEAST_MODE_ORDER_PREF, resetToDefaults.toString()); - Preferences.setBoolean(BEAST_MODE_MIGRATE_PREF, true); - return; - } - } - - Preferences.setString(BEAST_MODE_ORDER_PREF, newPref.toString()); - Preferences.setBoolean(BEAST_MODE_MIGRATE_PREF, true); - } - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -120,9 +52,8 @@ public class BeastModePreferences extends ListActivity { items = new ArrayList(); for (String s : itemsArray) { - - if (!s.equals(getResources().getString(R.string.TEA_control_title))){ - items.add(s); + if (!s.equals(getResources().getString(R.string.TEA_ctrl_title_pref))){ + items.add(s); } } @@ -163,7 +94,7 @@ public class BeastModePreferences extends ListActivity { private void buildDescriptionMap(Resources r) { String[] keys = r.getStringArray(R.array.TEA_control_sets_prefs); - String[] descriptions = r.getStringArray(R.array.TEA_control_sets); + String[] descriptions = r.getStringArray(R.array.TEA_control_sets_beast); for (int i = 0; i < keys.length && i < descriptions.length; i++) { prefsToDescriptions.put(keys[i], descriptions[i]); } diff --git a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java index 9413ea2a1..5d9552b64 100755 --- a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java @@ -570,7 +570,6 @@ public final class TaskEditFragment extends Fragment implements R.array.TEA_control_sets_prefs); String moreSectionTrigger = getString(R.string.TEA_ctrl_more_pref); String shareViewDescriptor = getString(R.string.TEA_ctrl_share_pref); - String titleViewDescriptor = getString(R.string.TEA_ctrl_title_pref); LinearLayout section = basicControls; for (int i = 0; i < itemOrder.length; i++) { @@ -581,9 +580,7 @@ public final class TaskEditFragment extends Fragment implements View control_set = null; TaskEditControlSet curr = controlSetMap.get(item); - if (item.equals(titleViewDescriptor)) - control_set = curr.getDisplayView(); - else if (item.equals(shareViewDescriptor)) + if (item.equals(shareViewDescriptor)) control_set = peopleControlSet.getSharedWithRow(); else if (curr != null) control_set = (LinearLayout) curr.getDisplayView(); diff --git a/astrid/src/com/todoroo/astrid/service/StartupService.java b/astrid/src/com/todoroo/astrid/service/StartupService.java index 0d97b48ee..1ef8fe950 100644 --- a/astrid/src/com/todoroo/astrid/service/StartupService.java +++ b/astrid/src/com/todoroo/astrid/service/StartupService.java @@ -31,7 +31,6 @@ import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.actfm.sync.ActFmSyncService; -import com.todoroo.astrid.activity.BeastModePreferences; import com.todoroo.astrid.backup.BackupConstants; import com.todoroo.astrid.backup.BackupService; import com.todoroo.astrid.backup.TasksXmlImporter; @@ -138,7 +137,6 @@ public class StartupService { } else { Preferences.setLong(AstridPreferences.P_FIRST_LAUNCH, 0); } - BeastModePreferences.migrateBeastModePreferences(context); int version = 0; try {