Browse Source

Add an explicit 'None' option to the 'Speak punctuation' setting.

master
Reece H. Dunn 12 years ago
parent
commit
1891740f80

+ 10
- 4
android/res/layout/speak_punctuation_preference.xml View File

<RadioGroup <RadioGroup
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusable="false">
android:focusable="false"
android:id="@+id/options">


<RadioButton <RadioButton
android:layout_width="match_parent" android:layout_width="match_parent"
android:focusable="false" android:focusable="false"
android:focusableInTouchMode="false" android:focusableInTouchMode="false"
android:clickable="true" /> android:clickable="true" />

<RadioButton
android:layout_width="match_parent"
android:layout_height="48dp"
android:text="@string/punctuation_none"
android:id="@+id/none" />
</RadioGroup> </RadioGroup>


<EditText <EditText
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_height="48dp"
android:id="@+id/punctuation_characters" android:id="@+id/punctuation_characters"
android:hint="@string/punctuation_characters"
android:layout_marginLeft="32dp" />
android:hint="@string/punctuation_characters" />


</LinearLayout> </LinearLayout>

+ 16
- 5
android/src/com/reecedunn/espeak/SpeakPunctuationPreference.java View File

public class SpeakPunctuationPreference extends DialogPreference { public class SpeakPunctuationPreference extends DialogPreference {
private RadioButton mAll; private RadioButton mAll;
private RadioButton mCustom; private RadioButton mCustom;
private RadioButton mNone;
private EditText mPunctuationCharacters; private EditText mPunctuationCharacters;


private VoiceSettings mSettings; private VoiceSettings mSettings;
View root = super.onCreateDialogView(); View root = super.onCreateDialogView();
mAll = (RadioButton)root.findViewById(R.id.all); mAll = (RadioButton)root.findViewById(R.id.all);
mCustom = (RadioButton)root.findViewById(R.id.custom); mCustom = (RadioButton)root.findViewById(R.id.custom);
mNone = (RadioButton)root.findViewById(R.id.none);
mPunctuationCharacters = (EditText)root.findViewById(R.id.punctuation_characters); mPunctuationCharacters = (EditText)root.findViewById(R.id.punctuation_characters);
return root; return root;
} }
protected void onBindDialogView(View view) { protected void onBindDialogView(View view) {
super.onBindDialogView(view); super.onBindDialogView(view);


if (mSettings.getPunctuationLevel() == SpeechSynthesis.PUNCT_ALL) {
mAll.toggle();
} else {
mCustom.toggle();
switch (mSettings.getPunctuationLevel()) {
case SpeechSynthesis.PUNCT_ALL:
mAll.toggle();
break;
case SpeechSynthesis.PUNCT_SOME:
mCustom.toggle();
break;
case SpeechSynthesis.PUNCT_NONE:
mNone.toggle();
break;
} }


mPunctuationCharacters.setText(mSettings.getPunctuationCharacters()); mPunctuationCharacters.setText(mSettings.getPunctuationCharacters());
if (text != null) { if (text != null) {
characters = text.toString(); characters = text.toString();
} }
if (characters == null || characters.isEmpty()) {

if (mNone.isChecked()) {
level = SpeechSynthesis.PUNCT_NONE;
} else if (characters == null || characters.isEmpty()) {
level = mAll.isChecked() ? SpeechSynthesis.PUNCT_ALL : SpeechSynthesis.PUNCT_NONE; level = mAll.isChecked() ? SpeechSynthesis.PUNCT_ALL : SpeechSynthesis.PUNCT_NONE;
} else { } else {
level = mAll.isChecked() ? SpeechSynthesis.PUNCT_ALL : SpeechSynthesis.PUNCT_SOME; level = mAll.isChecked() ? SpeechSynthesis.PUNCT_ALL : SpeechSynthesis.PUNCT_SOME;

Loading…
Cancel
Save