use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ButtonSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.rr_button_settings);
final ContentResolver resolver = getContentResolver();
final PreferenceScreen prefScreen = getPreferenceScreen();
final Resources res = getResources();
final int deviceWakeKeys = getResources().getInteger(com.android.internal.R.integer.config_deviceHardwareWakeKeys);
// bits for hardware keys present on device
final int deviceKeys = getResources().getInteger(com.android.internal.R.integer.config_deviceHardwareKeys);
final boolean needsNavbar = DUActionUtils.hasNavbarByDefault(getActivity());
final PreferenceCategory hwkeyCat = (PreferenceCategory) prefScreen.findPreference(CATEGORY_HWKEY);
if (needsNavbar) {
prefScreen.removePreference(hwkeyCat);
}
// load categories and init/remove preferences based on device
// configuration
final boolean hasPowerKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER);
// Double press power to launch camera.
mCameraDoubleTapPowerGesture = (SwitchPreference) findPreference(KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE);
final boolean hasCameraKey = (deviceKeys & KEY_MASK_CAMERA) != 0;
final boolean showCameraWake = (deviceWakeKeys & KEY_MASK_CAMERA) != 0;
final boolean showVolumeWake = (deviceWakeKeys & KEY_MASK_VOLUME) != 0;
final PreferenceCategory cameraCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_CAMERA);
final PreferenceCategory powerCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_POWER);
final PreferenceCategory volumeCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_VOLUME);
if (hasCameraKey) {
mCameraWakeScreen = (SwitchPreference) findPreference(CMSettings.System.CAMERA_WAKE_SCREEN);
mCameraSleepOnRelease = (SwitchPreference) findPreference(CMSettings.System.CAMERA_SLEEP_ON_RELEASE);
mCameraLaunch = (SwitchPreference) findPreference(CMSettings.System.CAMERA_LAUNCH);
if (!showCameraWake) {
prefScreen.removePreference(mCameraWakeScreen);
}
// Only show 'Camera sleep on release' if the device has a focus key
if (res.getBoolean(com.android.internal.R.bool.config_singleStageCameraKey)) {
prefScreen.removePreference(mCameraSleepOnRelease);
}
} else {
prefScreen.removePreference(cameraCategory);
}
if (DeviceUtils.hasVolumeRocker(getActivity())) {
if (!showVolumeWake) {
volumeCategory.removePreference(findPreference(CMSettings.System.VOLUME_WAKE_SCREEN));
}
if (!TelephonyUtils.isVoiceCapable(getActivity())) {
volumeCategory.removePreference(findPreference(CMSettings.System.VOLUME_ANSWER_CALL));
}
int cursorControlAction = Settings.System.getInt(resolver, Settings.System.VOLUME_KEY_CURSOR_CONTROL, 0);
mVolumeKeyCursorControl = initActionList(KEY_VOLUME_KEY_CURSOR_CONTROL, cursorControlAction);
int swapVolumeKeys = CMSettings.System.getInt(getContentResolver(), CMSettings.System.SWAP_VOLUME_KEYS_ON_ROTATION, 0);
mSwapVolumeButtons = (SwitchPreference) prefScreen.findPreference(KEY_SWAP_VOLUME_BUTTONS);
if (mSwapVolumeButtons != null) {
mSwapVolumeButtons.setChecked(swapVolumeKeys > 0);
}
} else {
prefScreen.removePreference(volumeCategory);
}
final ButtonBacklightBrightness backlight = (ButtonBacklightBrightness) findPreference(KEY_BUTTON_BACKLIGHT);
if (backlight != null) {
if (!backlight.isButtonSupported() && !backlight.isKeyboardSupported() || needsNavbar) {
prefScreen.removePreference(backlight);
}
}
// Power button ends calls.
mPowerEndCall = (SwitchPreference) findPreference(KEY_POWER_END_CALL);
if (hasPowerKey) {
if (!TelephonyUtils.isVoiceCapable(getActivity())) {
powerCategory.removePreference(mPowerEndCall);
mPowerEndCall = null;
}
if (mCameraDoubleTapPowerGesture != null && isCameraDoubleTapPowerGestureAvailable(getResources())) {
// Update double tap power to launch camera if available.
mCameraDoubleTapPowerGesture.setOnPreferenceChangeListener(this);
int cameraDoubleTapPowerDisabled = Settings.Secure.getInt(getContentResolver(), CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0);
mCameraDoubleTapPowerGesture.setChecked(cameraDoubleTapPowerDisabled == 0);
} else {
powerCategory.removePreference(mCameraDoubleTapPowerGesture);
mCameraDoubleTapPowerGesture = null;
}
} else {
prefScreen.removePreference(powerCategory);
}
if (mCameraWakeScreen != null) {
if (mCameraSleepOnRelease != null && !getResources().getBoolean(com.android.internal.R.bool.config_singleStageCameraKey)) {
mCameraSleepOnRelease.setDependency(CMSettings.System.CAMERA_WAKE_SCREEN);
}
}
mVolumeWakeScreen = (SwitchPreference) findPreference(CMSettings.System.VOLUME_WAKE_SCREEN);
mVolumeMusicControls = (SwitchPreference) findPreference(KEY_VOLUME_MUSIC_CONTROLS);
//volume rocker music control
mVolumeMusicControls = (SwitchPreference) findPreference(KEY_VOLUME_MUSIC_CONTROLS);
if (mVolumeWakeScreen != null) {
if (mVolumeMusicControls != null) {
mVolumeMusicControls.setDependency(CMSettings.System.VOLUME_WAKE_SCREEN);
mVolumeWakeScreen.setDisableDependentsState(true);
}
}
mDt2lCameraVibrateConfig = (SeekBarPreference) findPreference(DT2L_CAMERA_VIBRATE_CONFIG);
int dt2lCameraVibrateConfig = Settings.System.getInt(resolver, Settings.System.DT2L_CAMERA_VIBRATE_CONFIG, 1);
mDt2lCameraVibrateConfig.setValue(dt2lCameraVibrateConfig / 1);
mDt2lCameraVibrateConfig.setOnPreferenceChangeListener(this);
}
use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PremiumSmsAccess method updatePrefs.
private void updatePrefs(ArrayList<AppEntry> apps) {
if (apps == null)
return;
setEmptyText(R.string.premium_sms_none);
setLoading(false, true);
final PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getPrefContext());
screen.setOrderingAsAdded(true);
for (int i = 0; i < apps.size(); i++) {
final PremiumSmsPreference smsPreference = new PremiumSmsPreference(apps.get(i), getPrefContext());
smsPreference.setOnPreferenceChangeListener(this);
screen.addPreference(smsPreference);
}
if (apps.size() != 0) {
DividerPreference summary = new DividerPreference(getPrefContext());
summary.setSelectable(false);
summary.setSummary(R.string.premium_sms_warning);
summary.setDividerAllowedAbove(true);
screen.addPreference(summary);
}
setPreferenceScreen(screen);
}
use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppCircleBar method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ContentResolver resolver = getActivity().getContentResolver();
Resources res = getResources();
addPreferencesFromResource(R.xml.app_circlebar);
PreferenceScreen prefSet = getPreferenceScreen();
mIncludedAppCircleBar = (AppMultiSelectListPreference) prefSet.findPreference(PREF_INCLUDE_APP_CIRCLE_BAR_KEY);
Set<String> includedApps = getIncludedApps();
if (includedApps != null)
mIncludedAppCircleBar.setValues(includedApps);
mIncludedAppCircleBar.setOnPreferenceChangeListener(this);
mTriggerWidthPref = (SeekBarPreference) findPreference(KEY_TRIGGER_WIDTH);
mTriggerWidthPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.APP_CIRCLE_BAR_TRIGGER_WIDTH, 40));
mTriggerWidthPref.setOnPreferenceChangeListener(this);
mTriggerTopPref = (SeekBarPreference) findPreference(KEY_TRIGGER_TOP);
mTriggerTopPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.APP_CIRCLE_BAR_TRIGGER_TOP, 0));
mTriggerTopPref.setOnPreferenceChangeListener(this);
mTriggerBottomPref = (SeekBarPreference) findPreference(KEY_TRIGGER_BOTTOM);
mTriggerBottomPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.APP_CIRCLE_BAR_TRIGGER_HEIGHT, 100));
mTriggerBottomPref.setOnPreferenceChangeListener(this);
}
use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiCallingSettings method updateButtonWfcMode.
private void updateButtonWfcMode(Context context, boolean wfcEnabled, int wfcMode, int wfcRoamingMode) {
mButtonWfcMode.setSummary(getWfcModeSummary(context, wfcMode));
mButtonWfcMode.setEnabled(wfcEnabled && mEditableWfcMode);
// mButtonWfcRoamingMode.setSummary is not needed; summary is just selected value.
mButtonWfcRoamingMode.setEnabled(wfcEnabled && mEditableWfcRoamingMode);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
boolean updateAddressEnabled = (getCarrierActivityIntent(context) != null);
if (wfcEnabled) {
if (mEditableWfcMode) {
preferenceScreen.addPreference(mButtonWfcMode);
} else {
// Don't show WFC (home) preference if it's not editable.
preferenceScreen.removePreference(mButtonWfcMode);
}
if (mEditableWfcRoamingMode) {
preferenceScreen.addPreference(mButtonWfcRoamingMode);
} else {
// Don't show WFC roaming preference if it's not editable.
preferenceScreen.removePreference(mButtonWfcRoamingMode);
}
if (updateAddressEnabled) {
preferenceScreen.addPreference(mUpdateAddress);
} else {
preferenceScreen.removePreference(mUpdateAddress);
}
} else {
preferenceScreen.removePreference(mButtonWfcMode);
preferenceScreen.removePreference(mButtonWfcRoamingMode);
preferenceScreen.removePreference(mUpdateAddress);
}
}
use of android.support.v7.preference.PreferenceScreen in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SpellCheckersSettings method updatePreferenceScreen.
private void updatePreferenceScreen() {
mCurrentSci = mTsm.getCurrentSpellChecker();
final boolean isSpellCheckerEnabled = mTsm.isSpellCheckerEnabled();
mSwitchBar.setChecked(isSpellCheckerEnabled);
final SpellCheckerSubtype currentScs;
if (mCurrentSci != null) {
currentScs = mTsm.getCurrentSpellCheckerSubtype(false);
} else {
currentScs = null;
}
mSpellCheckerLanaguagePref.setSummary(getSpellCheckerSubtypeLabel(mCurrentSci, currentScs));
final PreferenceScreen screen = getPreferenceScreen();
final int count = screen.getPreferenceCount();
for (int index = 0; index < count; index++) {
final Preference preference = screen.getPreference(index);
preference.setEnabled(isSpellCheckerEnabled);
if (preference instanceof SpellCheckerPreference) {
final SpellCheckerPreference pref = (SpellCheckerPreference) preference;
pref.setSelected(mCurrentSci);
}
}
mSpellCheckerLanaguagePref.setEnabled(isSpellCheckerEnabled && mCurrentSci != null);
}
Aggregations