mirror of https://github.com/tasks/tasks
Add new navigation drawer settings
parent
ea354240ea
commit
6392188750
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2012 Todoroo Inc
|
|
||||||
*
|
|
||||||
* See the file "LICENSE" for the full license governing this code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.todoroo.astrid.tags;
|
|
||||||
|
|
||||||
import static com.google.common.collect.Lists.newArrayList;
|
|
||||||
import static com.google.common.collect.Lists.transform;
|
|
||||||
import static com.todoroo.andlib.utility.DateUtilities.now;
|
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.todoroo.astrid.api.Filter;
|
|
||||||
import com.todoroo.astrid.api.TagFilter;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import org.tasks.data.TagData;
|
|
||||||
import org.tasks.data.TagDataDao;
|
|
||||||
import org.tasks.filters.AlphanumComparator;
|
|
||||||
import org.tasks.filters.TagFilters;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exposes filters based on tags
|
|
||||||
*
|
|
||||||
* @author Tim Su <tim@todoroo.com>
|
|
||||||
*/
|
|
||||||
public class TagFilterExposer {
|
|
||||||
|
|
||||||
private final TagDataDao tagDataDao;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public TagFilterExposer(TagDataDao tagDataDao) {
|
|
||||||
this.tagDataDao = tagDataDao;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create filter from new tag object */
|
|
||||||
private static TagFilter filterFromTag(TagData tag) {
|
|
||||||
if (tag == null || Strings.isNullOrEmpty(tag.getName())) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new TagFilter(tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Filter> getFilters() {
|
|
||||||
List<Filter> tags =
|
|
||||||
newArrayList(transform(tagDataDao.getTagFilters(now()), TagFilters::toTagFilter));
|
|
||||||
Collections.sort(tags, new AlphanumComparator<>(AlphanumComparator.FILTER));
|
|
||||||
return tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Filter getFilterByUuid(String uuid) {
|
|
||||||
return filterFromTag(tagDataDao.getByUuid(uuid));
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.tasks.preferences.fragments
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import org.tasks.R
|
||||||
|
import org.tasks.injection.FragmentComponent
|
||||||
|
import org.tasks.injection.InjectingPreferenceFragment
|
||||||
|
|
||||||
|
class NavigationDrawer : InjectingPreferenceFragment() {
|
||||||
|
|
||||||
|
override fun getPreferenceXml() = R.xml.preferences_navigation_drawer
|
||||||
|
|
||||||
|
override fun setupPreferences(savedInstanceState: Bundle?) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun inject(component: FragmentComponent) = component.inject(this)
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:key="@string/preference_screen">
|
||||||
|
|
||||||
|
<PreferenceCategory android:title="@string/filters">
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="@string/p_filters_enabled"
|
||||||
|
android:title="@string/enabled" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:dependency="@string/p_filters_enabled"
|
||||||
|
android:key="@string/p_show_today_filter"
|
||||||
|
android:title="@string/today" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:dependency="@string/p_filters_enabled"
|
||||||
|
android:key="@string/p_show_recently_modified_filter"
|
||||||
|
android:title="@string/BFE_Recent" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:dependency="@string/p_filters_enabled"
|
||||||
|
android:key="@string/p_show_not_in_list_filter"
|
||||||
|
android:title="@string/tag_FEx_untagged" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory android:title="@string/tags">
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="@string/p_tags_enabled"
|
||||||
|
android:title="@string/enabled" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:dependency="@string/p_tags_enabled"
|
||||||
|
android:key="@string/p_tags_hide_unused"
|
||||||
|
android:title="@string/hide_unused_tags" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory android:title="@string/places">
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="@string/p_places_enabled"
|
||||||
|
android:title="@string/enabled" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:dependency="@string/p_places_enabled"
|
||||||
|
android:key="@string/p_places_hide_unused"
|
||||||
|
android:title="@string/hide_unused_places" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
Loading…
Reference in New Issue