From 529bb2fcba1a152878c2c3e80ef421bfdc3640b3 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Thu, 19 Apr 2012 14:07:25 -0700 Subject: [PATCH] Added a prefrence to control how aggressive the fragment pager is with preloading task lists --- astrid/AndroidManifest.xml | 9 ++++++++ .../astrid/core/PerformancePreferences.java | 21 +++++++++++++++++++ astrid/res/values/keys.xml | 9 ++++++++ astrid/res/values/strings-core.xml | 13 ++++++++++++ astrid/res/xml/preferences_performance.xml | 11 ++++++++++ .../astrid/ui/TaskListFragmentPager.java | 6 +++--- .../astrid/utility/AstridPreferences.java | 1 + 7 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 astrid/plugin-src/com/todoroo/astrid/core/PerformancePreferences.java create mode 100644 astrid/res/xml/preferences_performance.xml diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml index 5f2324ecc..81214724e 100644 --- a/astrid/AndroidManifest.xml +++ b/astrid/AndroidManifest.xml @@ -261,6 +261,15 @@ + + + + + + + diff --git a/astrid/plugin-src/com/todoroo/astrid/core/PerformancePreferences.java b/astrid/plugin-src/com/todoroo/astrid/core/PerformancePreferences.java new file mode 100644 index 000000000..c3b4982bc --- /dev/null +++ b/astrid/plugin-src/com/todoroo/astrid/core/PerformancePreferences.java @@ -0,0 +1,21 @@ +package com.todoroo.astrid.core; + +import android.preference.Preference; + +import com.timsu.astrid.R; +import com.todoroo.andlib.utility.TodorooPreferenceActivity; + +public class PerformancePreferences extends TodorooPreferenceActivity { + + @Override + public int getPreferenceResource() { + return R.xml.preferences_performance; + } + + @Override + public void updatePreferences(Preference preference, Object value) { + // TODO Auto-generated method stub + + } + +} diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index c7af11315..6b721876c 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -159,6 +159,12 @@ 08 + + 1 + 3 + 8 + + colorize @@ -280,6 +286,9 @@ rmd_default_reminder_mode + + p_swipe_lists_perf + -1 diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index d0a173de1..0ec3ed140 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -539,6 +539,19 @@ Task Row Appearance + + + Performance + + + Swipe between lists + Controls the memory performance of swipe between lists + + + Memory Conservation + Normal + High Performance + diff --git a/astrid/res/xml/preferences_performance.xml b/astrid/res/xml/preferences_performance.xml new file mode 100644 index 000000000..a76131977 --- /dev/null +++ b/astrid/res/xml/preferences_performance.xml @@ -0,0 +1,11 @@ + + + + diff --git a/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java b/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java index b595b002c..b1a60aa19 100644 --- a/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java +++ b/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java @@ -9,6 +9,7 @@ import android.view.MotionEvent; import android.view.View; import com.timsu.astrid.R; +import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.adapter.TaskListFragmentPagerAdapter; import com.todoroo.astrid.api.Filter; @@ -16,11 +17,10 @@ import com.todoroo.astrid.utility.Flags; public class TaskListFragmentPager extends ViewPager { - private static final int OFFSCREEN_PAGE_LIMIT = 2; - public TaskListFragmentPager(Context context, AttributeSet attrs) { super(context, attrs); - setOffscreenPageLimit(OFFSCREEN_PAGE_LIMIT); + int offscreenPageLimit = Preferences.getIntegerFromString(R.string.p_swipe_lists_performance_key, 3); + setOffscreenPageLimit(offscreenPageLimit); } @Override diff --git a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java index ff3315f9e..3236aacc3 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java @@ -46,6 +46,7 @@ public class AstridPreferences { Preferences.setIfUnset(prefs, editor, r, R.string.p_rmd_default_random_hours, 0); Preferences.setIfUnset(prefs, editor, r, R.string.p_fontSize, 18); Preferences.setIfUnset(prefs, editor, r, R.string.p_showNotes, false); + Preferences.setIfUnset(prefs, editor, r, R.string.p_swipe_lists_performance_key, 3); if ("white-blue".equals(Preferences.getStringValue(R.string.p_theme))) { //$NON-NLS-1$ migrate from when white-blue wasn't the default Preferences.setString(R.string.p_theme, ThemeService.THEME_WHITE);