Add isReverseSort and isManualSort to preferences

gtask_related_email
Alex Baker 5 years ago
parent dc519a59e5
commit c408eaf541

@ -15,7 +15,6 @@ import com.todoroo.astrid.gtasks.GtasksListService;
import com.todoroo.astrid.subtasks.SubtasksFilterUpdater; import com.todoroo.astrid.subtasks.SubtasksFilterUpdater;
import com.todoroo.astrid.subtasks.SubtasksHelper; import com.todoroo.astrid.subtasks.SubtasksHelper;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R;
import org.tasks.data.CaldavCalendar; import org.tasks.data.CaldavCalendar;
import org.tasks.data.CaldavDao; import org.tasks.data.CaldavDao;
import org.tasks.data.GoogleTaskDao; import org.tasks.data.GoogleTaskDao;
@ -66,13 +65,15 @@ public class TaskAdapterProvider {
TagFilter tagFilter = (TagFilter) filter; TagFilter tagFilter = (TagFilter) filter;
TagData tagData = tagDataDao.getByUuid(tagFilter.getUuid()); TagData tagData = tagDataDao.getByUuid(tagFilter.getUuid());
if (tagData != null) { if (tagData != null) {
return isManualSort() ? createManualTagTaskAdapter(tagFilter) : new TaskAdapter(); return preferences.isManualSort()
? createManualTagTaskAdapter(tagFilter)
: new TaskAdapter();
} }
} else if (filter instanceof GtasksFilter) { } else if (filter instanceof GtasksFilter) {
GtasksFilter gtasksFilter = (GtasksFilter) filter; GtasksFilter gtasksFilter = (GtasksFilter) filter;
GoogleTaskList list = gtasksListService.getList(gtasksFilter.getStoreId()); GoogleTaskList list = gtasksListService.getList(gtasksFilter.getStoreId());
if (list != null) { if (list != null) {
return isManualSort() return preferences.isManualSort()
? createManualGoogleTaskAdapter(gtasksFilter) ? createManualGoogleTaskAdapter(gtasksFilter)
: new TaskAdapter(); : new TaskAdapter();
} }
@ -90,10 +91,6 @@ public class TaskAdapterProvider {
return new TaskAdapter(); return new TaskAdapter();
} }
private boolean isManualSort() {
return preferences.getBoolean(R.string.p_manual_sort, false);
}
private TaskAdapter createManualTagTaskAdapter(TagFilter filter) { private TaskAdapter createManualTagTaskAdapter(TagFilter filter) {
TagData tagData = filter.getTagData(); TagData tagData = filter.getTagData();
String tdId = tagData.getRemoteId(); String tdId = tagData.getRemoteId();

@ -43,7 +43,7 @@ public class SortHelper {
if (!originalSql.toUpperCase().contains("ORDER BY")) { if (!originalSql.toUpperCase().contains("ORDER BY")) {
Order order = orderForSortType(sort); Order order = orderForSortType(sort);
if (preferences.getBoolean(R.string.p_reverse_sort, false)) { if (preferences.isReverseSort()) {
order = order.reverse(); order = order.reverse();
} }
originalSql += " ORDER BY " + order; originalSql += " ORDER BY " + order;
@ -175,7 +175,7 @@ public class SortHelper {
order.addSecondaryExpression(Order.asc("sort_title")); order.addSecondaryExpression(Order.asc("sort_title"));
} }
if (preferences.getBoolean(R.string.p_reverse_sort, false)) { if (preferences.isReverseSort()) {
order = order.reverse(); order = order.reverse();
} }

@ -14,7 +14,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import org.tasks.R;
import org.tasks.data.TagData; import org.tasks.data.TagData;
import org.tasks.data.TagDataDao; import org.tasks.data.TagDataDao;
import org.tasks.data.TaskListMetadata; import org.tasks.data.TaskListMetadata;
@ -126,7 +125,7 @@ public class SubtasksHelper {
} }
public boolean shouldUseSubtasksFragmentForFilter(Filter filter) { public boolean shouldUseSubtasksFragmentForFilter(Filter filter) {
return preferences.getBoolean(R.string.p_manual_sort, false) return preferences.isManualSort()
&& filter != null && filter != null
&& (filter.supportsSubtasks() && (filter.supportsSubtasks()
|| BuiltInFilterExposer.isInbox(context, filter) || BuiltInFilterExposer.isInbox(context, filter)

@ -62,7 +62,7 @@ public class SortDialog extends InjectingDialogFragment {
items.add(getString(R.string.SSD_sort_modified)); items.add(getString(R.string.SSD_sort_modified));
if (manualEnabled) { if (manualEnabled) {
if (preferences.getBoolean(R.string.p_manual_sort, false)) { if (preferences.isManualSort()) {
selectedIndex = 0; selectedIndex = 0;
} }
} else { } else {

@ -516,4 +516,12 @@ public class Preferences {
public boolean isPositionHackEnabled() { public boolean isPositionHackEnabled() {
return getLong(R.string.p_google_tasks_position_hack, 0) > now() - TimeUnit.DAYS.toMillis(7); 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);
}
} }

Loading…
Cancel
Save