Search in sources :

Example 11 with PreferenceCategory

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

the class NotificationsSettingsFragment method addSitesForViewAllSitesScreen.

private void addSitesForViewAllSitesScreen(PreferenceScreen preferenceScreen) {
    Context context = getActivity();
    if (context == null)
        return;
    PreferenceCategory rootCategory = new PreferenceCategory(context);
    rootCategory.setTitle(R.string.your_sites);
    preferenceScreen.addPreference(rootCategory);
    configureBlogsSettings(rootCategory, true);
}
Also used : Context(android.content.Context) PreferenceCategory(android.preference.PreferenceCategory)

Example 12 with PreferenceCategory

use of android.preference.PreferenceCategory 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 13 with PreferenceCategory

use of android.preference.PreferenceCategory in project pictureapp by EyeSeeTea.

the class SettingsActivityStrategy method setupPreferencesScreen.

@Override
public void setupPreferencesScreen(PreferenceScreen preferenceScreen) {
    PreferenceCategory preferenceCategory = (PreferenceCategory) preferenceScreen.findPreference(settingsActivity.getResources().getString(R.string.pref_cat_server));
    preferenceCategory.removePreference(preferenceScreen.findPreference(settingsActivity.getResources().getString(R.string.org_unit)));
}
Also used : PreferenceCategory(android.preference.PreferenceCategory)

Example 14 with PreferenceCategory

use of android.preference.PreferenceCategory in project android by cSploit.

the class MsfPreferences method createPreferenceHierarchy.

private PreferenceScreen createPreferenceHierarchy() {
    // Root
    PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
    String title = null;
    PreferenceCategory cat_required = new PreferenceCategory(this);
    PreferenceCategory cat_general = new PreferenceCategory(this);
    PreferenceCategory cat_advanced = new PreferenceCategory(this);
    PreferenceCategory cat_evasion = new PreferenceCategory(this);
    ArrayList<Preference> required = new ArrayList<Preference>();
    ArrayList<Preference> general = new ArrayList<Preference>();
    ArrayList<Preference> advanced = new ArrayList<Preference>();
    ArrayList<Preference> evasion = new ArrayList<Preference>();
    Payload payload = System.getCurrentPayload();
    MsfExploit exploit = (MsfExploit) System.getCurrentExploit();
    System.setCurrentPayload(null);
    System.setCurrentExploit(null);
    if (payload != null) {
        options = payload.getOptions();
        title = payload.toString();
    } else if (exploit != null) {
        options = exploit.getOptions();
        title = exploit.toString();
    }
    if (options == null) {
        options = new ArrayList<Option>();
        title = getString(R.string.error);
        String error_message;
        if (exploit != null)
            error_message = String.format("cannot retrieve options for '%s'", exploit.getName());
        else if (payload != null)
            error_message = String.format("cannot retrieve options for '%s'", payload.getName());
        else
            error_message = "called without Payload or MsfExploit";
        Logger.error(error_message);
    }
    setTitle(title + " > " + getString(R.string.menu_settings));
    cat_required.setTitle(R.string.required);
    cat_general.setTitle(R.string.pref_general);
    cat_advanced.setTitle(R.string.pref_advanced);
    cat_evasion.setTitle(R.string.evasion);
    for (Option opt : options) {
        Preference item = null;
        int inputType = 0;
        switch(opt.getType()) {
            case ADDRESS:
            case STRING:
            case PATH:
            case INTEGER:
            case PORT:
                item = new EditTextPreference(this);
                item.setTitle(opt.getName());
                ((EditTextPreference) item).setDialogTitle(opt.getName());
                ((EditTextPreference) item).setDialogMessage(opt.getDescription());
                item.setSummary(opt.getDescription());
                item.setKey(opt.getName());
                item.setDefaultValue(opt.getValue());
                break;
            case BOOLEAN:
                item = new CheckBoxPreference(this);
                item.setTitle(opt.getName());
                item.setKey(opt.getName());
                item.setSummary(opt.getDescription());
                ((CheckBoxPreference) item).setChecked(opt.getValue().equals("true"));
                break;
            case ENUM:
                item = new ListPreference(this);
                ((ListPreference) item).setEntries(opt.getEnum());
                ((ListPreference) item).setEntryValues(opt.getEnum());
                ((ListPreference) item).setDialogTitle(opt.getName());
                ((ListPreference) item).setValue(opt.getValue());
                item.setKey(opt.getName());
                item.setTitle(opt.getName());
                item.setSummary(opt.getDescription());
                break;
        }
        switch(opt.getType()) {
            case ADDRESS:
                inputType = InputType.TYPE_CLASS_PHONE;
                break;
            case PATH:
            case STRING:
                inputType = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
                break;
            case PORT:
            case INTEGER:
                inputType = InputType.TYPE_CLASS_NUMBER;
                break;
        }
        if (inputType != 0)
            ((EditTextPreference) item).getEditText().setInputType(inputType);
        if (opt.isAdvanced())
            advanced.add(item);
        else if (opt.isRequired())
            required.add(item);
        else if (opt.isEvasion())
            evasion.add(item);
        else
            general.add(item);
        if (item != null) {
            item.setOnPreferenceChangeListener(listener);
        }
    }
    if (required.size() > 0) {
        root.addPreference(cat_required);
        for (Preference i : required) cat_required.addPreference(i);
    }
    if (general.size() > 0) {
        root.addPreference(cat_general);
        for (Preference i : general) cat_general.addPreference(i);
    }
    if (advanced.size() > 0) {
        root.addPreference(cat_advanced);
        for (Preference i : advanced) cat_advanced.addPreference(i);
    }
    if (evasion.size() > 0) {
        root.addPreference(cat_evasion);
        for (Preference i : evasion) cat_evasion.addPreference(i);
    }
    return root;
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) CheckBoxPreference(android.preference.CheckBoxPreference) ArrayList(java.util.ArrayList) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) PreferenceCategory(android.preference.PreferenceCategory) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) MsfExploit(org.csploit.android.net.metasploit.MsfExploit) Payload(org.csploit.android.net.metasploit.Payload) Option(org.csploit.android.net.metasploit.Option)

