From 6075de7ee940e23133cf187f44a525e19cccf038 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Reimar=20D=C3=B6ffinger?= Date: Fri, 1 May 2020 13:28:24 +0200 Subject: [PATCH] Avoid deprecation warnings. --- .../hughes/android/dictionary/AboutActivity.java | 1 + .../android/dictionary/DictionaryActivity.java | 14 ++++++++------ src/com/hughes/android/dictionary/MyWebView.java | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/com/hughes/android/dictionary/AboutActivity.java b/src/com/hughes/android/dictionary/AboutActivity.java index 2f1ee13..91c3430 100644 --- a/src/com/hughes/android/dictionary/AboutActivity.java +++ b/src/com/hughes/android/dictionary/AboutActivity.java @@ -24,6 +24,7 @@ public final class AboutActivity extends Activity { /** Called when the activity is first created. */ @Override + @SuppressWarnings("deprecation") public void onCreate(final Bundle savedInstanceState) { DictionaryApplication.INSTANCE.init(getApplicationContext()); setTheme(DictionaryApplication.INSTANCE.getSelectedTheme().themeId); diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index e2558a0..8590d90 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -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; } }); diff --git a/src/com/hughes/android/dictionary/MyWebView.java b/src/com/hughes/android/dictionary/MyWebView.java index d57ad0b..028ddbc 100644 --- a/src/com/hughes/android/dictionary/MyWebView.java +++ b/src/com/hughes/android/dictionary/MyWebView.java @@ -42,6 +42,7 @@ public class MyWebView extends WebView { final WebViewClient webViewClient = new WebViewClient() { @Override + @SuppressWarnings("deprecation") public boolean shouldOverrideUrlLoading(WebView view, String url) { if (HtmlEntry.isQuickdicUrl(url)) { Log.d(LOG, "Handling Quickdic URL: " + url); -- 2.43.0