simplyfy SettingsActiviy code
This commit is contained in:
parent
b256c9ed15
commit
75b9d0e833
|
@ -16,24 +16,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setupSimplePreferencesScreen();
|
||||
}
|
||||
|
||||
private void setupSimplePreferencesScreen() {
|
||||
// Add 'general' preferences.
|
||||
addPreferencesFromResource(R.xml.pref_general);
|
||||
|
||||
// Add 'date' preferences, and a corresponding header.
|
||||
PreferenceCategory fakeHeaderDateTime = new PreferenceCategory(this);
|
||||
fakeHeaderDateTime.setTitle(R.string.pref_header_datetime);
|
||||
getPreferenceScreen().addPreference(fakeHeaderDateTime);
|
||||
addPreferencesFromResource(R.xml.pref_datetime);
|
||||
|
||||
// Add 'notifications' preferences, and a corresponding header.
|
||||
PreferenceCategory fakeHeader = new PreferenceCategory(this);
|
||||
fakeHeader.setTitle(R.string.pref_header_notifications);
|
||||
getPreferenceScreen().addPreference(fakeHeader);
|
||||
addPreferencesFromResource(R.xml.pref_notification);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
Preference pref = (Preference) findPreference("notifications_generic");
|
||||
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
|
@ -43,14 +26,6 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Add 'development' preferences, and a corresponding header.
|
||||
PreferenceCategory fakeHeaderDev = new PreferenceCategory(this);
|
||||
fakeHeaderDev.setTitle(R.string.pref_header_development);
|
||||
getPreferenceScreen().addPreference(fakeHeaderDev);
|
||||
addPreferencesFromResource(R.xml.pref_development);
|
||||
|
||||
|
||||
final Preference developmentMiaddr = findPreference("development_miaddr");
|
||||
bindPreferenceSummaryToValue(developmentMiaddr);
|
||||
|
||||
|
@ -64,12 +39,6 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
// Bind the summaries of EditText/List/Dialog/Ringtone preferences to
|
||||
// their values. When their values change, their summaries are updated
|
||||
// to reflect the new value, per the Android Design guidelines.
|
||||
|
||||
//bindPreferenceSummaryToValue(findPreference("notifications_sms_whenscreenon"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="datetime_synconconnect"
|
||||
android:title="@string/pref_title_datetime_syctimeonconnect" />
|
||||
</PreferenceScreen>
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<EditTextPreference
|
||||
android:key="development_miaddr"
|
||||
android:title="@string/pref_title_development_miaddr"
|
||||
android:digits="0123456789ABCDEF:"
|
||||
android:maxLength="17" />
|
||||
</PreferenceScreen>
|
|
@ -1,6 +0,0 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="general_autoconnectonbluetooth"
|
||||
android:title="@string/pref_title_general_autoconnectonbluetooth" />
|
||||
</PreferenceScreen>
|
|
@ -1,43 +0,0 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- A 'parent' preference, which enables/disables child preferences (below)
|
||||
when checked/unchecked. -->
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="notifications_sms"
|
||||
android:title="@string/pref_title_notifications_sms" />
|
||||
|
||||
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="notifications_sms"
|
||||
android:key="notifications_sms_whenscreenon"
|
||||
android:title="@string/pref_title_whenscreenon" />
|
||||
|
||||
<!-- A 'parent' preference, which enables/disables child preferences (below)
|
||||
when checked/unchecked. -->
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="notifications_k9mail"
|
||||
android:title="@string/pref_title_notifications_k9mail" />
|
||||
|
||||
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="notifications_k9mail"
|
||||
android:key="notifications_k9mail_whenscreenon"
|
||||
android:title="@string/pref_title_whenscreenon" />
|
||||
|
||||
<!-- A 'parent' preference, which enables/disables child preferences (below)
|
||||
when checked/unchecked. -->
|
||||
<Preference
|
||||
android:key="notifications_generic"
|
||||
android:title="@string/pref_title_notifications_generic" />
|
||||
|
||||
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="notifications_generic_whenscreenon"
|
||||
android:title="@string/pref_title_whenscreenon" />
|
||||
|
||||
</PreferenceScreen>
|
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_general"
|
||||
android:key="pref_key_general">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="general_autoconnectonbluetooth"
|
||||
android:title="@string/pref_title_general_autoconnectonbluetooth" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_datetime"
|
||||
android:key="pref_key_datetime">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="datetime_synconconnect"
|
||||
android:title="@string/pref_title_datetime_syctimeonconnect" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_notifications"
|
||||
android:key="pref_key_notifications">
|
||||
<!-- A 'parent' preference, which enables/disables child preferences (below)
|
||||
when checked/unchecked. -->
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="notifications_sms"
|
||||
android:title="@string/pref_title_notifications_sms" />
|
||||
|
||||
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="notifications_sms"
|
||||
android:key="notifications_sms_whenscreenon"
|
||||
android:title="@string/pref_title_whenscreenon" />
|
||||
|
||||
<!-- A 'parent' preference, which enables/disables child preferences (below)
|
||||
when checked/unchecked. -->
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="notifications_k9mail"
|
||||
android:title="@string/pref_title_notifications_k9mail" />
|
||||
|
||||
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="notifications_k9mail"
|
||||
android:key="notifications_k9mail_whenscreenon"
|
||||
android:title="@string/pref_title_whenscreenon" />
|
||||
|
||||
<!-- A 'parent' preference, which enables/disables child preferences (below)
|
||||
when checked/unchecked. -->
|
||||
<Preference
|
||||
android:key="notifications_generic"
|
||||
android:title="@string/pref_title_notifications_generic" />
|
||||
|
||||
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="notifications_generic_whenscreenon"
|
||||
android:title="@string/pref_title_whenscreenon" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_development"
|
||||
android:key="pref_key_development">
|
||||
<EditTextPreference
|
||||
android:key="development_miaddr"
|
||||
android:title="@string/pref_title_development_miaddr"
|
||||
android:digits="0123456789ABCDEF:"
|
||||
android:maxLength="17" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue