Search in sources :

Example 36 with PreferenceScreen

use of android.preference.PreferenceScreen in project WordPress-Android by wordpress-mobile.

the class NotificationsSettingsFragment method configureOtherSettings.

private void configureOtherSettings() {
    PreferenceScreen otherBlogsScreen = (PreferenceScreen) findPreference(getString(R.string.pref_notification_other_blogs));
    addPreferencesForPreferenceScreen(otherBlogsScreen, Channel.OTHER, 0);
}
Also used : PreferenceScreen(android.preference.PreferenceScreen)

Example 37 with PreferenceScreen

use of android.preference.PreferenceScreen in project android_packages_apps_FM by CyanogenMod.

the class Settings method createPreferenceHierarchy.

private PreferenceScreen createPreferenceHierarchy() {
    int index = 0;
    if (mPrefs == null) {
        return null;
    }
    // Root
    PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
    // Band/Country
    String[] summaryBandItems = getResources().getStringArray(R.array.regional_band_summary);
    mBandPreference = new ListPreference(this);
    mBandPreference.setEntries(R.array.regional_band_entries);
    mBandPreference.setEntryValues(R.array.regional_band_values);
    mBandPreference.setDialogTitle(R.string.sel_band_menu);
    mBandPreference.setKey(REGIONAL_BAND_KEY);
    mBandPreference.setTitle(R.string.regional_band);
    index = FmSharedPreferences.getCountry();
    Log.d(LOGTAG, "createPreferenceHierarchy: Country: " + index);
    // Get the preference and list the value.
    if ((index < 0) || (index >= summaryBandItems.length)) {
        index = 0;
    }
    Log.d(LOGTAG, "createPreferenceHierarchy: CountrySummary: " + summaryBandItems[index]);
    mBandPreference.setSummary(summaryBandItems[index]);
    mBandPreference.setValueIndex(index);
    root.addPreference(mBandPreference);
    if (mRxMode) {
        // Audio Output (Stereo or Mono)
        String[] summaryAudioModeItems = getResources().getStringArray(R.array.ster_mon_entries);
        mAudioPreference = new ListPreference(this);
        mAudioPreference.setEntries(R.array.ster_mon_entries);
        mAudioPreference.setEntryValues(R.array.ster_mon_values);
        mAudioPreference.setDialogTitle(R.string.sel_audio_output);
        mAudioPreference.setKey(AUDIO_OUTPUT_KEY);
        mAudioPreference.setTitle(R.string.aud_output_mode);
        boolean audiomode = FmSharedPreferences.getAudioOutputMode();
        if (audiomode) {
            index = 0;
        } else {
            index = 1;
        }
        Log.d(LOGTAG, "createPreferenceHierarchy: audiomode: " + audiomode);
        mAudioPreference.setSummary(summaryAudioModeItems[index]);
        mAudioPreference.setValueIndex(index);
        root.addPreference(mAudioPreference);
        // AF Auto Enable (Checkbox)
        mAfPref = new CheckBoxPreference(this);
        mAfPref.setKey(AUTO_AF);
        mAfPref.setTitle(R.string.auto_select_af);
        mAfPref.setSummaryOn(R.string.auto_select_af_enabled);
        mAfPref.setSummaryOff(R.string.auto_select_af_disabled);
        boolean bAFAutoSwitch = FmSharedPreferences.getAutoAFSwitch();
        Log.d(LOGTAG, "createPreferenceHierarchy: bAFAutoSwitch: " + bAFAutoSwitch);
        mAfPref.setChecked(bAFAutoSwitch);
        root.addPreference(mAfPref);
        if (FMRadio.RECORDING_ENABLE) {
            String[] summaryRecordItems = getResources().getStringArray(R.array.record_durations_entries);
            mRecordDurPreference = new ListPreference(this);
            mRecordDurPreference.setEntries(R.array.record_durations_entries);
            mRecordDurPreference.setEntryValues(R.array.record_duration_values);
            mRecordDurPreference.setDialogTitle(R.string.sel_rec_dur);
            mRecordDurPreference.setKey(RECORD_DURATION_KEY);
            mRecordDurPreference.setTitle(R.string.record_dur);
            index = FmSharedPreferences.getRecordDuration();
            Log.d(LOGTAG, "createPreferenceHierarchy: recordDuration: " + index);
            // Get the preference and list the value.
            if ((index < 0) || (index >= summaryRecordItems.length)) {
                index = 0;
            }
            Log.d(LOGTAG, "createPreferenceHierarchy: recordDurationSummary: " + summaryRecordItems[index]);
            mRecordDurPreference.setSummary(summaryRecordItems[index]);
            mRecordDurPreference.setValueIndex(index);
            root.addPreference(mRecordDurPreference);
        }
    }
    mBluetoothBehaviour = new ListPreference(this);
    mBluetoothBehaviour.setEntries(R.array.bt_exit_behaviour_entries);
    mBluetoothBehaviour.setEntryValues(R.array.bt_exit_behaviour_values);
    mBluetoothBehaviour.setDialogTitle(R.string.pref_bt_behaviour_on_exit_dialog_title);
    mBluetoothBehaviour.setKey(BT_EXIT_BEHAVIOUR);
    mBluetoothBehaviour.setTitle(R.string.pref_bt_behaviour_on_exit_title);
    mBluetoothBehaviour.setSummary(R.string.pref_bt_behaviour_on_exit_summary);
    root.addPreference(mBluetoothBehaviour);
    mRemoveHeadset = new CheckBoxPreference(this);
    mRemoveHeadset.setKey(HEADSET_DC_BEHAVIOUR);
    mRemoveHeadset.setTitle(R.string.pref_headset_behaviour_title);
    mRemoveHeadset.setSummary(R.string.pref_headset_behaviour_summary);
    mRemoveHeadset.setChecked(FmSharedPreferences.getHeadsetDcBehaviour());
    root.addPreference(mRemoveHeadset);
    mRestoreDefaultPreference = new Preference(this);
    mRestoreDefaultPreference.setTitle(R.string.settings_revert_defaults_title);
    mRestoreDefaultPreference.setKey(RESTORE_FACTORY_DEFAULT);
    mRestoreDefaultPreference.setSummary(R.string.settings_revert_defaults_summary);
    mRestoreDefaultPreference.setOnPreferenceClickListener(this);
    root.addPreference(mRestoreDefaultPreference);
    // Add a new category
    PreferenceCategory prefCat = new PreferenceCategory(this);
    prefCat.setTitle(R.string.about_title);
    root.addPreference(prefCat);
    mAboutPreference = new Preference(this);
    mAboutPreference.setTitle(R.string.about_title);
    mAboutPreference.setKey(ABOUT_KEY);
    mAboutPreference.setSummary(R.string.about_summary);
    mAboutPreference.setOnPreferenceClickListener(this);
    root.addPreference(mAboutPreference);
    return root;
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) CheckBoxPreference(android.preference.CheckBoxPreference) CheckBoxPreference(android.preference.CheckBoxPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) PreferenceCategory(android.preference.PreferenceCategory) ListPreference(android.preference.ListPreference)

