Add preference to open most recently used list

pull/1002/head
Alex Baker 4 years ago
parent 5ec70afabb
commit 4624ce552c

@ -33,7 +33,6 @@ import io.reactivex.schedulers.Schedulers
import org.tasks.BuildConfig import org.tasks.BuildConfig
import org.tasks.LocalBroadcastManager import org.tasks.LocalBroadcastManager
import org.tasks.R import org.tasks.R
import org.tasks.Strings.isNullOrEmpty
import org.tasks.activities.TagSettingsActivity import org.tasks.activities.TagSettingsActivity
import org.tasks.billing.Inventory import org.tasks.billing.Inventory
import org.tasks.data.Place import org.tasks.data.Place
@ -56,8 +55,8 @@ import org.tasks.themes.Theme
import org.tasks.themes.ThemeColor import org.tasks.themes.ThemeColor
import org.tasks.ui.DeadlineControlSet.DueDateChangeListener import org.tasks.ui.DeadlineControlSet.DueDateChangeListener
import org.tasks.ui.EmptyTaskEditFragment.Companion.newEmptyTaskEditFragment import org.tasks.ui.EmptyTaskEditFragment.Companion.newEmptyTaskEditFragment
import org.tasks.ui.NavigationDrawerFragment
import org.tasks.ui.ListFragment.OnListChanged import org.tasks.ui.ListFragment.OnListChanged
import org.tasks.ui.NavigationDrawerFragment
import org.tasks.ui.TaskListViewModel import org.tasks.ui.TaskListViewModel
import javax.inject.Inject import javax.inject.Inject
@ -182,7 +181,11 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
Single.fromCallable { Single.fromCallable {
val filter = intent.getStringExtra(LOAD_FILTER) val filter = intent.getStringExtra(LOAD_FILTER)
intent.removeExtra(LOAD_FILTER) intent.removeExtra(LOAD_FILTER)
if (isNullOrEmpty(filter)) defaultFilterProvider.defaultFilter else defaultFilterProvider.getFilterFromPreference(filter) if (filter.isNullOrBlank()) {
defaultFilterProvider.startupFilter
} else {
defaultFilterProvider.getFilterFromPreference(filter)
}
} }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
@ -245,6 +248,7 @@ class MainActivity : InjectingAppCompatActivity(), TaskListFragmentCallbackHandl
} }
filter = newFilter filter = newFilter
navigationDrawer.setSelected(filter) navigationDrawer.setSelected(filter)
defaultFilterProvider.setLastViewedFilter(filter)
applyTheme() applyTheme()
val fragmentManager = supportFragmentManager val fragmentManager = supportFragmentManager
fragmentManager fragmentManager

@ -94,6 +94,10 @@ public class DefaultFilterProvider {
setFilterPreference(filter, R.string.p_default_list); setFilterPreference(filter, R.string.p_default_list);
} }
public void setLastViewedFilter(Filter filter) {
setFilterPreference(filter, R.string.p_last_viewed_list);
}
public Filter getDefaultRemoteList() { public Filter getDefaultRemoteList() {
return getFilterFromPreference( return getFilterFromPreference(
preferences.getStringValue(R.string.p_default_remote_list), null); preferences.getStringValue(R.string.p_default_remote_list), null);
@ -103,6 +107,13 @@ public class DefaultFilterProvider {
setFilterPreference(filter, R.string.p_default_remote_list); setFilterPreference(filter, R.string.p_default_remote_list);
} }
public Filter getStartupFilter() {
return getFilterFromPreference(
preferences.getBoolean(R.string.p_open_last_viewed_list, true)
? R.string.p_last_viewed_list
: R.string.p_default_list);
}
public Filter getFilterFromPreference(int resId) { public Filter getFilterFromPreference(int resId) {
return getFilterFromPreference(preferences.getStringValue(resId)); return getFilterFromPreference(preferences.getStringValue(resId));
} }

@ -74,7 +74,7 @@ public class ShortcutConfigActivity extends ThemedInjectingAppCompatActivity
toolbar.setNavigationOnClickListener(v -> save()); toolbar.setNavigationOnClickListener(v -> save());
if (icicle == null) { if (icicle == null) {
selectedFilter = defaultFilterProvider.getDefaultFilter(); selectedFilter = defaultFilterProvider.getStartupFilter();
selectedTheme = 7; selectedTheme = 7;
} else { } else {
selectedFilter = icicle.getParcelable(EXTRA_FILTER); selectedFilter = icicle.getParcelable(EXTRA_FILTER);

@ -281,6 +281,8 @@
<string name="p_collect_statistics">collect_statistics</string> <string name="p_collect_statistics">collect_statistics</string>
<string name="p_back_button_saves_task">back_button_saves_task</string> <string name="p_back_button_saves_task">back_button_saves_task</string>
<string name="p_open_last_viewed_list">open_last_viewed_list</string>
<string name="p_last_viewed_list">last_viewed_list</string>
<string name="p_default_list">default_list</string> <string name="p_default_list">default_list</string>
<string name="p_badges_enabled">badges_enabled</string> <string name="p_badges_enabled">badges_enabled</string>

@ -631,4 +631,6 @@ File %1$s contained %2$s.\n\n
<string name="got_it">Got it!</string> <string name="got_it">Got it!</string>
<string name="sort_created_group">Created %s</string> <string name="sort_created_group">Created %s</string>
<string name="sort_modified_group">Modified %s</string> <string name="sort_modified_group">Modified %s</string>
<string name="on_launch">On launch</string>
<string name="open_last_viewed_list">Open last viewed list</string>
</resources> </resources>

@ -27,12 +27,24 @@
android:summaryOff="@string/desaturate_colors_summary_off" /> android:summaryOff="@string/desaturate_colors_summary_off" />
<PreferenceCategory <PreferenceCategory
android:key="@string/task_list_options" android:title="@string/on_launch">
android:title="@string/task_list_options">
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="@string/p_open_last_viewed_list"
android:disableDependentsState="true"
android:title="@string/open_last_viewed_list" />
<Preference <Preference
android:key="@string/p_default_list" android:key="@string/p_default_list"
android:title="@string/default_list" /> android:title="@string/widget_open_list"
android:dependency="@string/p_open_last_viewed_list" />
</PreferenceCategory>
<PreferenceCategory
android:key="@string/task_list_options"
android:title="@string/task_list_options">
<SeekBarPreference <SeekBarPreference
android:defaultValue="16" android:defaultValue="16"

Loading…
Cancel
Save