Search in sources :

Example 6 with PreferenceCategory

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();
}
Also used : RestrictedPreference(com.android.settingslib.RestrictedPreference) PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceCategory(androidx.preference.PreferenceCategory) PreferenceGroup(androidx.preference.PreferenceGroup) Test(org.junit.Test)

Example 7 with PreferenceCategory

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;
            }
        }
    }
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory)

Example 8 with PreferenceCategory

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));
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory)

Example 9 with PreferenceCategory

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) {
    }
}
Also used : Context(android.content.Context) PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceCategory(androidx.preference.PreferenceCategory) ArrayList(java.util.ArrayList) DcDimmingManager(android.hardware.display.DcDimmingManager) ContentResolver(android.content.ContentResolver)

Example 10 with PreferenceCategory

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);
    }
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) FooterPreference(com.android.settingslib.widget.FooterPreference)

Aggregations

PreferenceCategory (androidx.preference.PreferenceCategory)111 Preference (androidx.preference.Preference)38 PreferenceManager (androidx.preference.PreferenceManager)24 Before (org.junit.Before)24 PreferenceScreen (androidx.preference.PreferenceScreen)22 Test (org.junit.Test)19 SwitchPreference (androidx.preference.SwitchPreference)13 NotificationChannel (android.app.NotificationChannel)11 ArrayList (java.util.ArrayList)11 NotificationChannelGroup (android.app.NotificationChannelGroup)9 ShortcutInfo (android.content.pm.ShortcutInfo)9 Context (android.content.Context)8 ConversationChannel (android.app.people.ConversationChannel)7 View (android.view.View)7 PreferenceViewHolder (androidx.preference.PreferenceViewHolder)7 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)7 ListPreference (androidx.preference.ListPreference)6 ComponentName (android.content.ComponentName)5 ContentResolver (android.content.ContentResolver)5 Bundle (android.os.Bundle)5