diff --git a/astrid/src/main/java/com/todoroo/astrid/activity/BeastModePreferences.java b/astrid/src/main/java/com/todoroo/astrid/activity/BeastModePreferences.java index 2da0d75fc..011664467 100644 --- a/astrid/src/main/java/com/todoroo/astrid/activity/BeastModePreferences.java +++ b/astrid/src/main/java/com/todoroo/astrid/activity/BeastModePreferences.java @@ -5,7 +5,6 @@ */ package com.todoroo.astrid.activity; -import android.app.ListActivity; import android.content.Context; import android.content.res.Resources; import android.os.Bundle; @@ -19,15 +18,18 @@ import android.widget.TextView; import com.commonsware.cwac.tlv.TouchListView; import com.commonsware.cwac.tlv.TouchListView.DropListener; -import com.todoroo.andlib.utility.Preferences; import org.tasks.R; +import org.tasks.injection.InjectingListActivity; +import org.tasks.preferences.Preferences; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -public class BeastModePreferences extends ListActivity { +import javax.inject.Inject; + +public class BeastModePreferences extends InjectingListActivity { private ArrayAdapter adapter; @@ -39,19 +41,7 @@ public class BeastModePreferences extends ListActivity { private HashMap prefsToDescriptions; - public static void setDefaultOrder(Context context) { - if (Preferences.getStringValue(BEAST_MODE_ORDER_PREF) != null) { - return; - } - - ArrayList list = constructOrderedControlList(context); - StringBuilder newSetting = new StringBuilder(30); - for (String item : list) { - newSetting.append(item); - newSetting.append(BEAST_MODE_PREF_ITEM_SEPARATOR); - } - Preferences.setString(BEAST_MODE_ORDER_PREF, newSetting.toString()); - } + @Inject Preferences preferences; @Override protected void onCreate(Bundle savedInstanceState) { @@ -63,7 +53,7 @@ public class BeastModePreferences extends ListActivity { buildDescriptionMap(getResources()); TouchListView touchList = (TouchListView) getListView(); - items = constructOrderedControlList(this); + items = constructOrderedControlList(preferences, this); adapter = new ArrayAdapter(this, R.layout.preference_draggable_row, R.id.text, items) { @Override @@ -124,12 +114,26 @@ public class BeastModePreferences extends ListActivity { newSetting.append(adapter.getItem(i)); newSetting.append(BEAST_MODE_PREF_ITEM_SEPARATOR); } - Preferences.setString(BEAST_MODE_ORDER_PREF, newSetting.toString()); + preferences.setString(BEAST_MODE_ORDER_PREF, newSetting.toString()); super.finish(); } - public static ArrayList constructOrderedControlList(Context context) { - String order = Preferences.getStringValue(BEAST_MODE_ORDER_PREF); + public static void setDefaultOrder(Preferences preferences, Context context) { + if (preferences.getStringValue(BEAST_MODE_ORDER_PREF) != null) { + return; + } + + ArrayList list = constructOrderedControlList(preferences, context); + StringBuilder newSetting = new StringBuilder(30); + for (String item : list) { + newSetting.append(item); + newSetting.append(BEAST_MODE_PREF_ITEM_SEPARATOR); + } + preferences.setString(BEAST_MODE_ORDER_PREF, newSetting.toString()); + } + + public static ArrayList constructOrderedControlList(Preferences preferences, Context context) { + String order = preferences.getStringValue(BEAST_MODE_ORDER_PREF); ArrayList list = new ArrayList<>(); String[] itemsArray; if (order == null) { diff --git a/astrid/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java b/astrid/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java index 45a28a830..a0200343c 100755 --- a/astrid/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/astrid/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java @@ -44,7 +44,6 @@ import android.widget.Toast; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DialogUtilities; -import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.actfm.ActFmCameraModule; import com.todoroo.astrid.actfm.ActFmCameraModule.CameraResultCallback; import com.todoroo.astrid.alarms.AlarmService; @@ -89,6 +88,7 @@ import org.slf4j.LoggerFactory; import org.tasks.R; import org.tasks.injection.InjectingFragment; import org.tasks.notifications.NotificationManager; +import org.tasks.preferences.Preferences; import java.io.File; import java.io.FileOutputStream; @@ -182,6 +182,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { @Inject NotificationManager notificationManager; @Inject AlarmService alarmService; @Inject GCalHelper gcalHelper; + @Inject Preferences preferences; // --- UI components @@ -241,7 +242,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { } } - showEditComments = Preferences.getBoolean(R.string.p_show_task_edit_comments, true); + showEditComments = preferences.getBoolean(R.string.p_show_task_edit_comments, true); getActivity().setResult(Activity.RESULT_OK); } @@ -457,7 +458,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { basicControls.removeAllViews(); } - ArrayList controlOrder = BeastModePreferences.constructOrderedControlList(getActivity()); + ArrayList controlOrder = BeastModePreferences.constructOrderedControlList(preferences, getActivity()); String[] itemOrder = controlOrder.toArray(new String[controlOrder.size()]); String hideAlwaysTrigger = getString(R.string.TEA_ctrl_hide_section_pref); @@ -963,7 +964,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { item.setIcon(ThemeService.getDrawable(R.drawable.ic_action_discard)); setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS); - boolean useSaveAndCancel = Preferences.getBoolean(R.string.p_save_and_cancel, false); + boolean useSaveAndCancel = preferences.getBoolean(R.string.p_save_and_cancel, false); if (useSaveAndCancel || AstridPreferences.useTabletLayout(getActivity())) { if (useSaveAndCancel) { diff --git a/astrid/src/main/java/com/todoroo/astrid/utility/AstridDefaultPreferenceSpec.java b/astrid/src/main/java/com/todoroo/astrid/utility/AstridDefaultPreferenceSpec.java index 31c2eba03..d45da7204 100644 --- a/astrid/src/main/java/com/todoroo/astrid/utility/AstridDefaultPreferenceSpec.java +++ b/astrid/src/main/java/com/todoroo/astrid/utility/AstridDefaultPreferenceSpec.java @@ -82,7 +82,7 @@ public class AstridDefaultPreferenceSpec { } preferences.setBoolean(dragDropTestInitialized, true); } - BeastModePreferences.setDefaultOrder(context); + BeastModePreferences.setDefaultOrder(preferences, context); editor.commit(); diff --git a/astrid/src/main/java/org/tasks/injection/ActivityModule.java b/astrid/src/main/java/org/tasks/injection/ActivityModule.java index 7bbc01e4a..fca085182 100644 --- a/astrid/src/main/java/org/tasks/injection/ActivityModule.java +++ b/astrid/src/main/java/org/tasks/injection/ActivityModule.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.content.Context; import com.todoroo.astrid.actfm.TagSettingsActivity; +import com.todoroo.astrid.activity.BeastModePreferences; import com.todoroo.astrid.activity.EditPreferences; import com.todoroo.astrid.activity.FilterShortcutActivity; import com.todoroo.astrid.activity.ShareLinkActivity; @@ -67,7 +68,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; TimerFilterExposer.class, CustomFilterExposer.class, GtasksFilterExposer.class, - TagFilterExposer.class + TagFilterExposer.class, + BeastModePreferences.class }) public class ActivityModule {