Sync should occur after turning on featured lists preference

pull/14/head
Sam Bosley 12 years ago
parent 227fd9d6ae
commit c538daf22a

@ -24,22 +24,32 @@ public class LabsPreferences extends TodorooPreferenceActivity {
return R.xml.preferences_labs; return R.xml.preferences_labs;
} }
public static final int PERFORMANCE_SETTING_CHANGED = 3; public static final int RESULT_TLA_NEEDS_REFRESH = 3;
public static final int RESULT_NEEDS_SYNC = 4;
private class SetResultOnPreferenceChangeListener implements OnPreferenceChangeListener {
private final int resultCode;
public SetResultOnPreferenceChangeListener(int resultCode) {
this.resultCode = resultCode;
}
private final OnPreferenceChangeListener settingChangedListener = new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference p, Object newValue) { public boolean onPreferenceChange(Preference p, Object newValue) {
setResult(PERFORMANCE_SETTING_CHANGED); setResult(resultCode);
updatePreferences(p, newValue); updatePreferences(p, newValue);
return true; return true;
} }
}; }
@Override @Override
public void onCreate(android.os.Bundle savedInstanceState) { public void onCreate(android.os.Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
EditPreferences.removeForbiddenPreferences(getPreferenceScreen(), getResources()); EditPreferences.removeForbiddenPreferences(getPreferenceScreen(), getResources());
if (!AndroidUtilities.isTabletSized(this)) {
PreferenceScreen screen = getPreferenceScreen();
screen.removePreference(screen.findPreference(getString(R.string.p_force_phone_layout)));
}
} }
@Override @Override
@ -48,7 +58,7 @@ public class LabsPreferences extends TodorooPreferenceActivity {
String key = preference.getKey(); String key = preference.getKey();
if (r.getString(R.string.p_swipe_lists_performance_key).equals(key)) { if (r.getString(R.string.p_swipe_lists_performance_key).equals(key)) {
preference.setOnPreferenceChangeListener(settingChangedListener); preference.setOnPreferenceChangeListener(new SetResultOnPreferenceChangeListener(RESULT_TLA_NEEDS_REFRESH));
int index = 0; int index = 0;
if(value instanceof String && !TextUtils.isEmpty((String)value)) if(value instanceof String && !TextUtils.isEmpty((String)value))
@ -76,12 +86,9 @@ public class LabsPreferences extends TodorooPreferenceActivity {
screen.removePreference(preference); screen.removePreference(preference);
} }
} else if (r.getString(R.string.p_force_phone_layout).equals(key)) { } else if (r.getString(R.string.p_force_phone_layout).equals(key)) {
if (!AndroidUtilities.isTabletSized(this)) { preference.setOnPreferenceChangeListener(new SetResultOnPreferenceChangeListener(RESULT_TLA_NEEDS_REFRESH));
PreferenceScreen screen = getPreferenceScreen(); } else if (r.getString(R.string.p_show_featured_lists_labs).equals(key)) {
screen.removePreference(preference); preference.setOnPreferenceChangeListener(new SetResultOnPreferenceChangeListener(RESULT_NEEDS_SYNC));
} else {
preference.setOnPreferenceChangeListener(settingChangedListener);
}
} }
} }

@ -85,7 +85,7 @@ 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; private static final int REQUEST_CODE_LABS = 1;
private static final int REQUEST_CODE_FILES_DIR = 2; private static final int REQUEST_CODE_FILES_DIR = 2;
public static final int RESULT_CODE_THEME_CHANGED = 1; public static final int RESULT_CODE_THEME_CHANGED = 1;
@ -253,7 +253,7 @@ public class EditPreferences extends TodorooPreferenceActivity {
private static final HashMap<Class<?>, Integer> PREFERENCE_REQUEST_CODES = new HashMap<Class<?>, Integer>(); private static final HashMap<Class<?>, Integer> PREFERENCE_REQUEST_CODES = new HashMap<Class<?>, Integer>();
static { static {
PREFERENCE_REQUEST_CODES.put(SyncProviderPreferences.class, REQUEST_CODE_SYNC); PREFERENCE_REQUEST_CODES.put(SyncProviderPreferences.class, REQUEST_CODE_SYNC);
PREFERENCE_REQUEST_CODES.put(LabsPreferences.class, REQUEST_CODE_PERFORMANCE); PREFERENCE_REQUEST_CODES.put(LabsPreferences.class, REQUEST_CODE_LABS);
} }
private void addPluginPreferences(PreferenceScreen screen) { private void addPluginPreferences(PreferenceScreen screen) {
@ -494,9 +494,13 @@ 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) { } else if (requestCode == REQUEST_CODE_LABS && resultCode == LabsPreferences.RESULT_TLA_NEEDS_REFRESH) {
setResult(RESULT_CODE_PERFORMANCE_PREF_CHANGED); setResult(RESULT_CODE_PERFORMANCE_PREF_CHANGED);
return; return;
} else if (requestCode == REQUEST_CODE_LABS && resultCode == LabsPreferences.RESULT_NEEDS_SYNC) {
if (Preferences.getBoolean(R.string.p_show_featured_lists_labs, false))
setResult(SyncProviderPreferences.RESULT_CODE_SYNCHRONIZE);
return;
} else if (requestCode == REQUEST_CODE_FILES_DIR && resultCode == RESULT_OK) { } else if (requestCode == REQUEST_CODE_FILES_DIR && resultCode == RESULT_OK) {
if (data != null) { if (data != null) {
String dir = data.getStringExtra(FileExplore.RESULT_DIR_SELECTED); String dir = data.getStringExtra(FileExplore.RESULT_DIR_SELECTED);

Loading…
Cancel
Save