Colorpicker and customseekbar: add method to set default values
also be sure default values is not greater than max value
This commit is contained in:
@@ -54,6 +54,9 @@ public class CustomSeekBarPreference extends Preference implements SeekBar.OnSee
|
||||
mMax = attrs.getAttributeIntValue(ANDROIDNS, "max", 100);
|
||||
mMin = attrs.getAttributeIntValue(SETTINGS_NS, "min", 0);
|
||||
mDefaultValue = attrs.getAttributeIntValue(ANDROIDNS, "defaultValue", -1);
|
||||
if (mDefaultValue > mMax) {
|
||||
mDefaultValue = mMax;
|
||||
}
|
||||
mUnits = getAttributeStringValue(attrs, SETTINGS_NS, "units", "");
|
||||
mDefaultText = getAttributeStringValue(attrs, SETTINGS_NS, "defaultText", "Def");
|
||||
|
||||
@@ -137,7 +140,7 @@ public class CustomSeekBarPreference extends Preference implements SeekBar.OnSee
|
||||
mStatusText.setText(mDefaultText);
|
||||
} else {
|
||||
mStatusText.setText(String.valueOf(mCurrentValue) + mUnits);
|
||||
}
|
||||
}
|
||||
mSeekBar.setProgress(mCurrentValue - mMin);
|
||||
mTitle = (TextView) view.findViewById(android.R.id.title);
|
||||
|
||||
@@ -222,6 +225,16 @@ public class CustomSeekBarPreference extends Preference implements SeekBar.OnSee
|
||||
}
|
||||
}
|
||||
|
||||
public void setDefaultValue(int value) {
|
||||
mDefaultValue = value;
|
||||
if (mDefaultValue > mMax) {
|
||||
mDefaultValue = mMax;
|
||||
}
|
||||
if (mCurrentValue == mDefaultValue) {
|
||||
mStatusText.setText(mDefaultText);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (mSeekBar != null && mStatusText != null && mTitle != null) {
|
||||
|
||||
@@ -284,6 +284,10 @@ public class ColorPickerPreference extends Preference implements
|
||||
onColorChanged(color);
|
||||
}
|
||||
|
||||
public void setDefaultColor(int color) {
|
||||
mDefValue = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* For custom purposes. Not used by ColorPickerPreferrence
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user