Search in sources :

Example 1 with FilterTouchesSwitchPreference

use of com.android.settings.widget.FilterTouchesSwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DeviceAdminListPreferenceController method refreshUI.

private void refreshUI() {
    if (mPreferenceGroup == null) {
        return;
    }
    if (mFooterPreferenceMixin != null) {
        final FooterPreference footer = mFooterPreferenceMixin.createFooterPreference();
        footer.setTitle(R.string.no_device_admins);
        footer.setVisible(mAdmins.isEmpty());
    }
    final Map<String, FilterTouchesSwitchPreference> preferenceCache = new ArrayMap<>();
    final Context prefContext = mPreferenceGroup.getContext();
    final int childrenCount = mPreferenceGroup.getPreferenceCount();
    for (int i = 0; i < childrenCount; i++) {
        final Preference pref = mPreferenceGroup.getPreference(i);
        if (!(pref instanceof FilterTouchesSwitchPreference)) {
            continue;
        }
        final FilterTouchesSwitchPreference appSwitch = (FilterTouchesSwitchPreference) pref;
        preferenceCache.put(appSwitch.getKey(), appSwitch);
    }
    for (DeviceAdminListItem item : mAdmins) {
        final String key = item.getKey();
        FilterTouchesSwitchPreference pref = preferenceCache.remove(key);
        if (pref == null) {
            pref = new FilterTouchesSwitchPreference(prefContext);
            mPreferenceGroup.addPreference(pref);
        }
        bindPreference(item, pref);
    }
    for (FilterTouchesSwitchPreference unusedCacheItem : preferenceCache.values()) {
        mPreferenceGroup.removePreference(unusedCacheItem);
    }
}
Also used : Context(android.content.Context) FilterTouchesSwitchPreference(com.android.settings.widget.FilterTouchesSwitchPreference) SwitchPreference(androidx.preference.SwitchPreference) FilterTouchesSwitchPreference(com.android.settings.widget.FilterTouchesSwitchPreference) Preference(androidx.preference.Preference) FooterPreference(com.android.settingslib.widget.FooterPreference) ArrayMap(android.util.ArrayMap) FooterPreference(com.android.settingslib.widget.FooterPreference)

Aggregations

Context (android.content.Context)1 ArrayMap (android.util.ArrayMap)1 Preference (androidx.preference.Preference)1 SwitchPreference (androidx.preference.SwitchPreference)1 FilterTouchesSwitchPreference (com.android.settings.widget.FilterTouchesSwitchPreference)1 FooterPreference (com.android.settingslib.widget.FooterPreference)1