Example 38 with PreferenceScreen

use of android.preference.PreferenceScreen in project xabber-android by redsolution.

the class BaseSettingsFragment method setPreferences.

/**
 * Set values to the UI elements.
 *
 * @param source
 */
protected void setPreferences(Map<String, Object> source) {
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    for (int index = 0; index < preferenceScreen.getPreferenceCount(); index++) {
        Preference preference = preferenceScreen.getPreference(index);
        Object value = source.get(preference.getKey());
        setPreference(preference, value);
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) RingtonePreference(com.xabber.android.ui.widget.RingtonePreference) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference)

Example 39 with PreferenceScreen

use of android.preference.PreferenceScreen in project xabber-android by redsolution.

the class DebugSettingsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preference_debug);
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    preferenceScreen.removePreference(preferenceScreen.findPreference(getString(R.string.debug_log_key)));
    preferenceScreen.removePreference(preferenceScreen.findPreference(getString(R.string.cache_clear_key)));
    preferenceScreen.removePreference(preferenceScreen.findPreference(getString(R.string.debug_connection_errors_key)));
    Preference prefDownloadArchive = preferenceScreen.findPreference(getString(R.string.debug_download_all_messages_key));
    prefDownloadArchive.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            startMessageArchiveDownload();
            return true;
        }
    });
    if (!BuildConfig.DEBUG) {
        preferenceScreen.removePreference(prefDownloadArchive);
    }
    if (!SettingsManager.isCrashReportsSupported()) {
        preferenceScreen.removePreference(preferenceScreen.findPreference(getString(R.string.debug_crash_reports_key)));
    }
    PreferenceSummaryHelperActivity.updateSummary(preferenceScreen);
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) Preference(android.preference.Preference)

Example 40 with PreferenceScreen

use of android.preference.PreferenceScreen in project xabber-android by redsolution.

the class PresenceSettingsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preference_presence);
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    PreferenceSummaryHelperActivity.updateSummary(preferenceScreen);
}
Also used : PreferenceScreen(android.preference.PreferenceScreen)

Aggregations

PreferenceScreen (android.preference.PreferenceScreen)83 Preference (android.preference.Preference)36 ListPreference (android.preference.ListPreference)21 PreferenceCategory (android.preference.PreferenceCategory)17 CheckBoxPreference (android.preference.CheckBoxPreference)16 EditTextPreference (android.preference.EditTextPreference)14 Bundle (android.os.Bundle)13 Method (java.lang.reflect.Method)11 SharedPreferences (android.content.SharedPreferences)9 Intent (android.content.Intent)6 Dialog (android.app.Dialog)5 ArrayList (java.util.ArrayList)5 DialogInterface (android.content.DialogInterface)4 Activity (android.app.Activity)3 Context (android.content.Context)3 MultiSelectListPreference (android.preference.MultiSelectListPreference)3 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)3 PreferenceManager (android.preference.PreferenceManager)3 TwoStatePreference (android.preference.TwoStatePreference)3 View (android.view.View)3