Added place in the preferences to set configuration defaults

pull/14/head
Sam Bosley 12 years ago
parent ae6b12010f
commit 62ac52e740

@ -271,6 +271,12 @@
<string name="p_taskRowPrefs">taskRowPrefs</string>
<string name="p_fullTaskTitle">fullTaskTitle</string>
<!-- Configurations -->
<string name="p_configurations">p_configurations</string>
<string name="p_config_default">p_config_default</string>
<string name="p_config_lite">p_config_lite</string>
<!-- ========================================================= DEFAULTS == -->
<!-- default urgency setting (corresponds to entry in TEA_urgency) -->

@ -752,17 +752,29 @@
<string name="EPr_ideas_tab_description">Get ideas to help you complete tasks</string>
<!-- Preferences: calendar event start time -->
<string name = "EPr_cal_end_or_start_at_due_time">Calendar event time</string>
<string name = "EPr_cal_end_at_due_time">End calendar events at due time</string>
<string name = "EPr_cal_start_at_due_time">Start calendar events at due time</string>
<string name="EPr_cal_end_or_start_at_due_time">Calendar event time</string>
<string name="EPr_cal_end_at_due_time">End calendar events at due time</string>
<string name="EPr_cal_start_at_due_time">Start calendar events at due time</string>
<string name="EPr_force_phone_layout">Use phone layout</string>
<string name="EPr_show_featured_lists">Show featured lists</string>
<!-- Configurations -->
<string name="EPr_configurations_title">Set configuration</string>
<string name="EPr_config_default">Default</string>
<string name="EPr_config_lite">Astrid Lite</string>
<!-- Swipe between lists -->
<!-- Dialog title when setting preference configuration -->
<string name="EPr_config_dialog_title">Set configuration?</string>
<!-- Dialog prompt when setting preference configuration (%s -> name of configuration)-->
<string name="EPr_config_dialog_text">Reset preferences to the %s configuration?</string>
<!-- default configuration name for the above dialog -->
<string name="EPr_config_dialog_default_id">default</string>
<!-- Swipe between lists -->
<!-- Preference: swipe between lists performance -->
<string name="EPr_swipe_lists_performance_title">Swipe between lists</string>

@ -180,6 +180,12 @@
<CheckBoxPreference
android:key="@string/p_use_contact_picker"
android:title="@string/EPr_use_contact_picker"/>
<PreferenceScreen android:key="@string/p_configurations"
android:title="@string/EPr_configurations_title">
<PreferenceScreen android:title="@string/EPr_config_default" android:key="@string/p_config_default" />
<PreferenceScreen android:title="@string/EPr_config_lite" android:key="@string/p_config_lite"/>
</PreferenceScreen>
</PreferenceScreen>

@ -66,6 +66,9 @@ import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.sync.SyncProviderPreferences;
import com.todoroo.astrid.ui.ContactListAdapter;
import com.todoroo.astrid.ui.TaskListFragmentPager;
import com.todoroo.astrid.utility.AstridDefaultPreferenceSpec;
import com.todoroo.astrid.utility.AstridLitePreferenceSpec;
import com.todoroo.astrid.utility.AstridPreferenceSpec;
import com.todoroo.astrid.utility.Constants;
import com.todoroo.astrid.utility.Flags;
import com.todoroo.astrid.voice.VoiceInputAssistant;
@ -121,6 +124,29 @@ public class EditPreferences extends TodorooPreferenceActivity {
}
}
private class SetDefaultsClickListener implements OnPreferenceClickListener {
private final AstridPreferenceSpec spec;
private final int nameId;
public SetDefaultsClickListener(AstridPreferenceSpec spec, int nameId) {
this.spec = spec;
this.nameId = nameId;
}
@Override
public boolean onPreferenceClick(Preference preference) {
DialogUtilities.okCancelDialog(EditPreferences.this, getString(R.string.EPr_config_dialog_title),
getString(R.string.EPr_config_dialog_text, getString(nameId)), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
spec.resetDefaults();
setResult(RESULT_CODE_PERFORMANCE_PREF_CHANGED);
finish();
}
}, null);
return true;
}
}
@Override
public int getPreferenceResource() {
return R.xml.preferences;
@ -644,6 +670,12 @@ public class EditPreferences extends TodorooPreferenceActivity {
findPreference(getString(R.string.p_fontSize)).setOnPreferenceChangeListener(new SetResultOnPreferenceChangeListener(RESULT_CODE_PERFORMANCE_PREF_CHANGED));
findPreference(getString(R.string.p_config_default)).setOnPreferenceClickListener(
new SetDefaultsClickListener(new AstridDefaultPreferenceSpec(), R.string.EPr_config_dialog_default_id));
findPreference(getString(R.string.p_config_lite)).setOnPreferenceClickListener(
new SetDefaultsClickListener(new AstridLitePreferenceSpec(), R.string.EPr_config_lite));
int[] menuPrefs = { R.string.p_show_menu_search, R.string.p_show_menu_friends, R.string.p_show_featured_lists,
R.string.p_show_menu_sync, R.string.p_show_menu_sort, R.string.p_show_menu_addons
};

@ -14,7 +14,7 @@ public abstract class AstridPreferenceSpec {
if (ifUnset)
Preferences.setIfUnset(prefs, editor, r, key, value);
else
Preferences.setInt(r.getString(key), value);
Preferences.setString(r.getString(key), Integer.toString(value));
}
protected static void setPreference(SharedPreferences prefs, Editor editor, Resources r, int key, boolean value, boolean ifUnset) {

Loading…
Cancel
Save