use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class HighlightablePreferenceGroupAdapter method adjustInitialExpandedChildCount.
/**
* Tries to override initial expanded child count.
* <p/>
* Initial expanded child count will be ignored if:
* 1. fragment contains request to highlight a particular row.
* 2. count value is invalid.
*/
public static void adjustInitialExpandedChildCount(SettingsPreferenceFragment host) {
if (host == null) {
return;
}
final PreferenceScreen screen = host.getPreferenceScreen();
if (screen == null) {
return;
}
final Bundle arguments = host.getArguments();
if (arguments != null) {
final String highlightKey = arguments.getString(EXTRA_FRAGMENT_ARG_KEY);
if (!TextUtils.isEmpty(highlightKey)) {
// Has highlight row - expand everything
screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
return;
}
}
final int initialCount = host.getInitialExpandedChildCount();
if (initialCount <= 0) {
return;
}
screen.setInitialExpandedChildrenCount(initialCount);
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class RadioButtonPickerFragment method updateCandidates.
public void updateCandidates() {
mCandidates.clear();
final List<? extends CandidateInfo> candidateList = getCandidates();
if (candidateList != null) {
for (CandidateInfo info : candidateList) {
mCandidates.put(info.getKey(), info);
}
}
final String defaultKey = getDefaultKey();
final String systemDefaultKey = getSystemDefaultKey();
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
if (mIllustrationId != 0) {
addIllustration(screen);
}
if (!mAppendStaticPreferences) {
addStaticPreferences(screen);
}
final int customLayoutResId = getRadioButtonPreferenceCustomLayoutResId();
if (shouldShowItemNone()) {
final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
if (customLayoutResId > 0) {
nonePref.setLayoutResource(customLayoutResId);
}
nonePref.setIcon(R.drawable.ic_remove_circle);
nonePref.setTitle(R.string.app_list_preference_none);
nonePref.setChecked(TextUtils.isEmpty(defaultKey));
nonePref.setOnClickListener(this);
screen.addPreference(nonePref);
}
if (candidateList != null) {
for (CandidateInfo info : candidateList) {
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
if (customLayoutResId > 0) {
pref.setLayoutResource(customLayoutResId);
}
bindPreference(pref, info.getKey(), info, defaultKey);
bindPreferenceExtra(pref, info.getKey(), info, defaultKey, systemDefaultKey);
screen.addPreference(pref);
}
}
mayCheckOnlyRadioButton();
if (mAppendStaticPreferences) {
addStaticPreferences(screen);
}
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class TestingSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.testing_settings);
final UserManager um = UserManager.get(getContext());
if (!um.isAdminUser()) {
PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference("radio_info_settings");
getPreferenceScreen().removePreference(preferenceScreen);
}
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class AccountPreferenceController method updateProfileUi.
private void updateProfileUi(final UserInfo userInfo) {
if (mFragment.getPreferenceManager() == null) {
return;
}
final ProfileData data = mProfiles.get(userInfo.id);
if (data != null) {
data.pendingRemoval = false;
data.userInfo = userInfo;
if (userInfo.isEnabled()) {
// recreate the authentication helper to refresh the list of enabled accounts
data.authenticatorHelper = new AuthenticatorHelper(mContext, userInfo.getUserHandle(), this);
}
return;
}
final Context context = mContext;
final ProfileData profileData = new ProfileData();
profileData.userInfo = userInfo;
AccessiblePreferenceCategory preferenceGroup = mHelper.createAccessiblePreferenceCategory(mFragment.getPreferenceManager().getContext());
preferenceGroup.setOrder(mAccountProfileOrder++);
// default title; may be modified below
preferenceGroup.setTitle(R.string.account_settings);
if (isSingleProfile()) {
final String title = context.getString(R.string.account_for_section_header, BidiFormatter.getInstance().unicodeWrap(userInfo.name));
preferenceGroup.setTitle(title);
preferenceGroup.setContentDescription(title);
} else if (userInfo.isManagedProfile()) {
if (mType == ProfileSelectFragment.ProfileType.ALL) {
preferenceGroup.setTitle(R.string.category_work);
final String workGroupSummary = getWorkGroupSummary(context, userInfo);
preferenceGroup.setSummary(workGroupSummary);
preferenceGroup.setContentDescription(mContext.getString(R.string.accessibility_category_work, workGroupSummary));
}
profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference();
mHelper.enforceRestrictionOnPreference(profileData.removeWorkProfilePreference, DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
profileData.managedProfilePreference = newManagedProfileSettings();
} else {
if (mType == ProfileSelectFragment.ProfileType.ALL) {
preferenceGroup.setTitle(R.string.category_personal);
preferenceGroup.setContentDescription(mContext.getString(R.string.accessibility_category_personal));
}
}
final PreferenceScreen screen = mFragment.getPreferenceScreen();
if (screen != null) {
screen.addPreference(preferenceGroup);
}
profileData.preferenceGroup = preferenceGroup;
if (userInfo.isEnabled()) {
profileData.authenticatorHelper = new AuthenticatorHelper(context, userInfo.getUserHandle(), this);
profileData.addAccountPreference = newAddAccountPreference();
mHelper.enforceRestrictionOnPreference(profileData.addAccountPreference, DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
}
mProfiles.put(userInfo.id, profileData);
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class AccountPreferenceController method cleanUpPreferences.
void cleanUpPreferences() {
PreferenceScreen screen = mFragment.getPreferenceScreen();
if (screen == null) {
return;
}
final int count = mProfiles.size();
for (int i = count - 1; i >= 0; i--) {
final ProfileData data = mProfiles.valueAt(i);
if (data.pendingRemoval) {
screen.removePreference(data.preferenceGroup);
mProfiles.removeAt(i);
}
}
}
Aggregations