/** * Shows the simplified settings UI if the device configuration dictates that a simplified, * single-pane UI should be shown. */ @SuppressWarnings("deprecation") private void setupSimplePreferencesScreen() { if (!SettingsActivity.isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. this.addPreferencesFromResource(R.xml.pref_general); // Add 'notifications' preferences, and a corresponding header. PreferenceCategory preferencesFakeHeader = new PreferenceCategory(this); preferencesFakeHeader.setTitle(R.string.pref_header_notifications); this.getPreferenceScreen().addPreference(preferencesFakeHeader); this.addPreferencesFromResource(R.xml.pref_notification); // Add 'Other' preferences, and a corresponding header. PreferenceCategory otherFakeHeader = new PreferenceCategory(this); otherFakeHeader.setTitle(R.string.pref_header_other); this.getPreferenceScreen().addPreference(otherFakeHeader); this.addPreferencesFromResource(R.xml.pref_other); // 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. SettingsActivity.bindPreferenceSummaryToValue( this.findPreference(this.getString(R.string.pref_key_notifications_alarms_ringtone))); }
/** {@inheritDoc} */ @Override @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onBuildHeaders(List<PreferenceActivity.Header> target) { if (!SettingsActivity.isSimplePreferences(this)) { this.loadHeadersFromResource(R.xml.pref_headers, target); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.addPreferencesFromResource(R.xml.pref_notification); // 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. SettingsActivity.bindPreferenceSummaryToValue( this.findPreference(this.getString(R.string.pref_key_notifications_alarms_ringtone))); }
/** * Determines whether the simplified settings UI should be shown. This is true if this is forced * via {@link #ALWAYS_SIMPLE_PREFS}, or the device doesn't have newer APIs like {@link * PreferenceFragment}, or the device doesn't have an extra-large screen. In these cases, a * single-pane "simplified" settings UI should be shown. */ private static boolean isSimplePreferences(Context context) { return SettingsActivity.ALWAYS_SIMPLE_PREFS || Build.VERSION_CODES.HONEYCOMB > Build.VERSION.SDK_INT || !SettingsActivity.isXLargeTablet(context); }
/** {@inheritDoc} */ @Override public boolean onIsMultiPane() { return SettingsActivity.isXLargeTablet(this) && !SettingsActivity.isSimplePreferences(this); }