Fixed bug where neither widget nor task list would respect default settings

pull/14/head
Tim Su 16 years ago
parent 0ced4fc3d9
commit 0ae7d4ddd2

@ -89,7 +89,7 @@ public class SortSelectionActivity {
} }
@SuppressWarnings("nls") @SuppressWarnings("nls")
public static String adjustSortAndFlags(String originalSql, int flags, int sort) { public static String adjustQueryForFlagsAndSort(String originalSql, int flags, int sort) {
// sort // sort
if(!originalSql.toUpperCase().contains("ORDER BY")) { if(!originalSql.toUpperCase().contains("ORDER BY")) {
Order order; Order order;
@ -136,10 +136,10 @@ public class SortSelectionActivity {
// --- internal implementation // --- internal implementation
/** preference key for sort flags */ /** preference key for sort flags */
public static final String PREF_SORT_FLAGS = "tla_flags"; //$NON-NLS-1$ public static final String PREF_SORT_FLAGS = "sort_flags"; //$NON-NLS-1$
/** preference key for sort sort */ /** preference key for sort sort */
public static final String PREF_SORT_SORT = "tla_sort"; //$NON-NLS-1$ public static final String PREF_SORT_SORT = "sort_sort"; //$NON-NLS-1$
private SortSelectionActivity() { private SortSelectionActivity() {
// use the static method // use the static method

@ -363,6 +363,9 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
} catch (VerifyError e) { } catch (VerifyError e) {
// failed check, no gestures :P // failed check, no gestures :P
} }
sortFlags = Preferences.getInt(SortSelectionActivity.PREF_SORT_FLAGS, 0);
sortSort= Preferences.getInt(SortSelectionActivity.PREF_SORT_SORT, 0);
} }
public void bindServices() { public void bindServices() {
@ -525,7 +528,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
* @param withCustomId force task with given custom id to be part of list * @param withCustomId force task with given custom id to be part of list
*/ */
protected void setUpTaskList() { protected void setUpTaskList() {
sqlQueryTemplate.set(SortSelectionActivity.adjustSortAndFlags(filter.sqlQuery, sqlQueryTemplate.set(SortSelectionActivity.adjustQueryForFlagsAndSort(filter.sqlQuery,
sortFlags, sortSort)); sortFlags, sortSort));
// perform query // perform query

@ -100,10 +100,10 @@ public class TasksWidget extends AppWidgetProvider {
TodorooCursor<Task> cursor = null; TodorooCursor<Task> cursor = null;
try { try {
Filter inboxFilter = CoreFilterExposer.buildInboxFilter(getResources()); Filter inboxFilter = CoreFilterExposer.buildInboxFilter(getResources());
int sort = Preferences.getInt(SortSelectionActivity.PREF_SORT_SORT, 0);
int flags = Preferences.getInt(SortSelectionActivity.PREF_SORT_FLAGS, 0); int flags = Preferences.getInt(SortSelectionActivity.PREF_SORT_FLAGS, 0);
String query = SortSelectionActivity.adjustSortAndFlags( int sort = Preferences.getInt(SortSelectionActivity.PREF_SORT_SORT, 0);
inboxFilter.sqlQuery, sort, flags) + " LIMIT " + numberOfTasks; String query = SortSelectionActivity.adjustQueryForFlagsAndSort(
inboxFilter.sqlQuery, flags, sort) + " LIMIT " + numberOfTasks;
database.openForReading(); database.openForReading();
cursor = taskService.fetchFiltered(query, null, Task.TITLE, Task.DUE_DATE); cursor = taskService.fetchFiltered(query, null, Task.TITLE, Task.DUE_DATE);

Loading…
Cancel
Save