diff --git a/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java b/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java index 34dadcb37..059719f31 100644 --- a/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/core/LabsPreferences.java @@ -7,7 +7,6 @@ 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 LabsPreferences extends TodorooPreferenceActivity { @@ -17,6 +16,8 @@ public class LabsPreferences extends TodorooPreferenceActivity { return R.xml.preferences_labs; } + public static final int PERFORMANCE_SETTING_CHANGED = 3; + @Override public void updatePreferences(Preference preference, Object value) { final Resources r = getResources(); @@ -25,7 +26,7 @@ public class LabsPreferences extends TodorooPreferenceActivity { preference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference p, Object newValue) { - DialogUtilities.okDialog(LabsPreferences.this, r.getString(R.string.EPr_swipe_lists_restart_alert), null); + setResult(PERFORMANCE_SETTING_CHANGED); return true; } }); diff --git a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java index 472067224..d995b574f 100644 --- a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java +++ b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java @@ -4,6 +4,7 @@ package com.todoroo.astrid.activity; import java.util.ArrayList; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map.Entry; @@ -42,6 +43,7 @@ import com.todoroo.andlib.utility.Preferences; import com.todoroo.andlib.utility.TodorooPreferenceActivity; import com.todoroo.astrid.actfm.ActFmLoginActivity; import com.todoroo.astrid.api.AstridApiConstants; +import com.todoroo.astrid.core.LabsPreferences; import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.data.Task; import com.todoroo.astrid.helper.MetadataHelper; @@ -73,8 +75,10 @@ public class EditPreferences extends TodorooPreferenceActivity { private static final int POWER_PACK_PREFERENCE = 5; private static final int REQUEST_CODE_SYNC = 0; + private static final int REQUEST_CODE_PERFORMANCE = 1; public static final int RESULT_CODE_THEME_CHANGED = 1; + public static final int RESULT_CODE_PERFORMANCE_PREF_CHANGED = 2; // --- instance variables @@ -193,6 +197,12 @@ public class EditPreferences extends TodorooPreferenceActivity { startActivity(intent); } + private static final HashMap, Integer> PREFERENCE_REQUEST_CODES = new HashMap, Integer>(); + static { + PREFERENCE_REQUEST_CODES.put(SyncProviderPreferences.class, REQUEST_CODE_SYNC); + PREFERENCE_REQUEST_CODES.put(LabsPreferences.class, REQUEST_CODE_PERFORMANCE); + } + private void addPluginPreferences(PreferenceScreen screen) { Intent queryIntent = new Intent(AstridApiConstants.ACTION_SETTINGS); PackageManager pm = getPackageManager(); @@ -218,11 +228,12 @@ public class EditPreferences extends TodorooPreferenceActivity { preference.setTitle(resolveInfo.activityInfo.loadLabel(pm)); try { Class intentComponent = Class.forName(intent.getComponent().getClassName()); - if (SyncProviderPreferences.class.equals(intentComponent.getSuperclass())) { + if (PREFERENCE_REQUEST_CODES.containsKey(intentComponent)) { + final int code = PREFERENCE_REQUEST_CODES.get(intentComponent); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference pref) { - startActivityForResult(intent, REQUEST_CODE_SYNC); + startActivityForResult(intent, code); return true; } }); @@ -411,6 +422,9 @@ public class EditPreferences extends TodorooPreferenceActivity { setResult(SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE); finish(); return; + } else if (requestCode == REQUEST_CODE_PERFORMANCE && resultCode == LabsPreferences.PERFORMANCE_SETTING_CHANGED) { + setResult(RESULT_CODE_PERFORMANCE_PREF_CHANGED); + return; } try { VoiceOutputService.getVoiceOutputInstance().handleActivityResult(requestCode, resultCode, data); diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java index 52df586e7..ab862e227 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java @@ -752,10 +752,11 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, return; if (requestCode == ACTIVITY_SETTINGS) { - if (resultCode == EditPreferences.RESULT_CODE_THEME_CHANGED) { + if (resultCode == EditPreferences.RESULT_CODE_THEME_CHANGED || resultCode == EditPreferences.RESULT_CODE_PERFORMANCE_PREF_CHANGED) { getActivity().finish(); getActivity().startActivity(getActivity().getIntent()); TasksWidget.updateWidgets(getActivity()); + return; } else if (resultCode == SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE) { Preferences.setLong(SyncActionHelper.PREF_LAST_AUTO_SYNC, 0); // Forces autosync to occur after login }