use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UserSettingsTest method updateUserList_cannotSwitchUser_shouldDisableAddUser.
@Test
public void updateUserList_cannotSwitchUser_shouldDisableAddUser() {
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
final RestrictedPreference addUser = spy(new RestrictedPreference(mContext));
final PreferenceGroup userListCategory = spy(new PreferenceCategory(mContext));
mUserCapabilities.mCanAddUser = true;
mUserCapabilities.mDisallowAddUser = false;
mUserCapabilities.mUserSwitcherEnabled = true;
mFragment.mUserListCategory = userListCategory;
mFragment.mAddUser = addUser;
when(mUserManager.canSwitchUsers()).thenReturn(false);
when(mUserManager.canAddMoreUsers()).thenReturn(true);
doReturn(mMockPreferenceManager).when(mFragment).getPreferenceManager();
doReturn(mock(PreferenceScreen.class)).when(mFragment).getPreferenceScreen();
doReturn(mMockPreferenceManager).when(userListCategory).getPreferenceManager();
mFragment.updateUserList();
assertThat(addUser.isEnabled()).isFalse();
}
use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AccessibilitySettings method updateCategoryOrderFromArray.
/**
* Update the order of perferences in the category by matching their preference
* key with the string array of preference order which is defined in the xml.
*
* @param categoryKey The key of the category need to update the order
* @param key The key of the string array which defines the order of category
*/
private void updateCategoryOrderFromArray(String categoryKey, int key) {
String[] services = getResources().getStringArray(key);
PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
int preferenceCount = category.getPreferenceCount();
int serviceLength = services.length;
for (int preferenceIndex = 0; preferenceIndex < preferenceCount; preferenceIndex++) {
for (int serviceIndex = 0; serviceIndex < serviceLength; serviceIndex++) {
if (category.getPreference(preferenceIndex).getKey().equals(services[serviceIndex])) {
category.getPreference(preferenceIndex).setOrder(serviceIndex);
break;
}
}
}
}
use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AccessibilitySettings method updateSystemPreferences.
protected void updateSystemPreferences() {
// supports HWC hardware-accelerated color transform.
if (ColorDisplayManager.isColorTransformAccelerated(getContext())) {
PreferenceCategory experimentalCategory = mCategoryToPrefCategoryMap.get(CATEGORY_EXPERIMENTAL);
PreferenceCategory displayCategory = mCategoryToPrefCategoryMap.get(CATEGORY_DISPLAY);
experimentalCategory.removePreference(mToggleInversionPreference);
experimentalCategory.removePreference(mDisplayDaltonizerPreferenceScreen);
mDisplayDaltonizerPreferenceScreen.setOrder(mDisplayMagnificationPreferenceScreen.getOrder() + 1);
mToggleInversionPreference.setOrder(mDisplayDaltonizerPreferenceScreen.getOrder() + 1);
mToggleLargePointerIconPreference.setOrder(mToggleInversionPreference.getOrder() + 1);
mToggleDisableAnimationsPreference.setOrder(mToggleLargePointerIconPreference.getOrder() + 1);
mToggleInversionPreference.setSummary(R.string.summary_empty);
displayCategory.addPreference(mToggleInversionPreference);
displayCategory.addPreference(mDisplayDaltonizerPreferenceScreen);
}
// Text contrast.
mToggleHighTextContrastPreference.setChecked(Settings.Secure.getInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, 0) == 1);
// If the quick setting is enabled, the preference MUST be enabled.
mInversionPreferenceController.updateState(mToggleInversionPreference);
// Dark Mode
mDarkUIPreferenceController.updateState(mDarkUIModePreference);
// Power button ends calls.
if (KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER) && Utils.isVoiceCapable(getActivity())) {
final int incallPowerBehavior = Settings.Secure.getInt(getContentResolver(), Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT);
final boolean powerButtonEndsCall = (incallPowerBehavior == Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP);
mTogglePowerButtonEndsCallPreference.setChecked(powerButtonEndsCall);
}
// Auto-rotate screen
updateLockScreenRotationCheckbox();
// Large pointer icon.
mToggleLargePointerIconPreference.setChecked(Settings.Secure.getInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, 0) != 0);
updateDisableAnimationsToggle();
// Master mono
updateMasterMono();
// Long press timeout.
final int longPressTimeout = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LONG_PRESS_TIMEOUT, mLongPressTimeoutDefault);
String value = String.valueOf(longPressTimeout);
mSelectLongPressTimeoutPreference.setValue(value);
mSelectLongPressTimeoutPreference.setSummary(mLongPressTimeoutValueToTitleMap.get(value));
updateVibrationSummary(mVibrationPreferenceScreen);
mHearingAidPreferenceController.updateState(mHearingAidPreference);
mRTTSettingPreferenceController.updateState(mRTTPreference);
mLiveCaptionPreferenceController.updateState(mLiveCaptionPreference);
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, mCaptioningPreferenceScreen);
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, mDisplayDaltonizerPreferenceScreen);
updateMagnificationSummary(mDisplayMagnificationPreferenceScreen);
updateFontSizeSummary(mFontSizePreferenceScreen);
updateAutoclickSummary(mAutoclickPreferenceScreen);
updateAccessibilityShortcut(mAccessibilityShortcutPreferenceScreen);
updateAccessibilityTimeoutSummary(getContentResolver(), findPreference(ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE));
}
use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MiscInterfaceSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.rr_interface_other_settings);
Context mContext = getActivity().getApplicationContext();
PreferenceScreen prefSet = getPreferenceScreen();
ContentResolver resolver = getActivity().getContentResolver();
mAod = (SystemSettingSwitchPreference) findPreference(KEY_DOZE_ON_CHARGE);
mDisplay = (PreferenceCategory) findPreference(KEY_DISPLAY_CAT);
mPixel = (SystemSettingSwitchPreference) findPreference(PIXEL);
mWakeProx = (LineageSystemSettingSwitchPreference) findPreference(KEY_PROX_WAKE);
mHighTouch = (LineageSystemSettingSwitchPreference) findPreference(KEY_HIGH_TOUCH);
DcDimmingManager dm = (DcDimmingManager) mContext.getSystemService(Context.DC_DIM_SERVICE);
if (dm == null || !dm.isAvailable()) {
mDisplay.setVisible(false);
}
boolean dozeAlwaysOnDisplayAvailable = getContext().getResources().getBoolean(com.android.internal.R.bool.config_dozeAlwaysOnDisplayAvailable);
if (!dozeAlwaysOnDisplayAvailable && mAod != null) {
getPreferenceScreen().removePreference(mAod);
}
if (SystemNavigationPreferenceController.isEdgeToEdgeEnabled(getContext())) {
mPixel.setEnabled(false);
mPixel.setSummary(R.string.navbar_not_active_pulse);
} else {
mPixel.setEnabled(true);
}
mScreenshotChordKeyTimeout = getContext().getResources().getInteger(com.android.internal.R.integer.config_screenshotChordKeyTimeout);
mScreenshotDelay = (CustomSeekBarPreference) findPreference(KEY_SCREENSHOT_DELAY);
mScreenshotDelay.setDefaultValue(mScreenshotChordKeyTimeout);
boolean hasAlertSlider = getContext().getResources().getBoolean(com.android.internal.R.bool.config_hasAlertSlider);
if (!hasAlertSlider) {
removePreference("alert_slider_notifications");
}
final PreferenceCategory aspectRatioCategory = (PreferenceCategory) getPreferenceScreen().findPreference(KEY_ASPECT_RATIO_CATEGORY);
final boolean supportMaxAspectRatio = getResources().getBoolean(com.android.internal.R.bool.config_haveHigherAspectRatioScreen);
if (!supportMaxAspectRatio) {
getPreferenceScreen().removePreference(aspectRatioCategory);
} else {
mAspectRatioAppsSelect = (AppMultiSelectListPreference) findPreference(KEY_ASPECT_RATIO_APPS_LIST);
mAspectRatioApps = (ScrollAppsViewPreference) findPreference(KEY_ASPECT_RATIO_APPS_LIST_SCROLLER);
final String valuesString = Settings.System.getString(resolver, Settings.System.OMNI_ASPECT_RATIO_APPS_LIST);
List<String> valuesList = new ArrayList<String>();
if (!TextUtils.isEmpty(valuesString)) {
valuesList.addAll(Arrays.asList(valuesString.split(":")));
mAspectRatioApps.setVisible(true);
mAspectRatioApps.setValues(valuesList);
} else {
mAspectRatioApps.setVisible(false);
}
mAspectRatioAppsSelect.setValues(valuesList);
mAspectRatioAppsSelect.setOnPreferenceChangeListener(this);
}
int anim = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.RR_CONFIG_ANIM, 0);
try {
if (anim == 0) {
removePreference("animation");
} else if (anim == 1) {
removePreference("preview");
} else if (anim == 2) {
removePreference("animation");
removePreference("preview");
}
} catch (Exception e) {
}
}
use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class LocationFooterPreferenceController method updateState.
/**
* Insert footer preferences. Send a {@link LocationManager#SETTINGS_FOOTER_DISPLAYED_ACTION}
* broadcast to receivers who have injected a footer
*/
@Override
public void updateState(Preference preference) {
PreferenceCategory category = (PreferenceCategory) preference;
category.removeAll();
mFooterInjectors.clear();
Collection<FooterData> footerData = getFooterData();
for (FooterData data : footerData) {
// Generate a footer preference with the given text
FooterPreference footerPreference = new FooterPreference(preference.getContext());
String footerString;
try {
footerString = mPackageManager.getResourcesForApplication(data.applicationInfo).getString(data.footerStringRes);
} catch (NameNotFoundException exception) {
Log.w(TAG, "Resources not found for application " + data.applicationInfo.packageName);
continue;
}
footerPreference.setTitle(footerString);
// Inject the footer
category.addPreference(footerPreference);
// Send broadcast to the injector announcing a footer has been injected
sendBroadcastFooterDisplayed(data.componentName);
mFooterInjectors.add(data.componentName);
}
}
Aggregations