Add waiting on me to the core filter exposer (needs icon)

pull/14/head
Sam Bosley 12 years ago
parent e302cc1831
commit 4626952573

@ -5,7 +5,11 @@
*/ */
package com.todoroo.astrid.core; package com.todoroo.astrid.core;
import java.util.ArrayList;
import java.util.List;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
@ -16,15 +20,19 @@ import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.FilterListFragment; import com.todoroo.astrid.activity.FilterListFragment;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.AstridFilterExposer; import com.todoroo.astrid.api.AstridFilterExposer;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterListItem; import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.api.PermaSql;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria; import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.WaitingOnMe;
import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.tags.TaskToTagMetadata; import com.todoroo.astrid.tags.TaskToTagMetadata;
@ -49,12 +57,17 @@ public final class CoreFilterExposer extends BroadcastReceiver implements Astrid
private FilterListItem[] prepareFilters(Resources r) { private FilterListItem[] prepareFilters(Resources r) {
// core filters // core filters
Filter inbox = buildInboxFilter(r); List<FilterListItem> filters = new ArrayList<FilterListItem>(3);
filters.add(buildInboxFilter(r));
if (Preferences.getBoolean(R.string.p_show_today_filter, true))
filters.add(getTodayFilter(r));
if (Preferences.getBoolean(R.string.p_show_waiting_on_me_filter, true))
filters.add(getWaitingOnMeFilter(r));
// transmit filter list // transmit filter list
FilterListItem[] list = new FilterListItem[1]; return filters.toArray(new FilterListItem[filters.size()]);
list[0] = inbox;
return list;
} }
/** /**
@ -75,6 +88,37 @@ public final class CoreFilterExposer extends BroadcastReceiver implements Astrid
return inbox; return inbox;
} }
public static Filter getTodayFilter(Resources r) {
int themeFlags = ThemeService.getFilterThemeFlags();
String todayTitle = AndroidUtilities.capitalize(r.getString(R.string.today));
ContentValues todayValues = new ContentValues();
todayValues.put(Task.DUE_DATE.name, PermaSql.VALUE_NOON);
Filter todayFilter = new Filter(todayTitle,
todayTitle,
new QueryTemplate().where(
Criterion.and(TaskCriteria.activeVisibleMine(),
Task.DUE_DATE.gt(0),
Task.DUE_DATE.lte(PermaSql.VALUE_EOD))),
todayValues);
todayFilter.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_calendar, themeFlags))).getBitmap();
return todayFilter;
}
public static Filter getWaitingOnMeFilter(Resources r) {
Filter waitingOnMe = new Filter(r.getString(R.string.BFE_waiting_on_me), r.getString(R.string.BFE_waiting_on_me),
new QueryTemplate().where(
Criterion.and(TaskCriteria.activeVisibleMine(),
Task.UUID.in(Query.select(WaitingOnMe.TASK_UUID)
.from(WaitingOnMe.TABLE).where(WaitingOnMe.DELETED_AT.eq(0))))), null);
int themeFlags = ThemeService.getFilterThemeFlags();
waitingOnMe.listingIcon = ((BitmapDrawable) r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_inbox, themeFlags))).getBitmap();
return waitingOnMe;
}
/** /**
* Is this the inbox? * Is this the inbox?
* @param filter * @param filter
@ -84,6 +128,10 @@ public final class CoreFilterExposer extends BroadcastReceiver implements Astrid
return (filter != null && filter.equals(buildInboxFilter(ContextManager.getContext().getResources()))); return (filter != null && filter.equals(buildInboxFilter(ContextManager.getContext().getResources())));
} }
public static boolean isTodayFilter(Filter filter) {
return (filter != null && filter.equals(getTodayFilter(ContextManager.getContext().getResources())));
}
@Override @Override
public FilterListItem[] getFilters() { public FilterListItem[] getFilters() {
if (ContextManager.getContext() == null || ContextManager.getContext().getResources() == null) if (ContextManager.getContext() == null || ContextManager.getContext().getResources() == null)

@ -9,7 +9,6 @@ import java.util.ArrayList;
import android.app.Activity; import android.app.Activity;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
@ -26,7 +25,6 @@ import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Order; import com.todoroo.andlib.sql.Order;
import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences; import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
@ -35,7 +33,6 @@ import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.AstridFilterExposer; import com.todoroo.astrid.api.AstridFilterExposer;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterListItem; import com.todoroo.astrid.api.FilterListItem;
import com.todoroo.astrid.api.PermaSql;
import com.todoroo.astrid.dao.StoreObjectDao; import com.todoroo.astrid.dao.StoreObjectDao;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.StoreObject; import com.todoroo.astrid.data.StoreObject;
@ -76,27 +73,6 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
return savedFilters; return savedFilters;
} }
public static Filter getTodayFilter(Resources r) {
int themeFlags = ThemeService.getFilterThemeFlags();
String todayTitle = AndroidUtilities.capitalize(r.getString(R.string.today));
ContentValues todayValues = new ContentValues();
todayValues.put(Task.DUE_DATE.name, PermaSql.VALUE_NOON);
Filter todayFilter = new Filter(todayTitle,
todayTitle,
new QueryTemplate().where(
Criterion.and(TaskCriteria.activeVisibleMine(),
Task.DUE_DATE.gt(0),
Task.DUE_DATE.lte(PermaSql.VALUE_EOD))),
todayValues);
todayFilter.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_calendar, themeFlags))).getBitmap();
return todayFilter;
}
public static boolean isTodayFilter(Filter filter) {
return (filter != null && filter.equals(getTodayFilter(ContextManager.getContext().getResources())));
}
private Filter[] buildSavedFilters(Context context, Resources r) { private Filter[] buildSavedFilters(Context context, Resources r) {
int themeFlags = ThemeService.getFilterThemeFlags(); int themeFlags = ThemeService.getFilterThemeFlags();
@ -110,9 +86,6 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
ArrayList<Filter> list = new ArrayList<Filter>(); ArrayList<Filter> list = new ArrayList<Filter>();
// stock filters // stock filters
if (Preferences.getBoolean(R.string.p_show_today_filter, true))
list.add(getTodayFilter(r));
if (Preferences.getBoolean(R.string.p_show_recently_modified_filter, true)) { if (Preferences.getBoolean(R.string.p_show_recently_modified_filter, true)) {
Filter recent = new Filter(r.getString(R.string.BFE_Recent), Filter recent = new Filter(r.getString(R.string.BFE_Recent),
r.getString(R.string.BFE_Recent), r.getString(R.string.BFE_Recent),

@ -16,7 +16,6 @@ import com.todoroo.astrid.actfm.TagViewFragment;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterWithCustomIntent; import com.todoroo.astrid.api.FilterWithCustomIntent;
import com.todoroo.astrid.core.CoreFilterExposer; import com.todoroo.astrid.core.CoreFilterExposer;
import com.todoroo.astrid.core.CustomFilterExposer;
import com.todoroo.astrid.core.PluginServices; import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.core.SortHelper; import com.todoroo.astrid.core.SortHelper;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
@ -31,7 +30,7 @@ import com.todoroo.astrid.utility.AstridPreferences;
public class SubtasksHelper { public class SubtasksHelper {
public static boolean shouldUseSubtasksFragmentForFilter(Filter filter) { public static boolean shouldUseSubtasksFragmentForFilter(Filter filter) {
if(filter == null || CoreFilterExposer.isInbox(filter) || CustomFilterExposer.isTodayFilter(filter) || SubtasksHelper.isTagFilter(filter)) { if(filter == null || CoreFilterExposer.isInbox(filter) || CoreFilterExposer.isTodayFilter(filter) || SubtasksHelper.isTagFilter(filter)) {
SharedPreferences publicPrefs = AstridPreferences.getPublicPrefs(ContextManager.getContext()); SharedPreferences publicPrefs = AstridPreferences.getPublicPrefs(ContextManager.getContext());
int sortFlags = publicPrefs.getInt(SortHelper.PREF_SORT_FLAGS, 0); int sortFlags = publicPrefs.getInt(SortHelper.PREF_SORT_FLAGS, 0);
if(SortHelper.isManualSort(sortFlags)) if(SortHelper.isManualSort(sortFlags))
@ -67,7 +66,7 @@ public class SubtasksHelper {
tlm = tlmd.fetchByTagId(tagData.getUuid(), TaskListMetadata.TASK_IDS); tlm = tlmd.fetchByTagId(tagData.getUuid(), TaskListMetadata.TASK_IDS);
} else if (CoreFilterExposer.isInbox(filter)) { } else if (CoreFilterExposer.isInbox(filter)) {
tlm = tlmd.fetchByTagId(TaskListMetadata.FILTER_ID_ALL, TaskListMetadata.TASK_IDS); tlm = tlmd.fetchByTagId(TaskListMetadata.FILTER_ID_ALL, TaskListMetadata.TASK_IDS);
} else if (CustomFilterExposer.isTodayFilter(filter)) { } else if (CoreFilterExposer.isTodayFilter(filter)) {
tlm = tlmd.fetchByTagId(TaskListMetadata.FILTER_ID_TODAY, TaskListMetadata.TASK_IDS); tlm = tlmd.fetchByTagId(TaskListMetadata.FILTER_ID_TODAY, TaskListMetadata.TASK_IDS);
} }

@ -73,6 +73,7 @@
<string name="p_filters_to_show">p_filters_to_show</string> <string name="p_filters_to_show">p_filters_to_show</string>
<string name="p_show_my_tasks_filter">p_show_my_tasks_f</string> <string name="p_show_my_tasks_filter">p_show_my_tasks_f</string>
<string name="p_show_today_filter">p_show_today_f</string> <string name="p_show_today_filter">p_show_today_f</string>
<string name="p_show_waiting_on_me_filter">p_show_waiting_on_me_f</string>
<string name="p_show_recently_modified_filter">p_show_recently_modified_f</string> <string name="p_show_recently_modified_filter">p_show_recently_modified_f</string>
<string name="p_show_ive_assigned_filter">p_show_assigned_f</string> <string name="p_show_ive_assigned_filter">p_show_assigned_f</string>
<string name="p_show_not_in_list_filter">p_show_no_list_f</string> <string name="p_show_not_in_list_filter">p_show_no_list_f</string>

@ -13,6 +13,9 @@
<!-- Active Tasks Filter --> <!-- Active Tasks Filter -->
<string name="BFE_Active">My Tasks</string> <string name="BFE_Active">My Tasks</string>
<!-- Waiting on me filter -->
<string name="BFE_waiting_on_me">Waiting On Me</string>
<!-- Search Filter --> <!-- Search Filter -->
<!-- slide 10b: Recently Modified --> <!-- slide 10b: Recently Modified -->

@ -133,6 +133,10 @@
android:key="@string/p_show_today_filter" android:key="@string/p_show_today_filter"
android:title="@string/today" android:title="@string/today"
android:defaultValue="true"/> android:defaultValue="true"/>
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:key="@string/p_show_waiting_on_me_filter"
android:title="@string/BFE_waiting_on_me"
android:defaultValue="true"/>
<com.todoroo.astrid.ui.MultilineCheckboxPreference <com.todoroo.astrid.ui.MultilineCheckboxPreference
android:key="@string/p_show_recently_modified_filter" android:key="@string/p_show_recently_modified_filter"
android:title="@string/BFE_Recent" android:title="@string/BFE_Recent"

@ -78,7 +78,6 @@ import com.todoroo.astrid.api.TaskContextActionExposer;
import com.todoroo.astrid.api.TaskDecoration; import com.todoroo.astrid.api.TaskDecoration;
import com.todoroo.astrid.core.CoreFilterExposer; import com.todoroo.astrid.core.CoreFilterExposer;
import com.todoroo.astrid.core.CustomFilterActivity; import com.todoroo.astrid.core.CustomFilterActivity;
import com.todoroo.astrid.core.CustomFilterExposer;
import com.todoroo.astrid.core.SortHelper; import com.todoroo.astrid.core.SortHelper;
import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.TaskListMetadataDao; import com.todoroo.astrid.dao.TaskListMetadataDao;
@ -399,7 +398,7 @@ public class TaskListFragment extends SherlockListFragment implements OnScrollLi
isInbox = CoreFilterExposer.isInbox(filter); isInbox = CoreFilterExposer.isInbox(filter);
isTodayFilter = false; isTodayFilter = false;
if (!isInbox) if (!isInbox)
isTodayFilter = CustomFilterExposer.isTodayFilter(filter); isTodayFilter = CoreFilterExposer.isTodayFilter(filter);
initializeTaskListMetadata(); initializeTaskListMetadata();

@ -100,6 +100,7 @@ public class AstridDefaultPreferenceSpec extends AstridPreferenceSpec {
setPreference(prefs, editor, r, R.string.p_rmd_persistent, true, ifUnset); setPreference(prefs, editor, r, R.string.p_rmd_persistent, true, ifUnset);
setPreference(prefs, editor, r, R.string.p_show_today_filter, true, ifUnset); setPreference(prefs, editor, r, R.string.p_show_today_filter, true, ifUnset);
setPreference(prefs, editor, r, R.string.p_show_waiting_on_me_filter, true, ifUnset);
setPreference(prefs, editor, r, R.string.p_show_recently_modified_filter, true, ifUnset); setPreference(prefs, editor, r, R.string.p_show_recently_modified_filter, true, ifUnset);
setPreference(prefs, editor, r, R.string.p_show_ive_assigned_filter, true, ifUnset); setPreference(prefs, editor, r, R.string.p_show_ive_assigned_filter, true, ifUnset);
setPreference(prefs, editor, r, R.string.p_show_not_in_list_filter, true, ifUnset); setPreference(prefs, editor, r, R.string.p_show_not_in_list_filter, true, ifUnset);

@ -99,6 +99,7 @@ public class AstridLitePreferenceSpec extends AstridPreferenceSpec {
setPreference(prefs, editor, r, R.string.p_force_phone_layout, true, ifUnset); setPreference(prefs, editor, r, R.string.p_force_phone_layout, true, ifUnset);
setPreference(prefs, editor, r, R.string.p_show_today_filter, true, ifUnset); setPreference(prefs, editor, r, R.string.p_show_today_filter, true, ifUnset);
setPreference(prefs, editor, r, R.string.p_show_waiting_on_me_filter, false, ifUnset);
setPreference(prefs, editor, r, R.string.p_show_recently_modified_filter, false, ifUnset); setPreference(prefs, editor, r, R.string.p_show_recently_modified_filter, false, ifUnset);
setPreference(prefs, editor, r, R.string.p_show_ive_assigned_filter, false, ifUnset); setPreference(prefs, editor, r, R.string.p_show_ive_assigned_filter, false, ifUnset);
setPreference(prefs, editor, r, R.string.p_show_not_in_list_filter, false, ifUnset); setPreference(prefs, editor, r, R.string.p_show_not_in_list_filter, false, ifUnset);

Loading…
Cancel
Save