Show or hide specific default filters from the appearance prefs

pull/14/head
Sam Bosley 13 years ago
parent 92816d5cad
commit 93fbd75115

@ -5,6 +5,8 @@
*/ */
package com.todoroo.astrid.core; package com.todoroo.astrid.core;
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.ContentValues;
@ -108,44 +110,46 @@ public final class CustomFilterExposer extends BroadcastReceiver implements Astr
cursor = dao.query(Query.select(StoreObject.PROPERTIES).where( cursor = dao.query(Query.select(StoreObject.PROPERTIES).where(
StoreObject.TYPE.eq(SavedFilter.TYPE)).orderBy(Order.asc(SavedFilter.NAME))); StoreObject.TYPE.eq(SavedFilter.TYPE)).orderBy(Order.asc(SavedFilter.NAME)));
try { try {
Filter[] list; ArrayList<Filter> list = new ArrayList<Filter>();
if (useCustomFilters && cursor != null)
list = new Filter[cursor.getCount() + 3];
else
list = new Filter[3];
// stock filters // stock filters
list[0] = getTodayFilter(r); if (Preferences.getBoolean(R.string.p_show_today_filter, true))
list.add(getTodayFilter(r));
list[1] = new Filter(r.getString(R.string.BFE_Recent),
r.getString(R.string.BFE_Recent), if (Preferences.getBoolean(R.string.p_show_recently_modified_filter, true)) {
new QueryTemplate().where( Filter recent = new Filter(r.getString(R.string.BFE_Recent),
TaskCriteria.ownedByMe()).orderBy( r.getString(R.string.BFE_Recent),
Order.desc(Task.MODIFICATION_DATE)).limit(15), new QueryTemplate().where(
null); TaskCriteria.ownedByMe()).orderBy(
list[1].listingIcon = ((BitmapDrawable)r.getDrawable( Order.desc(Task.MODIFICATION_DATE)).limit(15),
ThemeService.getDrawable(R.drawable.filter_pencil, themeFlags))).getBitmap(); null);
recent.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_pencil, themeFlags))).getBitmap();
list.add(recent);
}
list[2] = getAssignedByMeFilter(r); if (Preferences.getBoolean(R.string.p_show_ive_assigned_filter, true))
list.add(getAssignedByMeFilter(r));
if (useCustomFilters && cursor != null) { if (useCustomFilters && cursor != null) {
StoreObject savedFilter = new StoreObject(); StoreObject savedFilter = new StoreObject();
for(int i = 3; i < list.length; i++) { for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
cursor.moveToNext();
savedFilter.readFromCursor(cursor); savedFilter.readFromCursor(cursor);
list[i] = SavedFilter.load(savedFilter); Filter f = SavedFilter.load(savedFilter);
Intent deleteIntent = new Intent(context, DeleteActivity.class); Intent deleteIntent = new Intent(context, DeleteActivity.class);
deleteIntent.putExtra(TOKEN_FILTER_ID, savedFilter.getId()); deleteIntent.putExtra(TOKEN_FILTER_ID, savedFilter.getId());
deleteIntent.putExtra(TOKEN_FILTER_NAME, list[i].title); deleteIntent.putExtra(TOKEN_FILTER_NAME, f.title);
list[i].contextMenuLabels = new String[] { context.getString(R.string.BFE_Saved_delete) }; f.contextMenuLabels = new String[] { context.getString(R.string.BFE_Saved_delete) };
list[i].contextMenuIntents = new Intent[] { deleteIntent }; f.contextMenuIntents = new Intent[] { deleteIntent };
list[i].listingIcon = ((BitmapDrawable)r.getDrawable( f.listingIcon = ((BitmapDrawable)r.getDrawable(
ThemeService.getDrawable(R.drawable.filter_sliders, themeFlags))).getBitmap(); ThemeService.getDrawable(R.drawable.filter_sliders, themeFlags))).getBitmap();
list.add(f);
} }
} }
return list; return list.toArray(new Filter[list.size()]);
} finally { } finally {
if (cursor != null) if (cursor != null)
cursor.close(); cursor.close();

@ -29,6 +29,7 @@ import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Criterion; import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.TagViewFragment; import com.todoroo.astrid.actfm.TagViewFragment;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.AstridFilterExposer; import com.todoroo.astrid.api.AstridFilterExposer;
@ -152,7 +153,10 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
} }
private FilterCategory filterFromTags(Tag[] tags, int name) { private FilterCategory filterFromTags(Tag[] tags, int name) {
int length = addUntaggedFilter ? tags.length + 1 : tags.length; boolean shouldAddUntagged = addUntaggedFilter &&
Preferences.getBoolean(R.string.p_show_not_in_list_filter, true);
int length = shouldAddUntagged ? tags.length + 1 : tags.length;
Filter[] filters = new Filter[length]; Filter[] filters = new Filter[length];
Context context = ContextManager.getContext(); Context context = ContextManager.getContext();
@ -161,7 +165,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
int themeFlags = ThemeService.getFilterThemeFlags(); int themeFlags = ThemeService.getFilterThemeFlags();
// --- untagged // --- untagged
if (addUntaggedFilter) { if (shouldAddUntagged) {
int untaggedLabel = gtasksPreferenceService.isLoggedIn() ? int untaggedLabel = gtasksPreferenceService.isLoggedIn() ?
R.string.tag_FEx_untagged_w_astrid : R.string.tag_FEx_untagged; R.string.tag_FEx_untagged_w_astrid : R.string.tag_FEx_untagged;
Filter untagged = new Filter(r.getString(untaggedLabel), Filter untagged = new Filter(r.getString(untaggedLabel),
@ -174,7 +178,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
} }
for(int i = 0; i < tags.length; i++) { for(int i = 0; i < tags.length; i++) {
int index = addUntaggedFilter ? i + 1 : i; int index = shouldAddUntagged ? i + 1 : i;
filters[index] = constructFilter(context, tags[i]); filters[index] = constructFilter(context, tags[i]);
} }
FilterCategory filter = new FilterCategory(context.getString(name), filters); FilterCategory filter = new FilterCategory(context.getString(name), filters);

@ -73,6 +73,14 @@
<!-- simple input box style --> <!-- simple input box style -->
<string name="p_simple_input_boxes">simple_input_boxes</string> <string name="p_simple_input_boxes">simple_input_boxes</string>
<!-- filters to show -->
<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_today_filter">p_show_today_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_not_in_list_filter">p_show_no_list_f</string>
<string-array name="TEA_reminder_random_hours"> <string-array name="TEA_reminder_random_hours">
<!-- values (in hours) associated with items above. --> <!-- values (in hours) associated with items above. -->
<item>1</item> <item>1</item>

@ -648,6 +648,9 @@
<!-- slide 34a: Preference: Task List Font Size Title --> <!-- slide 34a: Preference: Task List Font Size Title -->
<string name="EPr_fontSize_title">Task list size</string> <string name="EPr_fontSize_title">Task list size</string>
<!-- Preference: Filters to show pref screen title -->
<string name="EPr_filters_to_show_title">Filters to show</string>
<!-- slide 32a: Preference: Show confirmation for smart reminders --> <!-- slide 32a: Preference: Show confirmation for smart reminders -->
<string name="EPr_showSmartConfirmation_title">Show confirmation for smart reminders</string> <string name="EPr_showSmartConfirmation_title">Show confirmation for smart reminders</string>

@ -11,7 +11,7 @@
<!-- ================================================= Filter Exposer == --> <!-- ================================================= Filter Exposer == -->
<!-- Active Tasks Filter --> <!-- Active Tasks Filter -->
<string name="BFE_Active">Active Tasks</string> <string name="BFE_Active">My Tasks</string>
<!-- Search Filter --> <!-- Search Filter -->

@ -55,6 +55,31 @@
<PreferenceScreen android:title="@string/EPr_beastMode_title" <PreferenceScreen android:title="@string/EPr_beastMode_title"
android:key="@string/p_beastMode"/> android:key="@string/p_beastMode"/>
<PreferenceScreen android:title="@string/EPr_filters_to_show_title" android:key="@string/p_filters_to_show">
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:key="@string/p_show_my_tasks_filter"
android:title="@string/BFE_Active"
android:defaultValue="true"
android:enabled="false" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:key="@string/p_show_today_filter"
android:title="@string/today"
android:defaultValue="true"/>
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:key="@string/p_show_recently_modified_filter"
android:title="@string/BFE_Recent"
android:defaultValue="true"/>
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:key="@string/p_show_ive_assigned_filter"
android:title="@string/BFE_Assigned"
android:defaultValue="true"/>
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:key="@string/p_show_not_in_list_filter"
android:title="@string/tag_FEx_untagged"
android:defaultValue="true"/>
</PreferenceScreen>
<com.todoroo.astrid.ui.MultilineListPreference <com.todoroo.astrid.ui.MultilineListPreference
android:key="@string/p_theme" android:key="@string/p_theme"

@ -108,6 +108,11 @@ 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, 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_not_in_list_filter, false, ifUnset);
extras.setExtras(context, prefs, editor, r, ifUnset); extras.setExtras(context, prefs, editor, r, ifUnset);
editor.commit(); editor.commit();

Loading…
Cancel
Save