Search in sources :

Example 71 with PreferenceScreen

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

the class ToggleFeaturePreferenceFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final int resId = getPreferenceScreenResId();
    if (resId <= 0) {
        PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(getActivity());
        setPreferenceScreen(preferenceScreen);
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen)

Example 72 with PreferenceScreen

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

the class DataUsageSummary method inflatePreferences.

private Preference inflatePreferences(int resId) {
    PreferenceScreen rootPreferences = getPreferenceManager().inflateFromResource(getPrefContext(), resId, null);
    Preference pref = rootPreferences.getPreference(0);
    rootPreferences.removeAll();
    PreferenceScreen screen = getPreferenceScreen();
    pref.setOrder(screen.getPreferenceCount());
    screen.addPreference(pref);
    return pref;
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference)

Example 73 with PreferenceScreen

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

the class NetworkScorerPicker method updateCheckedState.

private void updateCheckedState(String selectedKey) {
    final PreferenceScreen screen = getPreferenceScreen();
    final int count = screen.getPreferenceCount();
    for (int i = 0; i < count; i++) {
        final Preference pref = screen.getPreference(i);
        if (pref instanceof RadioButtonPreference) {
            final RadioButtonPreference radioPref = (RadioButtonPreference) pref;
            radioPref.setChecked(TextUtils.equals(pref.getKey(), selectedKey));
        }
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Preference(androidx.preference.Preference) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference)

Example 74 with PreferenceScreen

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

the class NetworkScorerPicker method updateCandidates.

@VisibleForTesting
public void updateCandidates() {
    final PreferenceScreen screen = getPreferenceScreen();
    screen.removeAll();
    final List<NetworkScorerAppData> scorers = mNetworkScoreManager.getAllValidScorers();
    final String defaultAppKey = getActiveScorerPackage();
    final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
    nonePref.setTitle(R.string.network_scorer_picker_none_preference);
    if (scorers.isEmpty()) {
        nonePref.setChecked(true);
    } else {
        nonePref.setKey(null);
        nonePref.setChecked(TextUtils.isEmpty(defaultAppKey));
        nonePref.setOnClickListener(this);
    }
    screen.addPreference(nonePref);
    final int numScorers = scorers.size();
    for (int i = 0; i < numScorers; i++) {
        final RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
        final NetworkScorerAppData appData = scorers.get(i);
        final String appKey = appData.getRecommendationServicePackageName();
        pref.setTitle(appData.getRecommendationServiceLabel());
        pref.setKey(appKey);
        pref.setChecked(TextUtils.equals(defaultAppKey, appKey));
        pref.setOnClickListener(this);
        screen.addPreference(pref);
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) NetworkScorerAppData(android.net.NetworkScorerAppData) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 75 with PreferenceScreen

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

the class VibrationSettingsPreferenceFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.vibration_settings);
    mContext = getContext();
    mContentResolver = mContext.getContentResolver();
    final PreferenceScreen prefScreen = getPreferenceScreen();
    mHasOnePlusHaptics = getResources().getBoolean(com.android.internal.R.bool.config_hasOnePlusHapticMotor);
    mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
    if (mVibrator != null && !mVibrator.hasVibrator()) {
        mVibrator = null;
    }
    mVibrationSettings = (PreferenceCategory) findPreference(CATEGORY_VIBRATION_SETTINGS);
    mRingerVibrationIntensity = (Preference) findPreference(RING_VIBRATION_INTENSITY);
    mNotifVibrationIntensity = (Preference) findPreference(NOTIFICATION_VIBRATION_INTENSITY);
    mVibrationPattern = (ListPreference) findPreference(RINGTONE_VIBRATION_PATTERN);
    if (mHasOnePlusHaptics) {
        Log.i(TAG, "OnePlus vibrator format supported");
        mRingerVibrationIntensity.setOnPreferenceClickListener(this);
        mNotifVibrationIntensity.setOnPreferenceClickListener(this);
        mRingerVibrationIntensity.setOnPreferenceChangeListener(this);
        mNotifVibrationIntensity.setOnPreferenceChangeListener(this);
        updateIntensityText();
    } else {
        mVibrationSettings.removePreference(mRingerVibrationIntensity);
        removePreference("notification_vibration_intensity");
    }
    mVibrationPattern.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 : PreferenceScreen(androidx.preference.PreferenceScreen)

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