mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-10-31 05:35:35 +00:00
SeekBarPreference: make formatter an explicit property instead of using the extras bundle.
This commit is contained in:
@@ -31,6 +31,7 @@ public class SeekBarPreference extends DialogPreference
|
||||
private int mProgress = 0;
|
||||
private int mMin = 0;
|
||||
private int mMax = 100;
|
||||
private String mFormatter = "%s";
|
||||
|
||||
public void setProgress(int progress) {
|
||||
mProgress = progress + mMin;
|
||||
@@ -62,6 +63,14 @@ public class SeekBarPreference extends DialogPreference
|
||||
return mMax;
|
||||
}
|
||||
|
||||
public void setFormatter(String formatter) {
|
||||
mFormatter = formatter;
|
||||
}
|
||||
|
||||
public String getFormatter() {
|
||||
return mFormatter;
|
||||
}
|
||||
|
||||
public SeekBarPreference(Context context, AttributeSet attrs, int defStyle)
|
||||
{
|
||||
super(context, attrs, defStyle);
|
||||
|
||||
@@ -71,10 +71,10 @@ public class TtsSettingsActivity extends PreferenceActivity {
|
||||
switch (parameter.getUnitType())
|
||||
{
|
||||
case Percentage:
|
||||
pref.getExtras().putString("formatter", context.getString(R.string.formatter_percentage));
|
||||
pref.setFormatter(context.getString(R.string.formatter_percentage));
|
||||
break;
|
||||
case WordsPerMinute:
|
||||
pref.getExtras().putString("formatter", context.getString(R.string.formatter_wpm));
|
||||
pref.setFormatter(context.getString(R.string.formatter_wpm));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unsupported unit type for the parameter.");
|
||||
@@ -140,7 +140,8 @@ public class TtsSettingsActivity extends PreferenceActivity {
|
||||
summary = entries[index].toString();
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
preference.setSummary(summary);
|
||||
|
||||
Reference in New Issue
Block a user