diff --git a/astrid/plugin-src/com/todoroo/astrid/core/PerformancePreferences.java b/astrid/plugin-src/com/todoroo/astrid/core/PerformancePreferences.java index c3b4982bc..c57c9ed16 100644 --- a/astrid/plugin-src/com/todoroo/astrid/core/PerformancePreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/core/PerformancePreferences.java @@ -1,8 +1,13 @@ package com.todoroo.astrid.core; +import android.content.res.Resources; import android.preference.Preference; +import android.preference.Preference.OnPreferenceChangeListener; +import android.text.TextUtils; import com.timsu.astrid.R; +import com.todoroo.andlib.utility.AndroidUtilities; +import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.TodorooPreferenceActivity; public class PerformancePreferences extends TodorooPreferenceActivity { @@ -14,8 +19,27 @@ public class PerformancePreferences extends TodorooPreferenceActivity { @Override public void updatePreferences(Preference preference, Object value) { - // TODO Auto-generated method stub + final Resources r = getResources(); + if (r.getString(R.string.p_swipe_lists_performance_key).equals(preference.getKey())) { + preference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference p, Object newValue) { + DialogUtilities.okDialog(PerformancePreferences.this, r.getString(R.string.EPr_swipe_lists_restart_alert), null); + return true; + } + }); + + int index = 0; + if(value instanceof String && !TextUtils.isEmpty((String)value)) + index = AndroidUtilities.indexOf(r.getStringArray(R.array.EPr_swipe_lists_performance_mode_values), (String)value); + if (index < 0) + index = 0; + + String name = r.getStringArray(R.array.EPr_swipe_lists_performance_mode)[index]; + String desc = r.getStringArray(R.array.EPr_swipe_lists_performance_desc)[index]; + preference.setSummary(r.getString(R.string.EPr_swipe_lists_display, name, desc)); + } } } diff --git a/astrid/res/layout/task_list_wrapper_activity_no_swipe.xml b/astrid/res/layout/task_list_wrapper_activity_no_swipe.xml new file mode 100644 index 000000000..7f3cc135c --- /dev/null +++ b/astrid/res/layout/task_list_wrapper_activity_no_swipe.xml @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index 6b721876c..76a360c85 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -160,6 +160,7 @@ + 0 1 3 8 diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index 0ec3ed140..2a2ffca95 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -547,12 +547,25 @@ Swipe between lists Controls the memory performance of swipe between lists + You will need to restart Astrid for this change to take effect + - Memory Conservation - Normal + No swipe + Conserve Memory + Normal Performance High Performance + + + Swipe between lists is disabled + Slower performance + Default setting + Uses more system resources + + + %1$s - %2$s + @string/TEA_reminder_mode_once diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index d2f615182..24111b527 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -30,6 +30,7 @@ import com.todoroo.andlib.sql.Functions; import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.DialogUtilities; +import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.actfm.TagSettingsActivity; import com.todoroo.astrid.actfm.TagUpdatesFragment; import com.todoroo.astrid.actfm.TagViewFragment; @@ -74,6 +75,8 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener private FragmentPopover commentsPopover; private MainMenuPopover mainMenuPopover; + private boolean swipeEnabled = false; + private final TagDeletedReceiver tagDeletedReceiver = new TagDeletedReceiver(); private final OnClickListener mainMenuClickListener = new OnClickListener() { @@ -134,10 +137,14 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener ThemeService.applyTheme(this); super.onCreate(savedInstanceState); - if (AndroidUtilities.isTabletSized(this)) + if (AndroidUtilities.isTabletSized(this)) { setContentView(R.layout.task_list_wrapper_activity_3pane); - else + } else if (Preferences.getIntegerFromString(R.string.p_swipe_lists_performance_key, 3) == 0) { + setContentView(R.layout.task_list_wrapper_activity_no_swipe); + } else { setContentView(R.layout.task_list_wrapper_activity); + swipeEnabled = true; + } ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); @@ -172,7 +179,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener if (extras != null) extras = (Bundle) extras.clone(); - if (fragmentLayout == LAYOUT_SINGLE) { + if (swipeIsEnabled()) { FilterListFragment flf = getFilterListFragment(); if (flf == null) throw new RuntimeException("Filterlist fragment was null, needs to exist to construct the fragment pager"); //$NON-NLS-1$ @@ -193,9 +200,13 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener } } + private boolean swipeIsEnabled() { + return fragmentLayout == LAYOUT_SINGLE && swipeEnabled; + } + @Override public TaskListFragment getTaskListFragment() { - if (fragmentLayout == LAYOUT_SINGLE) { + if (swipeIsEnabled()) { return tlfPager.getCurrentFragment(); } else { return super.getTaskListFragment(); @@ -204,7 +215,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener @Override public void setupTasklistFragmentWithFilterAndCustomTaskList(Filter filter, Bundle extras, Class customTaskList) { - if (fragmentLayout == LAYOUT_SINGLE) { + if (swipeIsEnabled()) { tlfPager.showFilterWithCustomTaskList(filter, customTaskList); tlfPager.setAdapter(tlfPagerAdapter); // Hack to force reload of current page } else { @@ -336,7 +347,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener listsPopover.dismiss(); setCommentsCount(0); - if (fragmentLayout == LAYOUT_SINGLE) { + if (swipeIsEnabled()) { tlfPager.showFilter((Filter) item); return true; }