Search in sources :

Example 1 with MultiSelectListPreference

use of androidx.preference.MultiSelectListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ApnEditorTest method setMockPreference.

private void setMockPreference(Context context) {
    mApnEditorUT.mName = new EditTextPreference(context);
    mApnEditorUT.mApn = new EditTextPreference(context);
    mApnEditorUT.mProxy = new EditTextPreference(context);
    mApnEditorUT.mPort = new EditTextPreference(context);
    mApnEditorUT.mUser = new EditTextPreference(context);
    mApnEditorUT.mServer = new EditTextPreference(context);
    mApnEditorUT.mPassword = new EditTextPreference(context);
    mApnEditorUT.mMmsc = new EditTextPreference(context);
    mApnEditorUT.mMcc = new EditTextPreference(context);
    mApnEditorUT.mMnc = new EditTextPreference(context);
    mApnEditorUT.mMmsProxy = new EditTextPreference(context);
    mApnEditorUT.mMmsPort = new EditTextPreference(context);
    mApnEditorUT.mAuthType = new ListPreference(context);
    mApnEditorUT.mApnType = new EditTextPreference(context);
    mApnEditorUT.mProtocol = new ListPreference(context);
    mApnEditorUT.mRoamingProtocol = new ListPreference(context);
    mApnEditorUT.mCarrierEnabled = new SwitchPreference(context);
    mApnEditorUT.mBearerMulti = new MultiSelectListPreference(context);
    mApnEditorUT.mMvnoType = new ListPreference(context);
    mApnEditorUT.mMvnoMatchData = new EditTextPreference(context);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) EditTextPreference(androidx.preference.EditTextPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) ListPreference(androidx.preference.ListPreference)

Example 2 with MultiSelectListPreference

use of androidx.preference.MultiSelectListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AppRestrictionsFragment method onRestrictionsReceived.

private void onRestrictionsReceived(AppRestrictionsPreference preference, ArrayList<RestrictionEntry> restrictions) {
    // Remove any earlier restrictions
    removeRestrictionsForApp(preference);
    // Non-custom-activity case - expand the restrictions in-place
    int count = 1;
    for (RestrictionEntry entry : restrictions) {
        Preference p = null;
        switch(entry.getType()) {
            case RestrictionEntry.TYPE_BOOLEAN:
                p = new SwitchPreference(getPrefContext());
                p.setTitle(entry.getTitle());
                p.setSummary(entry.getDescription());
                ((SwitchPreference) p).setChecked(entry.getSelectedState());
                break;
            case RestrictionEntry.TYPE_CHOICE:
            case RestrictionEntry.TYPE_CHOICE_LEVEL:
                p = new ListPreference(getPrefContext());
                p.setTitle(entry.getTitle());
                String value = entry.getSelectedString();
                if (value == null) {
                    value = entry.getDescription();
                }
                p.setSummary(findInArray(entry.getChoiceEntries(), entry.getChoiceValues(), value));
                ((ListPreference) p).setEntryValues(entry.getChoiceValues());
                ((ListPreference) p).setEntries(entry.getChoiceEntries());
                ((ListPreference) p).setValue(value);
                ((ListPreference) p).setDialogTitle(entry.getTitle());
                break;
            case RestrictionEntry.TYPE_MULTI_SELECT:
                p = new MultiSelectListPreference(getPrefContext());
                p.setTitle(entry.getTitle());
                ((MultiSelectListPreference) p).setEntryValues(entry.getChoiceValues());
                ((MultiSelectListPreference) p).setEntries(entry.getChoiceEntries());
                HashSet<String> set = new HashSet<>();
                Collections.addAll(set, entry.getAllSelectedStrings());
                ((MultiSelectListPreference) p).setValues(set);
                ((MultiSelectListPreference) p).setDialogTitle(entry.getTitle());
                break;
            case RestrictionEntry.TYPE_NULL:
            default:
        }
        if (p != null) {
            p.setPersistent(false);
            p.setOrder(preference.getOrder() + count);
            // Store the restrictions key string as a key for the preference
            p.setKey(preference.getKey().substring(PKG_PREFIX.length()) + DELIMITER + entry.getKey());
            mAppList.addPreference(p);
            p.setOnPreferenceChangeListener(AppRestrictionsFragment.this);
            p.setIcon(R.drawable.empty_icon);
            preference.mChildren.add(p);
            count++;
        }
    }
    preference.setRestrictions(restrictions);
    if (// No visible restrictions
    count == 1 && preference.isImmutable() && preference.isChecked()) {
        // Special case of required app with no visible restrictions. Remove it
        mAppList.removePreference(preference);
    }
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Preference(androidx.preference.Preference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) ListPreference(androidx.preference.ListPreference) SwitchPreference(androidx.preference.SwitchPreference) RestrictionEntry(android.content.RestrictionEntry) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) ListPreference(androidx.preference.ListPreference) HashSet(java.util.HashSet)

Aggregations

ListPreference (androidx.preference.ListPreference)2 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)2 SwitchPreference (androidx.preference.SwitchPreference)2 RestrictionEntry (android.content.RestrictionEntry)1 EditTextPreference (androidx.preference.EditTextPreference)1 Preference (androidx.preference.Preference)1 HashSet (java.util.HashSet)1