Don't need to restart astrid for swipe performance to take effect

pull/14/head
Sam Bosley 13 years ago
parent 32bd06219a
commit 472288b1b9

@ -7,7 +7,6 @@ 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.AndroidUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.TodorooPreferenceActivity; import com.todoroo.andlib.utility.TodorooPreferenceActivity;
public class LabsPreferences extends TodorooPreferenceActivity { public class LabsPreferences extends TodorooPreferenceActivity {
@ -17,6 +16,8 @@ public class LabsPreferences extends TodorooPreferenceActivity {
return R.xml.preferences_labs; return R.xml.preferences_labs;
} }
public static final int PERFORMANCE_SETTING_CHANGED = 3;
@Override @Override
public void updatePreferences(Preference preference, Object value) { public void updatePreferences(Preference preference, Object value) {
final Resources r = getResources(); final Resources r = getResources();
@ -25,7 +26,7 @@ public class LabsPreferences extends TodorooPreferenceActivity {
preference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { preference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference p, Object newValue) { 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; return true;
} }
}); });

@ -4,6 +4,7 @@
package com.todoroo.astrid.activity; package com.todoroo.astrid.activity;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -42,6 +43,7 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.andlib.utility.TodorooPreferenceActivity; import com.todoroo.andlib.utility.TodorooPreferenceActivity;
import com.todoroo.astrid.actfm.ActFmLoginActivity; import com.todoroo.astrid.actfm.ActFmLoginActivity;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.core.LabsPreferences;
import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.helper.MetadataHelper; 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 POWER_PACK_PREFERENCE = 5;
private static final int REQUEST_CODE_SYNC = 0; 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_THEME_CHANGED = 1;
public static final int RESULT_CODE_PERFORMANCE_PREF_CHANGED = 2;
// --- instance variables // --- instance variables
@ -193,6 +197,12 @@ public class EditPreferences extends TodorooPreferenceActivity {
startActivity(intent); startActivity(intent);
} }
private static final HashMap<Class<?>, Integer> PREFERENCE_REQUEST_CODES = new HashMap<Class<?>, 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) { private void addPluginPreferences(PreferenceScreen screen) {
Intent queryIntent = new Intent(AstridApiConstants.ACTION_SETTINGS); Intent queryIntent = new Intent(AstridApiConstants.ACTION_SETTINGS);
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
@ -218,11 +228,12 @@ public class EditPreferences extends TodorooPreferenceActivity {
preference.setTitle(resolveInfo.activityInfo.loadLabel(pm)); preference.setTitle(resolveInfo.activityInfo.loadLabel(pm));
try { try {
Class<?> intentComponent = Class.forName(intent.getComponent().getClassName()); 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() { preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference pref) { public boolean onPreferenceClick(Preference pref) {
startActivityForResult(intent, REQUEST_CODE_SYNC); startActivityForResult(intent, code);
return true; return true;
} }
}); });
@ -411,6 +422,9 @@ public class EditPreferences extends TodorooPreferenceActivity {
setResult(SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE); setResult(SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE);
finish(); finish();
return; return;
} else if (requestCode == REQUEST_CODE_PERFORMANCE && resultCode == LabsPreferences.PERFORMANCE_SETTING_CHANGED) {
setResult(RESULT_CODE_PERFORMANCE_PREF_CHANGED);
return;
} }
try { try {
VoiceOutputService.getVoiceOutputInstance().handleActivityResult(requestCode, resultCode, data); VoiceOutputService.getVoiceOutputInstance().handleActivityResult(requestCode, resultCode, data);

@ -752,10 +752,11 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
return; return;
if (requestCode == ACTIVITY_SETTINGS) { 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().finish();
getActivity().startActivity(getActivity().getIntent()); getActivity().startActivity(getActivity().getIntent());
TasksWidget.updateWidgets(getActivity()); TasksWidget.updateWidgets(getActivity());
return;
} else if (resultCode == SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE) { } else if (resultCode == SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE) {
Preferences.setLong(SyncActionHelper.PREF_LAST_AUTO_SYNC, 0); // Forces autosync to occur after login Preferences.setLong(SyncActionHelper.PREF_LAST_AUTO_SYNC, 0); // Forces autosync to occur after login
} }

Loading…
Cancel
Save