Search in sources :

Example 76 with PreferenceScreen

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

the class ButtonBrightness method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.button_brightness);
    PreferenceScreen prefSet = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    mManualButtonBrightness = (CustomSeekBarPreference) findPreference(KEY_BUTTON_MANUAL_BRIGHTNESS_NEW);
    final int customButtonBrightness = getResources().getInteger(com.android.internal.R.integer.config_button_brightness_default);
    final int currentBrightness = Settings.System.getInt(resolver, Settings.System.CUSTOM_BUTTON_BRIGHTNESS, customButtonBrightness);
    PowerManager pm = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE);
    mManualButtonBrightness.setMax(pm.getMaximumScreenBrightnessSetting());
    mManualButtonBrightness.setValue(currentBrightness);
    mManualButtonBrightness.setOnPreferenceChangeListener(this);
    mButtonTimoutBar = (CustomSeekBarPreference) findPreference(KEY_BUTTON_TIMEOUT);
    int currentTimeout = Settings.System.getInt(resolver, Settings.System.BUTTON_BACKLIGHT_TIMEOUT, 0);
    mButtonTimoutBar.setValue(currentTimeout);
    mButtonTimoutBar.setOnPreferenceChangeListener(this);
}
Also used : PowerManager(android.os.PowerManager) PreferenceScreen(androidx.preference.PreferenceScreen) ContentResolver(android.content.ContentResolver)

Example 77 with PreferenceScreen

use of androidx.preference.PreferenceScreen 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 78 with PreferenceScreen

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

the class PartSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.rr_parts);
    Context mContext = getActivity().getApplicationContext();
    final PreferenceScreen prefScreen = getPreferenceScreen();
    final Resources res = getResources();
    mSmartPixels = (Preference) findPreference(SMART_PIXELS);
    boolean mSmartPixelsSupported = res.getBoolean(com.android.internal.R.bool.config_supportSmartPixels);
    if (!mSmartPixelsSupported)
        removePreference("smart_pixels");
    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) Resources(android.content.res.Resources)

Example 79 with PreferenceScreen

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

the class HeadsUp method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.rr_headsup);
    PreferenceScreen prefSet = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    Resources systemUiResources;
    try {
        systemUiResources = getPackageManager().getResourcesForApplication("com.android.systemui");
    } catch (Exception e) {
        return;
    }
    int defaultTimeOut = systemUiResources.getInteger(systemUiResources.getIdentifier("com.android.systemui:integer/heads_up_notification_decay", null, null));
    mHeadsUpTimeOut = (ListPreference) findPreference(PREF_HEADS_UP_TIME_OUT);
    mHeadsUpTimeOut.setOnPreferenceChangeListener(this);
    int headsUpTimeOut = Settings.System.getInt(getContentResolver(), Settings.System.HEADS_UP_TIMEOUT, defaultTimeOut);
    mHeadsUpTimeOut.setValue(String.valueOf(headsUpTimeOut));
    updateHeadsUpTimeOutSummary(headsUpTimeOut);
    int defaultSnooze = systemUiResources.getInteger(systemUiResources.getIdentifier("com.android.systemui:integer/heads_up_default_snooze_length_ms", null, null));
    mHeadsUpSnoozeTime = (ListPreference) findPreference(PREF_HEADS_UP_SNOOZE_TIME);
    mHeadsUpSnoozeTime.setOnPreferenceChangeListener(this);
    int headsUpSnooze = Settings.System.getInt(getContentResolver(), Settings.System.HEADS_UP_NOTIFICATION_SNOOZE, defaultSnooze);
    mHeadsUpSnoozeTime.setValue(String.valueOf(headsUpSnooze));
    updateHeadsUpSnoozeTimeSummary(headsUpSnooze);
    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 : PreferenceScreen(androidx.preference.PreferenceScreen) Resources(android.content.res.Resources) RemoteException(android.os.RemoteException) ContentResolver(android.content.ContentResolver)

Example 80 with PreferenceScreen

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

the class AccountTypePreferenceLoader method addPreferencesForType.

/**
 * Gets the preferences.xml file associated with a particular account type.
 * @param accountType the type of account
 * @return a PreferenceScreen inflated from accountPreferenceId.
 */
public PreferenceScreen addPreferencesForType(final String accountType, PreferenceScreen parent) {
    PreferenceScreen prefs = null;
    if (mAuthenticatorHelper.containsAccountType(accountType)) {
        AuthenticatorDescription desc = null;
        try {
            desc = mAuthenticatorHelper.getAccountTypeDescription(accountType);
            if (desc != null && desc.accountPreferencesId != 0) {
                // Load the context of the target package, then apply the
                // base Settings theme (no references to local resources)
                // and create a context theme wrapper so that we get the
                // correct text colors. Control colors will still be wrong,
                // but there's not much we can do about it since we can't
                // reference local color resources.
                final Context targetCtx = mFragment.getActivity().createPackageContextAsUser(desc.packageName, 0, mUserHandle);
                final Theme baseTheme = mFragment.getResources().newTheme();
                baseTheme.applyStyle(R.style.Theme_SettingsBase, true);
                final Context themedCtx = new LocalClassLoaderContextThemeWrapper(getClass(), targetCtx, 0);
                themedCtx.getTheme().setTo(baseTheme);
                prefs = mFragment.getPreferenceManager().inflateFromResource(themedCtx, desc.accountPreferencesId, parent);
            }
        } catch (PackageManager.NameNotFoundException e) {
            Log.w(TAG, "Couldn't load preferences.xml file from " + desc.packageName);
        } catch (Resources.NotFoundException e) {
            Log.w(TAG, "Couldn't load preferences.xml file from " + desc.packageName);
        }
    }
    return prefs;
}
Also used : Context(android.content.Context) AuthenticatorDescription(android.accounts.AuthenticatorDescription) PreferenceScreen(androidx.preference.PreferenceScreen) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) PackageManager(android.content.pm.PackageManager) Theme(android.content.res.Resources.Theme) LocalClassLoaderContextThemeWrapper(com.android.settings.utils.LocalClassLoaderContextThemeWrapper) Resources(android.content.res.Resources)

Aggregations

PreferenceScreen (androidx.preference.PreferenceScreen)244 Preference (androidx.preference.Preference)81 Test (org.junit.Test)60 Context (android.content.Context)36 PreferenceManager (androidx.preference.PreferenceManager)36 ContentResolver (android.content.ContentResolver)25 PreferenceCategory (androidx.preference.PreferenceCategory)24 Bundle (android.os.Bundle)20 ArrayList (java.util.ArrayList)20 SwitchPreference (androidx.preference.SwitchPreference)19 Resources (android.content.res.Resources)18 Before (org.junit.Before)17 ListPreference (androidx.preference.ListPreference)14 PackageManager (android.content.pm.PackageManager)13 PreferenceGroup (androidx.preference.PreferenceGroup)13 ApplicationInfo (android.content.pm.ApplicationInfo)9 VisibleForTesting (androidx.annotation.VisibleForTesting)9 List (java.util.List)9 UserManager (android.os.UserManager)8 StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)8