Made swipe between lists disableable

pull/14/head
Sam Bosley 13 years ago
parent d42471a5f6
commit 9519517073

@ -1,8 +1,13 @@
package com.todoroo.astrid.core; package com.todoroo.astrid.core;
import android.content.res.Resources;
import android.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.text.TextUtils;
import com.timsu.astrid.R; import com.timsu.astrid.R;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.TodorooPreferenceActivity; import com.todoroo.andlib.utility.TodorooPreferenceActivity;
public class PerformancePreferences extends TodorooPreferenceActivity { public class PerformancePreferences extends TodorooPreferenceActivity {
@ -14,8 +19,27 @@ public class PerformancePreferences extends TodorooPreferenceActivity {
@Override @Override
public void updatePreferences(Preference preference, Object value) { 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));
}
} }
} }

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/Content"
android:id="@+id/tasklist_fragment_container">
</FrameLayout>

@ -160,6 +160,7 @@
</string-array> </string-array>
<string-array name="EPr_swipe_lists_performance_mode_values"> <string-array name="EPr_swipe_lists_performance_mode_values">
<item>0</item>
<item>1</item> <item>1</item>
<item>3</item> <item>3</item>
<item>8</item> <item>8</item>

@ -547,12 +547,25 @@
<string name="EPr_swipe_lists_performance_title">Swipe between lists</string> <string name="EPr_swipe_lists_performance_title">Swipe between lists</string>
<string name="EPr_swipe_lists_performance_subtitle">Controls the memory performance of swipe between lists</string> <string name="EPr_swipe_lists_performance_subtitle">Controls the memory performance of swipe between lists</string>
<string name="EPr_swipe_lists_restart_alert">You will need to restart Astrid for this change to take effect</string>
<string-array name="EPr_swipe_lists_performance_mode"> <string-array name="EPr_swipe_lists_performance_mode">
<item>Memory Conservation</item> <item>No swipe</item>
<item>Normal</item> <item>Conserve Memory</item>
<item>Normal Performance</item>
<item>High Performance</item> <item>High Performance</item>
</string-array> </string-array>
<string-array name="EPr_swipe_lists_performance_desc">
<item>Swipe between lists is disabled</item>
<item>Slower performance</item>
<item>Default setting</item>
<item>Uses more system resources</item>
</string-array>
<!-- Format string for displaying the currently selected preference. $1 is name of selected mode, $2 is description -->
<string name="EPr_swipe_lists_display">%1$s - %2$s</string>
<string-array name="EPr_default_reminders_mode"> <string-array name="EPr_default_reminders_mode">
<!-- reminders duration: labels for "Task Defaults" preference item. --> <!-- reminders duration: labels for "Task Defaults" preference item. -->
<item>@string/TEA_reminder_mode_once</item> <item>@string/TEA_reminder_mode_once</item>

@ -30,6 +30,7 @@ import com.todoroo.andlib.sql.Functions;
import com.todoroo.andlib.sql.QueryTemplate; import com.todoroo.andlib.sql.QueryTemplate;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.TagSettingsActivity; import com.todoroo.astrid.actfm.TagSettingsActivity;
import com.todoroo.astrid.actfm.TagUpdatesFragment; import com.todoroo.astrid.actfm.TagUpdatesFragment;
import com.todoroo.astrid.actfm.TagViewFragment; import com.todoroo.astrid.actfm.TagViewFragment;
@ -74,6 +75,8 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
private FragmentPopover commentsPopover; private FragmentPopover commentsPopover;
private MainMenuPopover mainMenuPopover; private MainMenuPopover mainMenuPopover;
private boolean swipeEnabled = false;
private final TagDeletedReceiver tagDeletedReceiver = new TagDeletedReceiver(); private final TagDeletedReceiver tagDeletedReceiver = new TagDeletedReceiver();
private final OnClickListener mainMenuClickListener = new OnClickListener() { private final OnClickListener mainMenuClickListener = new OnClickListener() {
@ -134,10 +137,14 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
ThemeService.applyTheme(this); ThemeService.applyTheme(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (AndroidUtilities.isTabletSized(this)) if (AndroidUtilities.isTabletSized(this)) {
setContentView(R.layout.task_list_wrapper_activity_3pane); 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); setContentView(R.layout.task_list_wrapper_activity);
swipeEnabled = true;
}
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
@ -172,7 +179,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
if (extras != null) if (extras != null)
extras = (Bundle) extras.clone(); extras = (Bundle) extras.clone();
if (fragmentLayout == LAYOUT_SINGLE) { if (swipeIsEnabled()) {
FilterListFragment flf = getFilterListFragment(); FilterListFragment flf = getFilterListFragment();
if (flf == null) if (flf == null)
throw new RuntimeException("Filterlist fragment was null, needs to exist to construct the fragment pager"); //$NON-NLS-1$ 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 @Override
public TaskListFragment getTaskListFragment() { public TaskListFragment getTaskListFragment() {
if (fragmentLayout == LAYOUT_SINGLE) { if (swipeIsEnabled()) {
return tlfPager.getCurrentFragment(); return tlfPager.getCurrentFragment();
} else { } else {
return super.getTaskListFragment(); return super.getTaskListFragment();
@ -204,7 +215,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
@Override @Override
public void setupTasklistFragmentWithFilterAndCustomTaskList(Filter filter, Bundle extras, Class<?> customTaskList) { public void setupTasklistFragmentWithFilterAndCustomTaskList(Filter filter, Bundle extras, Class<?> customTaskList) {
if (fragmentLayout == LAYOUT_SINGLE) { if (swipeIsEnabled()) {
tlfPager.showFilterWithCustomTaskList(filter, customTaskList); tlfPager.showFilterWithCustomTaskList(filter, customTaskList);
tlfPager.setAdapter(tlfPagerAdapter); // Hack to force reload of current page tlfPager.setAdapter(tlfPagerAdapter); // Hack to force reload of current page
} else { } else {
@ -336,7 +347,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
listsPopover.dismiss(); listsPopover.dismiss();
setCommentsCount(0); setCommentsCount(0);
if (fragmentLayout == LAYOUT_SINGLE) { if (swipeIsEnabled()) {
tlfPager.showFilter((Filter) item); tlfPager.showFilter((Filter) item);
return true; return true;
} }

Loading…
Cancel
Save