use of androidx.preference.PreferenceCategory in project android_packages_apps_crDroidSettings by crdroidandroid.
the class Notifications method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.crdroid_settings_notifications);
final PreferenceScreen prefScreen = getPreferenceScreen();
final Context mContext = getActivity().getApplicationContext();
final ContentResolver resolver = mContext.getContentResolver();
final Resources res = mContext.getResources();
mAlertSlider = (Preference) prefScreen.findPreference(ALERT_SLIDER_PREF);
boolean mAlertSliderAvailable = res.getBoolean(com.android.internal.R.bool.config_hasAlertSlider);
if (!mAlertSliderAvailable)
prefScreen.removePreference(mAlertSlider);
mBatLights = (Preference) prefScreen.findPreference(BATTERY_LIGHTS_PREF);
boolean mBatLightsSupported = res.getInteger(org.lineageos.platform.internal.R.integer.config_deviceLightCapabilities) >= 64;
if (!mBatLightsSupported)
prefScreen.removePreference(mBatLights);
mNotLights = (Preference) prefScreen.findPreference(NOTIFICATION_LIGHTS_PREF);
boolean mNotLightsSupported = res.getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed);
if (!mNotLightsSupported)
prefScreen.removePreference(mNotLights);
if (!mBatLightsSupported && !mNotLightsSupported) {
final PreferenceCategory lightsCategory = (PreferenceCategory) prefScreen.findPreference(LIGHT_BRIGHTNESS_CATEGORY);
prefScreen.removePreference(lightsCategory);
}
if (!Utils.deviceHasFlashlight(mContext)) {
final PreferenceCategory flashlightCategory = (PreferenceCategory) prefScreen.findPreference(FLASHLIGHT_CATEGORY);
prefScreen.removePreference(flashlightCategory);
} else {
mFlashOnCall = (ListPreference) prefScreen.findPreference(FLASHLIGHT_CALL_PREF);
mFlashOnCall.setOnPreferenceChangeListener(this);
mFlashOnCallIgnoreDND = (SwitchPreference) prefScreen.findPreference(FLASHLIGHT_DND_PREF);
int value = Settings.System.getInt(resolver, Settings.System.FLASHLIGHT_ON_CALL, 0);
mFlashOnCallRate = (CustomSeekBarPreference) prefScreen.findPreference(FLASHLIGHT_RATE_PREF);
mFlashOnCallIgnoreDND.setEnabled(value > 1);
mFlashOnCallRate.setEnabled(value > 0);
}
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_crDroidSettings by crdroidandroid.
the class LockScreen method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.crdroid_settings_lockscreen);
PreferenceCategory interfaceCategory = (PreferenceCategory) findPreference(LOCKSCREEN_INTERFACE_CATEGORY);
PreferenceCategory gestCategory = (PreferenceCategory) findPreference(LOCKSCREEN_GESTURES_CATEGORY);
FingerprintManager mFingerprintManager = (FingerprintManager) getActivity().getSystemService(Context.FINGERPRINT_SERVICE);
mUdfpsSettings = (Preference) findPreference(KEY_UDFPS_SETTINGS);
mFingerprintVib = (Preference) findPreference(KEY_FP_SUCCESS_VIBRATE);
mFingerprintVibErr = (Preference) findPreference(KEY_FP_ERROR_VIBRATE);
mRippleEffect = (Preference) findPreference(KEY_RIPPLE_EFFECT);
if (mFingerprintManager == null || !mFingerprintManager.isHardwareDetected()) {
interfaceCategory.removePreference(mUdfpsSettings);
gestCategory.removePreference(mFingerprintVib);
gestCategory.removePreference(mFingerprintVibErr);
gestCategory.removePreference(mRippleEffect);
} else {
if (!Utils.isPackageInstalled(getContext(), "com.crdroid.udfps.icons")) {
interfaceCategory.removePreference(mUdfpsSettings);
} else {
gestCategory.removePreference(mFingerprintVib);
gestCategory.removePreference(mFingerprintVibErr);
}
}
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_crDroidSettings by crdroidandroid.
the class DozeSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.doze_settings);
Context context = getContext();
PreferenceCategory dozeSensorCategory = (PreferenceCategory) getPreferenceScreen().findPreference(CATEG_DOZE_SENSOR);
mDozeAlwaysOnPreference = (SwitchPreference) findPreference(KEY_DOZE_ALWAYS_ON);
mTiltPreference = (SwitchPreference) findPreference(KEY_DOZE_TILT_GESTURE);
mPickUpPreference = (SwitchPreference) findPreference(KEY_DOZE_PICK_UP_GESTURE);
mHandwavePreference = (SwitchPreference) findPreference(KEY_DOZE_HANDWAVE_GESTURE);
mPocketPreference = (SwitchPreference) findPreference(KEY_DOZE_POCKET_GESTURE);
mRaiseToWakePreference = (SwitchPreference) findPreference(KEY_RAISE_TO_WAKE_GESTURE);
mDozeVibratePreference = (SecureSettingSeekBarPreference) findPreference(KEY_DOZE_GESTURE_VIBRATE);
// Hide sensor related features if the device doesn't support them
if (!Utils.getTiltSensor(context) && !Utils.getPickupSensor(context) && !Utils.getProximitySensor(context)) {
getPreferenceScreen().removePreference(dozeSensorCategory);
} else {
if (!Utils.getTiltSensor(context)) {
dozeSensorCategory.removePreference(mTiltPreference);
} else {
mTiltPreference.setOnPreferenceChangeListener(this);
}
if (!Utils.getPickupSensor(context)) {
dozeSensorCategory.removePreference(mPickUpPreference);
} else {
mPickUpPreference.setOnPreferenceChangeListener(this);
}
if (!Utils.getProximitySensor(context)) {
dozeSensorCategory.removePreference(mHandwavePreference);
dozeSensorCategory.removePreference(mPocketPreference);
} else {
mHandwavePreference.setOnPreferenceChangeListener(this);
mPocketPreference.setOnPreferenceChangeListener(this);
}
mRaiseToWakePreference.setOnPreferenceChangeListener(this);
checkService(context);
}
// Hides always on toggle if device doesn't support it (based on config_dozeAlwaysOnDisplayAvailable overlay)
if (!Utils.isDozeAlwaysOnAvailable(context)) {
getPreferenceScreen().removePreference(mDozeAlwaysOnPreference);
} else {
mDozeAlwaysOnPreference.setOnPreferenceChangeListener(this);
}
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_crDroidSettings by crdroidandroid.
the class Sound method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.crdroid_settings_sound);
final PreferenceScreen prefScreen = getPreferenceScreen();
ContentResolver resolver = getActivity().getContentResolver();
boolean isAudioPanelOnLeft = LineageSettings.Secure.getIntForUser(resolver, LineageSettings.Secure.VOLUME_PANEL_ON_LEFT, isAudioPanelOnLeftSide(getActivity()) ? 1 : 0, UserHandle.USER_CURRENT) != 0;
mVolumePanelLeft = (SwitchPreference) prefScreen.findPreference(KEY_VOLUME_PANEL_LEFT);
mVolumePanelLeft.setChecked(isAudioPanelOnLeft);
final PreferenceCategory vibCategory = prefScreen.findPreference(KEY_VIBRATE_CATEGORY);
if (!TelephonyUtils.isVoiceCapable(getActivity())) {
prefScreen.removePreference(vibCategory);
}
}
use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiDisplaySettings method buildCertificationMenu.
private void buildCertificationMenu(final PreferenceScreen preferenceScreen) {
if (mCertCategory == null) {
mCertCategory = new PreferenceCategory(getPrefContext());
mCertCategory.setTitle(R.string.wifi_display_certification_heading);
mCertCategory.setOrder(ORDER_CERTIFICATION);
} else {
mCertCategory.removeAll();
}
preferenceScreen.addPreference(mCertCategory);
// display session info if there is an active p2p session
if (!mWifiDisplayStatus.getSessionInfo().getGroupId().isEmpty()) {
Preference p = new Preference(getPrefContext());
p.setTitle(R.string.wifi_display_session_info);
p.setSummary(mWifiDisplayStatus.getSessionInfo().toString());
mCertCategory.addPreference(p);
// show buttons for Pause/Resume when a WFD session is established
if (mWifiDisplayStatus.getSessionInfo().getSessionId() != 0) {
mCertCategory.addPreference(new Preference(getPrefContext()) {
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
Button b = (Button) view.findViewById(R.id.left_button);
b.setText(R.string.wifi_display_pause);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mDisplayManager.pauseWifiDisplay();
}
});
b = (Button) view.findViewById(R.id.right_button);
b.setText(R.string.wifi_display_resume);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mDisplayManager.resumeWifiDisplay();
}
});
}
});
mCertCategory.setLayoutResource(R.layout.two_buttons_panel);
}
}
// switch for Listen Mode
SwitchPreference pref = new SwitchPreference(getPrefContext()) {
@Override
protected void onClick() {
mListen = !mListen;
setListenMode(mListen);
setChecked(mListen);
}
};
pref.setTitle(R.string.wifi_display_listen_mode);
pref.setChecked(mListen);
mCertCategory.addPreference(pref);
// switch for Autonomous GO
pref = new SwitchPreference(getPrefContext()) {
@Override
protected void onClick() {
mAutoGO = !mAutoGO;
if (mAutoGO) {
startAutoGO();
} else {
stopAutoGO();
}
setChecked(mAutoGO);
}
};
pref.setTitle(R.string.wifi_display_autonomous_go);
pref.setChecked(mAutoGO);
mCertCategory.addPreference(pref);
// Drop down list for choosing WPS method (PBC/KEYPAD/DISPLAY)
ListPreference lp = new ListPreference(getPrefContext());
lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
int wpsConfig = Integer.parseInt((String) value);
if (wpsConfig != mWpsConfig) {
mWpsConfig = wpsConfig;
getActivity().invalidateOptionsMenu();
Settings.Global.putInt(getActivity().getContentResolver(), Settings.Global.WIFI_DISPLAY_WPS_CONFIG, mWpsConfig);
}
return true;
}
});
mWpsConfig = Settings.Global.getInt(getActivity().getContentResolver(), Settings.Global.WIFI_DISPLAY_WPS_CONFIG, WpsInfo.INVALID);
String[] wpsEntries = { "Default", "PBC", "KEYPAD", "DISPLAY" };
String[] wpsValues = { "" + WpsInfo.INVALID, "" + WpsInfo.PBC, "" + WpsInfo.KEYPAD, "" + WpsInfo.DISPLAY };
lp.setKey("wps");
lp.setTitle(R.string.wifi_display_wps_config);
lp.setEntries(wpsEntries);
lp.setEntryValues(wpsValues);
lp.setValue("" + mWpsConfig);
lp.setSummary("%1$s");
mCertCategory.addPreference(lp);
// Drop down list for choosing listen channel
lp = new ListPreference(getPrefContext());
lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
int channel = Integer.parseInt((String) value);
if (channel != mListenChannel) {
mListenChannel = channel;
getActivity().invalidateOptionsMenu();
setWifiP2pChannels(mListenChannel, mOperatingChannel);
}
return true;
}
});
String[] lcEntries = { "Auto", "1", "6", "11" };
String[] lcValues = { "0", "1", "6", "11" };
lp.setKey("listening_channel");
lp.setTitle(R.string.wifi_display_listen_channel);
lp.setEntries(lcEntries);
lp.setEntryValues(lcValues);
lp.setValue("" + mListenChannel);
lp.setSummary("%1$s");
mCertCategory.addPreference(lp);
// Drop down list for choosing operating channel
lp = new ListPreference(getPrefContext());
lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
int channel = Integer.parseInt((String) value);
if (channel != mOperatingChannel) {
mOperatingChannel = channel;
getActivity().invalidateOptionsMenu();
setWifiP2pChannels(mListenChannel, mOperatingChannel);
}
return true;
}
});
String[] ocEntries = { "Auto", "1", "6", "11", "36" };
String[] ocValues = { "0", "1", "6", "11", "36" };
lp.setKey("operating_channel");
lp.setTitle(R.string.wifi_display_operating_channel);
lp.setEntries(ocEntries);
lp.setEntryValues(ocValues);
lp.setValue("" + mOperatingChannel);
lp.setSummary("%1$s");
mCertCategory.addPreference(lp);
}
Aggregations