Browse Source

SeekBarPreference: make formatter an explicit property instead of using the extras bundle.

master
Reece H. Dunn 12 years ago
parent
commit
8e4b6044dc

+ 9
- 0
android/src/com/reecedunn/espeak/SeekBarPreference.java View File

private int mProgress = 0; private int mProgress = 0;
private int mMin = 0; private int mMin = 0;
private int mMax = 100; private int mMax = 100;
private String mFormatter = "%s";


public void setProgress(int progress) { public void setProgress(int progress) {
mProgress = progress + mMin; mProgress = progress + mMin;
return mMax; return mMax;
} }


public void setFormatter(String formatter) {
mFormatter = formatter;
}

public String getFormatter() {
return mFormatter;
}

public SeekBarPreference(Context context, AttributeSet attrs, int defStyle) public SeekBarPreference(Context context, AttributeSet attrs, int defStyle)
{ {
super(context, attrs, defStyle); super(context, attrs, defStyle);

+ 4
- 3
android/src/com/reecedunn/espeak/TtsSettingsActivity.java View File

switch (parameter.getUnitType()) switch (parameter.getUnitType())
{ {
case Percentage: case Percentage:
pref.getExtras().putString("formatter", context.getString(R.string.formatter_percentage));
pref.setFormatter(context.getString(R.string.formatter_percentage));
break; break;
case WordsPerMinute: case WordsPerMinute:
pref.getExtras().putString("formatter", context.getString(R.string.formatter_wpm));
pref.setFormatter(context.getString(R.string.formatter_wpm));
break; break;
default: default:
throw new IllegalStateException("Unsupported unit type for the parameter."); throw new IllegalStateException("Unsupported unit type for the parameter.");
summary = entries[index].toString(); summary = entries[index].toString();
} }
} else if (preference instanceof SeekBarPreference) { } else if (preference instanceof SeekBarPreference) {
String formatter = preference.getExtras().getString("formatter");
final SeekBarPreference seekBarPreference = (SeekBarPreference) preference;
String formatter = seekBarPreference.getFormatter();
summary = String.format(formatter, (String)newValue); summary = String.format(formatter, (String)newValue);
} }
preference.setSummary(summary); preference.setSummary(summary);

Loading…
Cancel
Save