use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VolumePanelSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.rr_volume_panel);
PreferenceScreen prefSet = getPreferenceScreen();
final ContentResolver resolver = getActivity().getContentResolver();
// Volume dialog alpha
mVolumeDialogAlpha = (SeekBarPreference) prefSet.findPreference(PREF_TRANSPARENT_VOLUME_DIALOG);
int volumeDialogAlpha = Settings.System.getInt(resolver, Settings.System.TRANSPARENT_VOLUME_DIALOG, 255);
mVolumeDialogAlpha.setValue(volumeDialogAlpha / 1);
mVolumeDialogAlpha.setOnPreferenceChangeListener(this);
// Volume dialog stroke
mVolumeDialogStroke = (ListPreference) findPreference(PREF_VOLUME_DIALOG_STROKE);
int volumeDialogStroke = Settings.System.getIntForUser(resolver, Settings.System.VOLUME_DIALOG_STROKE, 0, UserHandle.USER_CURRENT);
mVolumeDialogStroke.setValue(String.valueOf(volumeDialogStroke));
mVolumeDialogStroke.setSummary(mVolumeDialogStroke.getEntry());
mVolumeDialogStroke.setOnPreferenceChangeListener(this);
// Volume dialog stroke color
mVolumeDialogStrokeColor = (ColorPickerPreference) findPreference(PREF_VOLUME_DIALOG_STROKE_COLOR);
mVolumeDialogStrokeColor.setOnPreferenceChangeListener(this);
int intColor = Settings.System.getInt(resolver, Settings.System.VOLUME_DIALOG_STROKE_COLOR, DEFAULT_VOLUME_DIALOG_STROKE_COLOR);
String hexColor = String.format("#%08x", (0xFF80CBC4 & intColor));
mVolumeDialogStrokeColor.setSummary(hexColor);
mVolumeDialogStrokeColor.setNewPreviewColor(intColor);
// Volume dialog stroke thickness
mVolumeDialogStrokeThickness = (SeekBarPreference) findPreference(PREF_VOLUME_DIALOG_STROKE_THICKNESS);
int volumeDialogStrokeThickness = Settings.System.getInt(resolver, Settings.System.VOLUME_DIALOG_STROKE_THICKNESS, 4);
mVolumeDialogStrokeThickness.setValue(volumeDialogStrokeThickness / 1);
mVolumeDialogStrokeThickness.setOnPreferenceChangeListener(this);
// Volume dialog corner radius
mVolumeDialogCornerRadius = (SeekBarPreference) findPreference(PREF_VOLUME_DIALOG_CORNER_RADIUS);
int volumeDialogCornerRadius = Settings.System.getInt(resolver, Settings.System.VOLUME_DIALOG_CORNER_RADIUS, 10);
mVolumeDialogCornerRadius.setValue(volumeDialogCornerRadius / 1);
mVolumeDialogCornerRadius.setOnPreferenceChangeListener(this);
// Volume dialog dash width
mVolumeDialogDashWidth = (SeekBarPreference) findPreference(PREF_VOLUME_DIALOG_STROKE_DASH_WIDTH);
int volumeDialogDashWidth = Settings.System.getInt(resolver, Settings.System.VOLUME_DIALOG_STROKE_DASH_WIDTH, 0);
if (volumeDialogDashWidth != 0) {
mVolumeDialogDashWidth.setValue(volumeDialogDashWidth / 1);
} else {
mVolumeDialogDashWidth.setValue(0);
}
mVolumeDialogDashWidth.setOnPreferenceChangeListener(this);
// Volume dialog dash gap
mVolumeDialogDashGap = (SeekBarPreference) findPreference(PREF_VOLUME_DIALOG_STROKE_DASH_GAP);
int volumeDialogDashGap = Settings.System.getInt(resolver, Settings.System.VOLUME_DIALOG_STROKE_DASH_GAP, 10);
mVolumeDialogDashGap.setValue(volumeDialogDashGap / 1);
mVolumeDialogDashGap.setOnPreferenceChangeListener(this);
mVolumeDialogTimeout = (SeekBarPreference) findPreference(KEY_VOLUME_DIALOG_TIMEOUT);
int timeout = Settings.System.getInt(resolver, Settings.System.VOLUME_DIALOG_TIMEOUT, 3000);
mVolumeDialogTimeout.setValue(timeout / 1);
mVolumeDialogTimeout.setOnPreferenceChangeListener(this);
VolumeDialogSettingsDisabler(volumeDialogStroke);
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class VolumeSteps method updateVolumeStepPrefs.
private void updateVolumeStepPrefs(Preference pref, int steps) {
if (pref == null || !(pref instanceof ListPreference)) {
return;
}
final ListPreference listPref = (ListPreference) pref;
listPref.setSummary(String.valueOf(steps));
listPref.setValue(String.valueOf(steps));
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DisplaySettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Activity activity = getActivity();
final ContentResolver resolver = activity.getContentResolver();
addPreferencesFromResource(R.xml.display_settings);
PreferenceCategory displayPrefs = (PreferenceCategory) findPreference(KEY_CATEGORY_DISPLAY);
mScreenSaverPreference = findPreference(KEY_SCREEN_SAVER);
if (mScreenSaverPreference != null && getResources().getBoolean(com.android.internal.R.bool.config_dreamsSupported) == false) {
getPreferenceScreen().removePreference(mScreenSaverPreference);
}
mScreenTimeoutPreference = (TimeoutListPreference) findPreference(KEY_SCREEN_TIMEOUT);
if (displayPrefs != null) {
mAutoBrightnessPreference = (SwitchPreference) findPreference(KEY_AUTO_BRIGHTNESS);
if (mAutoBrightnessPreference != null) {
if (isAutomaticBrightnessAvailable(getResources())) {
mAutoBrightnessPreference.setOnPreferenceChangeListener(this);
} else {
displayPrefs.removePreference(mAutoBrightnessPreference);
}
}
if (!NightDisplayController.isAvailable(activity)) {
removePreference(KEY_NIGHT_DISPLAY);
}
mLiftToWakePreference = (SwitchPreference) findPreference(KEY_LIFT_TO_WAKE);
if (mLiftToWakePreference != null) {
if (isLiftToWakeAvailable(activity)) {
mLiftToWakePreference.setOnPreferenceChangeListener(this);
} else {
displayPrefs.removePreference(mLiftToWakePreference);
}
}
mTapToWakePreference = (SwitchPreference) findPreference(KEY_TAP_TO_WAKE);
if (mTapToWakePreference != null) {
if (isTapToWakeAvailable(getResources())) {
mTapToWakePreference.setOnPreferenceChangeListener(this);
} else {
displayPrefs.removePreference(mTapToWakePreference);
}
}
mCameraGesturePreference = (SwitchPreference) findPreference(KEY_CAMERA_GESTURE);
if (mCameraGesturePreference != null) {
if (isCameraGestureAvailable(getResources())) {
mCameraGesturePreference.setOnPreferenceChangeListener(this);
} else {
displayPrefs.removePreference(mCameraGesturePreference);
}
}
DropDownPreference rotatePreference = (DropDownPreference) findPreference(KEY_AUTO_ROTATE);
if (rotatePreference != null) {
if (RotationPolicy.isRotationLockToggleVisible(activity)) {
int rotateLockedResourceId;
// rotation), then we use a different string to include this information.
if (allowAllRotations(activity)) {
rotateLockedResourceId = R.string.display_auto_rotate_stay_in_current;
} else {
if (RotationPolicy.getRotationLockOrientation(activity) == Configuration.ORIENTATION_PORTRAIT) {
rotateLockedResourceId = R.string.display_auto_rotate_stay_in_portrait;
} else {
rotateLockedResourceId = R.string.display_auto_rotate_stay_in_landscape;
}
}
rotatePreference.setEntries(new CharSequence[] { activity.getString(R.string.display_auto_rotate_rotate), activity.getString(rotateLockedResourceId) });
rotatePreference.setEntryValues(new CharSequence[] { "0", "1" });
rotatePreference.setValueIndex(RotationPolicy.isRotationLocked(activity) ? 1 : 0);
rotatePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean locked = Integer.parseInt((String) newValue) != 0;
MetricsLogger.action(getActivity(), MetricsEvent.ACTION_ROTATION_LOCK, locked);
RotationPolicy.setRotationLock(activity, locked);
return true;
}
});
} else {
displayPrefs.removePreference(rotatePreference);
}
}
DropDownPreference vrDisplayPref = (DropDownPreference) findPreference(KEY_VR_DISPLAY_PREF);
if (vrDisplayPref != null) {
if (isVrDisplayModeAvailable(activity)) {
vrDisplayPref.setEntries(new CharSequence[] { activity.getString(R.string.display_vr_pref_low_persistence), activity.getString(R.string.display_vr_pref_off) });
vrDisplayPref.setEntryValues(new CharSequence[] { "0", "1" });
final Context c = activity;
int currentUser = ActivityManager.getCurrentUser();
int current = Settings.Secure.getIntForUser(c.getContentResolver(), Settings.Secure.VR_DISPLAY_MODE, /*default*/
Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE, currentUser);
vrDisplayPref.setValueIndex(current);
vrDisplayPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
int i = Integer.parseInt((String) newValue);
int u = ActivityManager.getCurrentUser();
if (!Settings.Secure.putIntForUser(c.getContentResolver(), Settings.Secure.VR_DISPLAY_MODE, i, u)) {
Log.e(TAG, "Could not change setting for " + Settings.Secure.VR_DISPLAY_MODE);
}
return true;
}
});
} else {
displayPrefs.removePreference(vrDisplayPref);
}
}
}
mNightModePreference = (ListPreference) findPreference(KEY_NIGHT_MODE);
if (mNightModePreference != null) {
final UiModeManager uiManager = (UiModeManager) getSystemService(Context.UI_MODE_SERVICE);
final int currentNightMode = uiManager.getNightMode();
mNightModePreference.setValue(String.valueOf(currentNightMode));
mNightModePreference.setOnPreferenceChangeListener(this);
}
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PixelAnimDurationSettings method refreshSettings.
public void refreshSettings() {
PreferenceScreen prefs = getPreferenceScreen();
if (prefs != null) {
prefs.removeAll();
}
addPreferencesFromResource(R.xml.pixel_anim_duration);
mContext = getActivity().getApplicationContext();
mContentRes = getActivity().getContentResolver();
final Resources res = getResources();
int defaultValue;
mPixelx = (SeekBarPreference) findPreference(PIXEL_X);
int xanim = Settings.System.getIntForUser(getContentResolver(), Settings.System.OPA_ANIM_DURATION_X, 133, UserHandle.USER_CURRENT);
mPixelx.setValue(xanim / 1);
mPixelx.setOnPreferenceChangeListener(this);
mPixely = (SeekBarPreference) findPreference(PIXEL_Y);
int yanim = Settings.System.getIntForUser(getContentResolver(), Settings.System.OPA_ANIM_DURATION_Y, 255, UserHandle.USER_CURRENT);
mPixely.setValue(yanim / 1);
mPixely.setOnPreferenceChangeListener(this);
mCollapse = (SeekBarPreference) findPreference(PIXEL_COLLAPSE);
int xcol = Settings.System.getIntForUser(getContentResolver(), Settings.System.COLLAPSE_ANIMATION_DURATION_RY, 83, UserHandle.USER_CURRENT);
mCollapse.setValue(xcol / 1);
mCollapse.setOnPreferenceChangeListener(this);
mBg = (SeekBarPreference) findPreference(PIXEL_BG);
int bg = Settings.System.getIntForUser(getContentResolver(), Settings.System.COLLAPSE_ANIMATION_DURATION_BG, 100, UserHandle.USER_CURRENT);
mBg.setValue(yanim / 1);
mBg.setOnPreferenceChangeListener(this);
mRetract = (SeekBarPreference) findPreference(PIXEL_RETRACT);
int ret = Settings.System.getIntForUser(getContentResolver(), Settings.System.RETRACT_ANIMATION_DURATION, 300, UserHandle.USER_CURRENT);
mRetract.setValue(ret / 1);
mRetract.setOnPreferenceChangeListener(this);
mDiamond = (SeekBarPreference) findPreference(PIXEL_DIAMOND);
int diam = Settings.System.getIntForUser(getContentResolver(), Settings.System.DIAMOND_ANIMATION_DURATION, 200, UserHandle.USER_CURRENT);
mDiamond.setValue(diam / 1);
mDiamond.setOnPreferenceChangeListener(this);
mDots = (SeekBarPreference) findPreference(PIXEL_DOTS);
int dots = Settings.System.getIntForUser(getContentResolver(), Settings.System.DOTS_RESIZE_DURATION, 200, UserHandle.USER_CURRENT);
mDots.setValue(dots / 1);
mDots.setOnPreferenceChangeListener(this);
mHome = (SeekBarPreference) findPreference(PIXEL_HOME);
int home = Settings.System.getIntForUser(getContentResolver(), Settings.System.HOME_RESIZE_DURATION, 255, UserHandle.USER_CURRENT);
mHome.setValue(home / 1);
mHome.setOnPreferenceChangeListener(this);
mColorCat = (PreferenceCategory) findPreference(COLOR_CAT);
mTopColor = (ColorPickerPreference) findPreference(TOP_COLOR);
mTopColor.setOnPreferenceChangeListener(this);
int top = Settings.System.getInt(mContentRes, Settings.System.DOT_TOP_COLOR, Color.RED);
String topHexColor = String.format("#%08x", (0x00ffffff & top));
mTopColor.setSummary(topHexColor);
mTopColor.setNewPreviewColor(top);
mBottomColor = (ColorPickerPreference) findPreference(BOTTOM_COLOR);
mBottomColor.setOnPreferenceChangeListener(this);
int bottom = Settings.System.getInt(mContentRes, Settings.System.DOT_BOTTOM_COLOR, Color.YELLOW);
String bottomHexColor = String.format("#%08x", (0x00ffffff & bottom));
mBottomColor.setSummary(bottomHexColor);
mBottomColor.setNewPreviewColor(bottom);
mRightColor = (ColorPickerPreference) findPreference(RIGHT_COLOR);
mRightColor.setOnPreferenceChangeListener(this);
int right = Settings.System.getInt(mContentRes, Settings.System.DOT_RIGHT_COLOR, Color.GREEN);
String rightHexColor = String.format("#%08x", (0x00ffffff & right));
mRightColor.setSummary(rightHexColor);
mRightColor.setNewPreviewColor(right);
mLeftColor = (ColorPickerPreference) findPreference(LEFT_COLOR);
mLeftColor.setOnPreferenceChangeListener(this);
int left = Settings.System.getInt(mContentRes, Settings.System.DOT_LEFT_COLOR, Color.RED);
String leftHexColor = String.format("#%08x", (0x00ffffff & left));
mLeftColor.setSummary(leftHexColor);
mLeftColor.setNewPreviewColor(left);
mColorStyle = (ListPreference) findPreference(COLOR_STYLE);
int style = Settings.System.getIntForUser(mContentRes, Settings.System.DOT_COLOR_SWITCH, 0, UserHandle.USER_CURRENT);
mColorStyle.setValue(String.valueOf(style));
mColorStyle.setSummary(mColorStyle.getEntry());
mColorStyle.setOnPreferenceChangeListener(this);
UpdateSettings(style);
}
use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PieControl method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.pa_pie_control);
PreferenceScreen prefSet = getPreferenceScreen();
Context context = getActivity();
mResolver = context.getContentResolver();
mPieSize = (ListPreference) prefSet.findPreference(PA_PIE_SIZE);
float pieSize = Settings.System.getFloat(mResolver, Settings.System.PA_PIE_SIZE, 1.0f);
mPieSize.setValue(String.valueOf(pieSize));
mPieSize.setOnPreferenceChangeListener(this);
mPieGravity = (ListPreference) prefSet.findPreference(PA_PIE_GRAVITY);
int pieGravity = Settings.System.getInt(mResolver, Settings.System.PA_PIE_GRAVITY, 2);
mPieGravity.setValue(String.valueOf(pieGravity));
mPieGravity.setOnPreferenceChangeListener(this);
mPieMode = (ListPreference) prefSet.findPreference(PA_PIE_MODE);
int pieMode = Settings.System.getInt(mResolver, Settings.System.PA_PIE_MODE, 2);
mPieMode.setValue(String.valueOf(pieMode));
mPieMode.setOnPreferenceChangeListener(this);
mPieGap = (ListPreference) prefSet.findPreference(PA_PIE_GAP);
int pieGap = Settings.System.getInt(mResolver, Settings.System.PA_PIE_GAP, 2);
mPieGap.setValue(String.valueOf(pieGap));
mPieGap.setOnPreferenceChangeListener(this);
mPieAngle = (ListPreference) prefSet.findPreference(PA_PIE_ANGLE);
int pieAngle = Settings.System.getInt(mResolver, Settings.System.PA_PIE_ANGLE, 12);
mPieAngle.setValue(String.valueOf(pieAngle));
mPieAngle.setOnPreferenceChangeListener(this);
}
Aggregations