diff --git a/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapterProvider.java b/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapterProvider.java index 2082631dc..0a4e5108d 100644 --- a/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapterProvider.java +++ b/app/src/main/java/com/todoroo/astrid/adapter/TaskAdapterProvider.java @@ -15,7 +15,6 @@ import com.todoroo.astrid.gtasks.GtasksListService; import com.todoroo.astrid.subtasks.SubtasksFilterUpdater; import com.todoroo.astrid.subtasks.SubtasksHelper; import javax.inject.Inject; -import org.tasks.R; import org.tasks.data.CaldavCalendar; import org.tasks.data.CaldavDao; import org.tasks.data.GoogleTaskDao; @@ -66,13 +65,15 @@ public class TaskAdapterProvider { TagFilter tagFilter = (TagFilter) filter; TagData tagData = tagDataDao.getByUuid(tagFilter.getUuid()); if (tagData != null) { - return isManualSort() ? createManualTagTaskAdapter(tagFilter) : new TaskAdapter(); + return preferences.isManualSort() + ? createManualTagTaskAdapter(tagFilter) + : new TaskAdapter(); } } else if (filter instanceof GtasksFilter) { GtasksFilter gtasksFilter = (GtasksFilter) filter; GoogleTaskList list = gtasksListService.getList(gtasksFilter.getStoreId()); if (list != null) { - return isManualSort() + return preferences.isManualSort() ? createManualGoogleTaskAdapter(gtasksFilter) : new TaskAdapter(); } @@ -90,10 +91,6 @@ public class TaskAdapterProvider { return new TaskAdapter(); } - private boolean isManualSort() { - return preferences.getBoolean(R.string.p_manual_sort, false); - } - private TaskAdapter createManualTagTaskAdapter(TagFilter filter) { TagData tagData = filter.getTagData(); String tdId = tagData.getRemoteId(); diff --git a/app/src/main/java/com/todoroo/astrid/core/SortHelper.java b/app/src/main/java/com/todoroo/astrid/core/SortHelper.java index 1d2ea2943..5e82fe1d5 100644 --- a/app/src/main/java/com/todoroo/astrid/core/SortHelper.java +++ b/app/src/main/java/com/todoroo/astrid/core/SortHelper.java @@ -43,7 +43,7 @@ public class SortHelper { if (!originalSql.toUpperCase().contains("ORDER BY")) { Order order = orderForSortType(sort); - if (preferences.getBoolean(R.string.p_reverse_sort, false)) { + if (preferences.isReverseSort()) { order = order.reverse(); } originalSql += " ORDER BY " + order; @@ -175,7 +175,7 @@ public class SortHelper { order.addSecondaryExpression(Order.asc("sort_title")); } - if (preferences.getBoolean(R.string.p_reverse_sort, false)) { + if (preferences.isReverseSort()) { order = order.reverse(); } diff --git a/app/src/main/java/com/todoroo/astrid/subtasks/SubtasksHelper.java b/app/src/main/java/com/todoroo/astrid/subtasks/SubtasksHelper.java index d15af7aec..af9427448 100644 --- a/app/src/main/java/com/todoroo/astrid/subtasks/SubtasksHelper.java +++ b/app/src/main/java/com/todoroo/astrid/subtasks/SubtasksHelper.java @@ -14,7 +14,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; -import org.tasks.R; import org.tasks.data.TagData; import org.tasks.data.TagDataDao; import org.tasks.data.TaskListMetadata; @@ -126,7 +125,7 @@ public class SubtasksHelper { } public boolean shouldUseSubtasksFragmentForFilter(Filter filter) { - return preferences.getBoolean(R.string.p_manual_sort, false) + return preferences.isManualSort() && filter != null && (filter.supportsSubtasks() || BuiltInFilterExposer.isInbox(context, filter) diff --git a/app/src/main/java/org/tasks/dialogs/SortDialog.java b/app/src/main/java/org/tasks/dialogs/SortDialog.java index 7d50228d0..72ff5775d 100644 --- a/app/src/main/java/org/tasks/dialogs/SortDialog.java +++ b/app/src/main/java/org/tasks/dialogs/SortDialog.java @@ -62,7 +62,7 @@ public class SortDialog extends InjectingDialogFragment { items.add(getString(R.string.SSD_sort_modified)); if (manualEnabled) { - if (preferences.getBoolean(R.string.p_manual_sort, false)) { + if (preferences.isManualSort()) { selectedIndex = 0; } } else { diff --git a/app/src/main/java/org/tasks/preferences/Preferences.java b/app/src/main/java/org/tasks/preferences/Preferences.java index 15ba0702f..3c378e1b1 100644 --- a/app/src/main/java/org/tasks/preferences/Preferences.java +++ b/app/src/main/java/org/tasks/preferences/Preferences.java @@ -516,4 +516,12 @@ public class Preferences { public boolean isPositionHackEnabled() { return getLong(R.string.p_google_tasks_position_hack, 0) > now() - TimeUnit.DAYS.toMillis(7); } + + public boolean isManualSort() { + return getBoolean(R.string.p_manual_sort, false); + } + + public boolean isReverseSort() { + return getBoolean(R.string.p_reverse_sort, false); + } }