Search in sources :

Example 26 with PreferenceGroup

use of android.preference.PreferenceGroup in project PhoneProfiles by henrichg.

the class PreferenceFragment method getAllPreferenceScreen.

private ArrayList<Preference> getAllPreferenceScreen(Preference p, ArrayList<Preference> list) {
    if (p instanceof PreferenceCategory || p instanceof PreferenceScreen) {
        PreferenceGroup pGroup = (PreferenceGroup) p;
        int pCount = pGroup.getPreferenceCount();
        if (p instanceof PreferenceScreen) {
            list.add(p);
        }
        for (int i = 0; i < pCount; i++) {
            getAllPreferenceScreen(pGroup.getPreference(i), list);
        }
    }
    return list;
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) PreferenceCategory(android.preference.PreferenceCategory) PreferenceGroup(android.preference.PreferenceGroup)

Example 27 with PreferenceGroup

use of android.preference.PreferenceGroup in project android_packages_apps_Snap by LineageOS.

the class SettingsActivity method filterPreferences.

private void filterPreferences() {
    String[] categories = { "photo", "video", "general", "developer" };
    Set<String> set = mSettingsManager.getFilteredKeys();
    if (!mDeveloperMenuEnabled) {
        set.add(SettingsManager.KEY_MONO_PREVIEW);
        set.add(SettingsManager.KEY_MONO_ONLY);
        set.add(SettingsManager.KEY_CLEARSIGHT);
        PreferenceGroup developer = (PreferenceGroup) findPreference("developer");
        // it will cause crash.
        if (developer != null) {
            PreferenceScreen parent = getPreferenceScreen();
            parent.removePreference(developer);
        }
    }
    CharSequence[] entries = mSettingsManager.getEntries(SettingsManager.KEY_SCENE_MODE);
    List<CharSequence> list = Arrays.asList(entries);
    if (mDeveloperMenuEnabled && !list.contains("HDR")) {
        Preference p = findPreference("pref_camera2_hdr_key");
        if (p != null) {
            PreferenceGroup developer = (PreferenceGroup) findPreference("developer");
            developer.removePreference(p);
        }
    }
    for (String key : set) {
        Preference p = findPreference(key);
        if (p == null)
            continue;
        for (int i = 0; i < categories.length; i++) {
            PreferenceGroup group = (PreferenceGroup) findPreference(categories[i]);
            if (group.removePreference(p))
                break;
        }
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference) PreferenceGroup(android.preference.PreferenceGroup)

Example 28 with PreferenceGroup

use of android.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.

the class LanguageSettings method onCreateIMM.

private void onCreateIMM() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mInputMethodProperties = imm.getInputMethodList();
    mLastInputMethodId = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
    PreferenceGroup textCategory = (PreferenceGroup) findPreference("text_category");
    int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size());
    for (int i = 0; i < N; ++i) {
        InputMethodInfo property = mInputMethodProperties.get(i);
        String prefKey = property.getId();
        CharSequence label = property.loadLabel(getPackageManager());
        boolean systemIME = isSystemIme(property);
        // Don't show the toggle if it's the only keyboard in the system, or it's a system IME.
        if (mHaveHardKeyboard || (N > 1 && !systemIME)) {
            CheckBoxPreference chkbxPref = new CheckBoxPreference(this);
            chkbxPref.setKey(prefKey);
            chkbxPref.setTitle(label);
            textCategory.addPreference(chkbxPref);
            mCheckboxes.add(chkbxPref);
        }
        // If setting activity is available, add a setting screen entry.
        if (null != property.getSettingsActivity()) {
            PreferenceScreen prefScreen = new PreferenceScreen(this, null);
            String settingsActivity = property.getSettingsActivity();
            if (settingsActivity.lastIndexOf("/") < 0) {
                settingsActivity = property.getPackageName() + "/" + settingsActivity;
            }
            prefScreen.setKey(settingsActivity);
            prefScreen.setTitle(label);
            if (N == 1) {
                prefScreen.setSummary(getString(R.string.onscreen_keyboard_settings_summary));
            } else {
                CharSequence settingsLabel = getResources().getString(R.string.input_methods_settings_label_format, label);
                prefScreen.setSummary(settingsLabel);
            }
            textCategory.addPreference(prefScreen);
        }
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) CheckBoxPreference(android.preference.CheckBoxPreference) InputMethodManager(android.view.inputmethod.InputMethodManager) PreferenceGroup(android.preference.PreferenceGroup) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 29 with PreferenceGroup