Example 15 with PreferenceCategory

use of android.preference.PreferenceCategory in project Android-Terminal-Emulator by jackpal.

the class TermPreferences method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);
    // Remove the action bar pref on older platforms without an action bar
    if (AndroidCompat.SDK < 11) {
        Preference actionBarPref = findPreference(ACTIONBAR_KEY);
        PreferenceCategory screenCategory = (PreferenceCategory) findPreference(CATEGORY_SCREEN_KEY);
        if ((actionBarPref != null) && (screenCategory != null)) {
            screenCategory.removePreference(actionBarPref);
        }
    }
    // Display up indicator on action bar home button
    if (AndroidCompat.V11ToV20) {
        ActionBarCompat bar = ActivityCompat.getActionBar(this);
        if (bar != null) {
            bar.setDisplayOptions(ActionBarCompat.DISPLAY_HOME_AS_UP, ActionBarCompat.DISPLAY_HOME_AS_UP);
        }
    }
}
Also used : ActionBarCompat(jackpal.androidterm.compat.ActionBarCompat) Preference(android.preference.Preference) PreferenceCategory(android.preference.PreferenceCategory)

Aggregations

PreferenceCategory (android.preference.PreferenceCategory)34 Preference (android.preference.Preference)22 PreferenceScreen (android.preference.PreferenceScreen)17 CheckBoxPreference (android.preference.CheckBoxPreference)12 ListPreference (android.preference.ListPreference)11 Intent (android.content.Intent)7 EditTextPreference (android.preference.EditTextPreference)6 Bundle (android.os.Bundle)4 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)4 ArrayList (java.util.ArrayList)4 SharedPreferences (android.content.SharedPreferences)3 Uri (android.net.Uri)3 Activity (android.app.Activity)2 AlertDialog (android.app.AlertDialog)2 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 PackageInfo (android.content.pm.PackageInfo)2 PackageManager (android.content.pm.PackageManager)2 SpannableString (android.text.SpannableString)2 View (android.view.View)2