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);
}
}
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;
}
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));
}
}
}
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);
}
}
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) {
}
}
Aggregations