X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2FDictionaryActivity.java;h=8590d90fbf7f13103895f305d61ba2f67d3a6e35;hb=6075de7ee940e23133cf187f44a525e19cccf038;hp=ef5a9ccc035104d40bb065a21a42fb9d7c45f548;hpb=0b8b634663df52b47c2e3aeb75960a5a7b58dffe;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index ef5a9cc..8590d90 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -28,7 +28,7 @@ import android.graphics.Typeface; import android.net.Uri; import android.os.Bundle; import android.os.Handler; -import android.preference.PreferenceManager; +import android.support.v7.preference.PreferenceManager; import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech.OnInitListener; import android.support.annotation.NonNull; @@ -880,6 +880,11 @@ public class DictionaryActivity extends AppCompatActivity { updateTTSLanguage(indexIndex); } + @SuppressWarnings("deprecation") + private void speak(String text) { + textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null); + } + private void updateTTSLanguage(int i) { if (!ttsReady || index == null || textToSpeech == null) { Log.d(LOG, "Can't updateTTSLanguage."); @@ -1236,8 +1241,7 @@ public class DictionaryActivity extends AppCompatActivity { speak.setOnMenuItemClickListener(new android.view.MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(android.view.MenuItem item) { - textToSpeech.speak(textToSpeak, TextToSpeech.QUEUE_FLUSH, - new HashMap()); + speak(textToSpeak); return false; } }); @@ -1253,8 +1257,7 @@ public class DictionaryActivity extends AppCompatActivity { String text = ""; for (Pair p : pairs) text += p.get(idx); text = text.replaceAll("\\{[^{}]*\\}", "").replace("{", "").replace("}", ""); - textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, - new HashMap()); + speak(text); return false; } }); @@ -1267,8 +1270,7 @@ public class DictionaryActivity extends AppCompatActivity { String text = ""; for (Pair p : pairs) text += p.get(idx); text = text.replaceAll("\\{[^{}]*\\}", "").replace("{", "").replace("}", ""); - textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, - new HashMap()); + speak(text); return false; } });