use of android.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.

the class ApnSettings method fillList.

private void fillList() {
    String where = "numeric=\"" + android.os.SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "") + "\"";
    Cursor cursor = managedQuery(Telephony.Carriers.CONTENT_URI, new String[] { "_id", "name", "apn", "type" }, where, Telephony.Carriers.DEFAULT_SORT_ORDER);
    PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list");
    apnList.removeAll();
    ArrayList<Preference> mmsApnList = new ArrayList<Preference>();
    mSelectedKey = getSelectedApnKey();
    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
        String name = cursor.getString(NAME_INDEX);
        String apn = cursor.getString(APN_INDEX);
        String key = cursor.getString(ID_INDEX);
        String type = cursor.getString(TYPES_INDEX);
        ApnPreference pref = new ApnPreference(this);
        pref.setKey(key);
        pref.setTitle(name);
        pref.setSummary(apn);
        pref.setPersistent(false);
        pref.setOnPreferenceChangeListener(this);
        boolean selectable = ((type == null) || !type.equals("mms"));
        pref.setSelectable(selectable);
        if (selectable) {
            if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
                pref.setChecked();
            }
            apnList.addPreference(pref);
        } else {
            mmsApnList.add(pref);
        }
        cursor.moveToNext();
    }
    cursor.close();
    for (Preference preference : mmsApnList) {
        apnList.addPreference(preference);
    }
}
Also used : Preference(android.preference.Preference) ArrayList(java.util.ArrayList) PreferenceGroup(android.preference.PreferenceGroup) Cursor(android.database.Cursor)

Example 30 with PreferenceGroup

use of android.preference.PreferenceGroup in project android_packages_apps_Settings by LineageOS.

the class Settings method onResume.

@Override
protected void onResume() {
    super.onResume();
    findPreference(KEY_CALL_SETTINGS).setEnabled(!AirplaneModeEnabler.isAirplaneModeOn(this));
    Intent intent = new Intent();
    intent.setAction("android.intent.action.MAIN");
    intent.addCategory("android.intent.category.HOME");
    PreferenceGroup parent = (PreferenceGroup) findPreference(KEY_PARENT);
    ActivityInfo a = getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY).activityInfo;
    if (a != null && a.name.equals("com.android.launcher.Launcher") && (a.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
        if (parent.findPreference(KEY_LAUNCHER) == null) {
            parent.addPreference(mLauncherSettings);
        }
    } else {
        if (parent.findPreference(KEY_LAUNCHER) != null) {
            parent.removePreference(mLauncherSettings);
        }
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) Intent(android.content.Intent) PreferenceGroup(android.preference.PreferenceGroup)

Aggregations

PreferenceGroup (android.preference.PreferenceGroup)38 Preference (android.preference.Preference)26 ListPreference (android.preference.ListPreference)7 SharedPreferences (android.content.SharedPreferences)6 CheckBoxPreference (android.preference.CheckBoxPreference)6 PreferenceScreen (android.preference.PreferenceScreen)6 Intent (android.content.Intent)5 Bundle (android.os.Bundle)4 TwoStatePreference (android.preference.TwoStatePreference)4 ArrayList (java.util.ArrayList)4 EditTextPreference (android.preference.EditTextPreference)3 MultiSelectListPreference (android.preference.MultiSelectListPreference)3 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)3 ChromeSwitchPreference (org.chromium.chrome.browser.preferences.ChromeSwitchPreference)3 Point (android.graphics.Point)2 DialogPreference (android.preference.DialogPreference)2 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)2 PreferenceCategory (android.preference.PreferenceCategory)2 SpannableString (android.text.SpannableString)2 View (android.view.View)2