Search in sources :

Example 71 with PreferenceCategory

use of android.preference.PreferenceCategory in project afwall by ukanth.

the class MultiProfilePreferenceFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.profiles_preferences);
    Preference button = (Preference) findPreference("manage_profiles");
    button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            // code for what you want it to do
            startActivity(new Intent(getActivity(), ProfileActivity.class));
            return true;
        }
    });
    final PreferenceCategory mCategory = (PreferenceCategory) findPreference("promigrate");
    final PreferenceCategory mCategory2 = (PreferenceCategory) findPreference("oldprofile_pref");
    final Preference migrate = (Preference) findPreference("migrate_profile");
    if (!G.isProfileMigrated()) {
        migrate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                Context ctx = getActivity();
                ProfileHelper.migrateProfiles(ctx);
                if (ctx != null) {
                    Api.toast(getActivity(), ctx.getString(R.string.profile_migrate_msg));
                    mCategory.removePreference(migrate);
                    Preference migrate = (Preference) findPreference("profile1");
                    mCategory2.removePreference(migrate);
                    migrate = (Preference) findPreference("profile2");
                    mCategory2.removePreference(migrate);
                    migrate = (Preference) findPreference("profile3");
                    mCategory2.removePreference(migrate);
                }
                return true;
            }
        });
    } else {
        mCategory.removePreference(migrate);
        Preference migrate2 = (Preference) findPreference("profile1");
        mCategory2.removePreference(migrate2);
        migrate2 = (Preference) findPreference("profile2");
        mCategory2.removePreference(migrate2);
        migrate2 = (Preference) findPreference("profile3");
        mCategory2.removePreference(migrate2);
    }
}
Also used : Context(android.content.Context) Preference(android.preference.Preference) PreferenceCategory(android.preference.PreferenceCategory) Intent(android.content.Intent)

Example 72 with PreferenceCategory

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

the class SettingsFragment method setupGaplessControlSettingsV14.

private void setupGaplessControlSettingsV14() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        PreferenceCategory playbackControlSettings = (PreferenceCategory) findPreference(Constants.PREFERENCES_KEY_PLAYBACK_CONTROL_SETTINGS);
        CheckBoxPreference gaplessPlaybackEnabled = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_GAPLESS_PLAYBACK);
        if (gaplessPlaybackEnabled != null) {
            gaplessPlaybackEnabled.setChecked(false);
            gaplessPlaybackEnabled.setEnabled(false);
            if (playbackControlSettings != null) {
                playbackControlSettings.removePreference(gaplessPlaybackEnabled);
            }
        }
    }
}
Also used : PreferenceCategory(android.preference.PreferenceCategory) CheckBoxPreference(android.preference.CheckBoxPreference)

Example 73 with PreferenceCategory

use of android.preference.PreferenceCategory in project android-edittext-validator by vekexasia.

the class SettingsActivity method setupSimplePreferencesScreen.

/**
 * Shows the simplified settings UI if the device configuration if the device configuration dictates that a
 * simplified, single-pane UI should be shown.
 */
@SuppressWarnings("deprecation")
private void setupSimplePreferencesScreen() {
    if (!SettingsActivity.isSimplePreferences(this)) {
        return;
    }
    // Class<ContactPreferenceFragment> a = ContactPreferenceFragment.class;
    // In the simplified UI, fragments are not used at all and we instead
    // use the older PreferenceActivity APIs.
    // Add 'general' preferences.
    PreferenceCategory fakeHeader = new PreferenceCategory(this);
    addPreferencesFromResource(R.xml.pref_contact);
    SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_FULL_NAME));
    SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_ADDRESS));
    SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_PHONE_NUMBER));
    SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_EMAIL));
}
Also used : PreferenceCategory(android.preference.PreferenceCategory)

Example 74 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)

Example 75 with PreferenceCategory

use of android.preference.PreferenceCategory in project KeepScore by nolanlawson.

the class SettingsActivity method getPreferenceCategoryPosition.

@SuppressWarnings("deprecation")
private int getPreferenceCategoryPosition(int titleId) {
    PreferenceScreen screen = getPreferenceScreen();
    String titleToFind = getString(titleId);
    for (int i = 0; i < screen.getPreferenceCount(); i++) {
        Preference preference = screen.getPreference(i);
        if (!(preference instanceof PreferenceCategory)) {
            continue;
        }
        if (titleToFind.equals(((PreferenceCategory) preference).getTitle())) {
            return i;
        }
    }
    return -1;
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) PreferenceCategory(android.preference.PreferenceCategory)

Aggregations

PreferenceCategory (android.preference.PreferenceCategory)80 Preference (android.preference.Preference)49 PreferenceScreen (android.preference.PreferenceScreen)31 ListPreference (android.preference.ListPreference)30 CheckBoxPreference (android.preference.CheckBoxPreference)26 Intent (android.content.Intent)19 EditTextPreference (android.preference.EditTextPreference)8 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)8 SwitchPreference (android.preference.SwitchPreference)8 ArrayList (java.util.ArrayList)7 Uri (android.net.Uri)6 Bundle (android.os.Bundle)5 SharedPreferences (android.content.SharedPreferences)4 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)4 View (android.view.View)4 OsmandApplication (net.osmand.plus.OsmandApplication)4 Context (android.content.Context)3 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)3 RingtonePreference (android.preference.RingtonePreference)3 ListView (android.widget.ListView)3