diff --git a/src/main/java/com/todoroo/astrid/activity/SortSelectionActivity.java b/src/main/java/com/todoroo/astrid/activity/SortSelectionActivity.java
index 84d1caca6..4e487d964 100644
--- a/src/main/java/com/todoroo/astrid/activity/SortSelectionActivity.java
+++ b/src/main/java/com/todoroo/astrid/activity/SortSelectionActivity.java
@@ -39,13 +39,14 @@ public class SortSelectionActivity {
* Create the dialog
*/
public static AlertDialog createDialog(Activity activity, boolean showDragDrop, ActivityPreferences activityPreferences,
- OnSortSelectedListener listener, int flags, int sort) {
+ OnSortSelectedListener listener) {
+ int flags = activityPreferences.getSortFlags();
int editDialogTheme = activityPreferences.getEditDialogTheme();
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(activity, editDialogTheme);
LayoutInflater themedInflater = activity.getLayoutInflater().cloneInContext(contextThemeWrapper);
View body = themedInflater.inflate(R.layout.sort_selection_dialog, null);
- if((flags & SortHelper.FLAG_REVERSE_SORT) > 0) {
+ if (activityPreferences.getBoolean(R.string.p_reverse_sort, false)) {
((CheckBox) body.findViewById(R.id.reverse)).setChecked(true);
}
@@ -56,7 +57,7 @@ public class SortSelectionActivity {
if(showDragDrop && (flags & SortHelper.FLAG_DRAG_DROP) > 0) {
((RadioButton) body.findViewById(R.id.sort_drag)).setChecked(true);
} else {
- switch(sort) {
+ switch(activityPreferences.getSortMode()) {
case SortHelper.SORT_ALPHA:
((RadioButton)body.findViewById(R.id.sort_alpha)).setChecked(true);
break;
@@ -87,7 +88,7 @@ public class SortSelectionActivity {
AlertDialog dialog = builder.
setTitle(R.string.TLA_menu_sort).
setView(body).
- setPositiveButton(R.string.TLA_menu_sort, new DialogOkListener(body, listener)).
+ setPositiveButton(R.string.TLA_menu_sort, new DialogOkListener(activityPreferences, body, listener)).
setNegativeButton(android.R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@@ -106,9 +107,11 @@ public class SortSelectionActivity {
private static class DialogOkListener implements OnClickListener {
private final OnSortSelectedListener listener;
+ private Preferences preferences;
private final View body;
- public DialogOkListener(View body, OnSortSelectedListener listener) {
+ public DialogOkListener(Preferences preferences, View body, OnSortSelectedListener listener) {
+ this.preferences = preferences;
this.body = body;
this.listener = listener;
}
@@ -118,9 +121,8 @@ public class SortSelectionActivity {
int flags = 0;
int sort;
- if(((CheckBox)body.findViewById(R.id.reverse)).isChecked()) {
- flags |= SortHelper.FLAG_REVERSE_SORT;
- }
+ preferences.setBoolean(R.string.p_reverse_sort, ((CheckBox) body.findViewById(R.id.reverse)).isChecked());
+
if(((RadioButton)body.findViewById(R.id.sort_drag)).isChecked()) {
flags |= SortHelper.FLAG_DRAG_DROP;
}
diff --git a/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java b/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java
index 9b8fdf2f6..dfe4859cf 100644
--- a/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java
+++ b/src/main/java/com/todoroo/astrid/activity/TaskListActivity.java
@@ -13,7 +13,6 @@ import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
-import android.support.v7.app.AlertDialog;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
@@ -452,9 +451,9 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
voiceInputAssistant.startVoiceRecognitionActivity(R.string.voice_create_prompt);
return true;
case R.id.menu_sort:
- AlertDialog dialog = SortSelectionActivity.createDialog(
- this, tlf.hasDraggableOption(), preferences, tlf, preferences.getSortFlags(), preferences.getSortMode());
- dialog.show();
+ SortSelectionActivity
+ .createDialog(this, tlf.hasDraggableOption(), preferences, tlf)
+ .show();
return true;
case R.id.menu_tag_settings:
startActivityForResult(new Intent(this, TagSettingsActivity.class) {{
diff --git a/src/main/java/com/todoroo/astrid/core/SortHelper.java b/src/main/java/com/todoroo/astrid/core/SortHelper.java
index 52dc8e8b1..170867baf 100644
--- a/src/main/java/com/todoroo/astrid/core/SortHelper.java
+++ b/src/main/java/com/todoroo/astrid/core/SortHelper.java
@@ -23,6 +23,8 @@ import org.tasks.preferences.Preferences;
*/
public class SortHelper {
+ @SuppressWarnings("UnusedDeclaration")
+ @Deprecated
public static final int FLAG_REVERSE_SORT = 1;
@SuppressWarnings("UnusedDeclaration")
@@ -61,7 +63,7 @@ public class SortHelper {
if(!originalSql.toUpperCase().contains("ORDER BY")) {
Order order = orderForSortType(sort);
- if((flags & FLAG_REVERSE_SORT) > 0) {
+ if (preferences.getBoolean(R.string.p_reverse_sort, false)) {
order = order.reverse();
}
originalSql += " ORDER BY " + order;
diff --git a/src/main/res/values/keys.xml b/src/main/res/values/keys.xml
index 7170e9553..abe11b520 100644
--- a/src/main/res/values/keys.xml
+++ b/src/main/res/values/keys.xml
@@ -245,6 +245,7 @@
show_deleted_tasks
show_hidden_tasks
show_completed_tasks
+ reverse_sort
- @string/TEA_ctrl_when_pref