mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-26 04:59:59 +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 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;
|
||||||
@@ -62,6 +63,14 @@ public class SeekBarPreference extends DialogPreference
|
|||||||
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);
|
||||||
|
|||||||
@@ -71,10 +71,10 @@ public class TtsSettingsActivity extends PreferenceActivity {
|
|||||||
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.");
|
||||||
@@ -140,7 +140,8 @@ public class TtsSettingsActivity extends PreferenceActivity {
|
|||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user