When upgrading the speech rate, clamp it to between the default and maximum values.

This commit is contained in:
Reece H. Dunn
2013-05-06 13:43:48 +01:00
parent 94c8a1bcce
commit ce8f261495
@@ -52,8 +52,13 @@ public class TtsSettingsActivity extends PreferenceActivity {
if (rate == null) {
// Try the old eyes-free setting:
SpeechSynthesis engine = new SpeechSynthesis(this, null);
int defaultValue = engine.Rate.getDefaultValue();
int maxValue = engine.Rate.getMaxValue();
rate = prefs.getString("default_rate", "100");
int rateValue = (Integer.parseInt(rate) / 100) * engine.Rate.getDefaultValue();
int rateValue = (Integer.parseInt(rate) / 100) * defaultValue;
if (rateValue < defaultValue) rateValue = defaultValue;
if (rateValue > maxValue) rateValue = maxValue;
editor.putString("espeak_rate", Integer.toString(rateValue));
}