use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ScreenPinningSettings method updateDisplay.
public void updateDisplay() {
PreferenceScreen root = getPreferenceScreen();
if (root != null) {
root.removeAll();
}
if (isLockToAppEnabled(getActivity())) {
addPreferencesFromResource(R.xml.screen_pinning_settings);
root = getPreferenceScreen();
mUseScreenLock = (SwitchPreference) root.findPreference(KEY_USE_SCREEN_LOCK);
mUseScreenLock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
return setScreenLockUsed((boolean) newValue);
}
});
mUseScreenLock.setChecked(isScreenLockUsed());
mUseScreenLock.setTitle(getCurrentSecurityTitle());
}
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDetailsProfilesController method refresh.
/**
* Refreshes the state of the switches for all profiles, possibly adding or removing switches as
* needed.
*/
@Override
protected void refresh() {
for (LocalBluetoothProfile profile : getProfiles()) {
if (!profile.isProfileReady()) {
continue;
}
SwitchPreference pref = mProfilesContainer.findPreference(profile.toString());
if (pref == null) {
pref = createProfilePreference(mProfilesContainer.getContext(), profile);
mProfilesContainer.addPreference(pref);
maybeAddHighQualityAudioPref(profile);
}
refreshProfilePreference(pref, profile);
}
for (LocalBluetoothProfile removedProfile : mCachedDevice.getRemovedProfiles()) {
final SwitchPreference pref = mProfilesContainer.findPreference(removedProfile.toString());
if (pref != null) {
mProfilesContainer.removePreference(pref);
}
}
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDetailsProfilesController method refreshProfilePreference.
/**
* Refreshes the state for an existing SwitchPreference for a profile.
*/
private void refreshProfilePreference(SwitchPreference profilePref, LocalBluetoothProfile profile) {
BluetoothDevice device = mCachedDevice.getDevice();
profilePref.setEnabled(!mCachedDevice.isBusy());
if (profile instanceof MapProfile) {
profilePref.setChecked(device.getMessageAccessPermission() == BluetoothDevice.ACCESS_ALLOWED);
} else if (profile instanceof PbapServerProfile) {
profilePref.setChecked(device.getPhonebookAccessPermission() == BluetoothDevice.ACCESS_ALLOWED);
} else if (profile instanceof PanProfile) {
profilePref.setChecked(profile.getConnectionStatus(device) == BluetoothProfile.STATE_CONNECTED);
} else {
profilePref.setChecked(profile.isPreferred(device));
}
if (profile instanceof A2dpProfile) {
A2dpProfile a2dp = (A2dpProfile) profile;
SwitchPreference highQualityPref = (SwitchPreference) mProfilesContainer.findPreference(HIGH_QUALITY_AUDIO_PREF_TAG);
if (highQualityPref != null) {
if (a2dp.isPreferred(device) && a2dp.supportsHighQualityAudio(device)) {
highQualityPref.setVisible(true);
highQualityPref.setTitle(a2dp.getHighQualityAudioOptionLabel(device));
highQualityPref.setChecked(a2dp.isHighQualityAudioEnabled(device));
highQualityPref.setEnabled(!mCachedDevice.isBusy());
} else {
highQualityPref.setVisible(false);
}
}
}
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDetailsProfilesController method maybeAddHighQualityAudioPref.
/**
* This is a helper method to be called after adding a Preference for a profile. If that
* profile happened to be A2dp and the device supports high quality audio, it will add a
* separate preference for controlling whether to actually use high quality audio.
*
* @param profile the profile just added
*/
private void maybeAddHighQualityAudioPref(LocalBluetoothProfile profile) {
if (!(profile instanceof A2dpProfile)) {
return;
}
BluetoothDevice device = mCachedDevice.getDevice();
A2dpProfile a2dp = (A2dpProfile) profile;
if (a2dp.isProfileReady() && a2dp.supportsHighQualityAudio(device)) {
SwitchPreference highQualityAudioPref = new SwitchPreference(mProfilesContainer.getContext());
highQualityAudioPref.setKey(HIGH_QUALITY_AUDIO_PREF_TAG);
highQualityAudioPref.setVisible(false);
highQualityAudioPref.setOnPreferenceClickListener(clickedPref -> {
boolean enable = ((SwitchPreference) clickedPref).isChecked();
a2dp.setHighQualityAudioEnabled(mCachedDevice.getDevice(), enable);
return true;
});
mProfilesContainer.addPreference(highQualityAudioPref);
}
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ShowSurfaceUpdatesPreferenceController method updateShowUpdatesSetting.
@VisibleForTesting
void updateShowUpdatesSetting() {
// magic communication with surface flinger.
try {
if (mSurfaceFlinger != null) {
final Parcel data = Parcel.obtain();
final Parcel reply = Parcel.obtain();
data.writeInterfaceToken(SURFACE_COMPOSER_INTERFACE_KEY);
mSurfaceFlinger.transact(SURFACE_FLINGER_READ_CODE, data, reply, 0);
@SuppressWarnings("unused") final int showCpu = reply.readInt();
@SuppressWarnings("unused") final int enableGL = reply.readInt();
final int showUpdates = reply.readInt();
((SwitchPreference) mPreference).setChecked(showUpdates != SETTING_VALUE_OFF);
reply.recycle();
data.recycle();
}
} catch (RemoteException ex) {
// intentional no-op
}
}
Aggregations