From a9a80afcae04b5b821a264a832a97c1c4e167e74 Mon Sep 17 00:00:00 2001 From: mikunimaru <43168745+mikunimaru@users.noreply.github.com> Date: Wed, 7 Jul 2021 21:01:37 +0900 Subject: [PATCH] Improved JavaScript TTS initialization process Fixed a problem that null may be passed as an argument when initializing JavaScriptTTS. Changed to refer to context from within the class instead of the argument when initializing JavaScriptTTS. --- .../src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java | 2 +- AnkiDroid/src/main/java/com/ichi2/anki/JavaScriptTTS.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java index 6948ee0d5f06..04d717c8c8b7 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java +++ b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java @@ -393,7 +393,7 @@ public abstract class AbstractFlashcardViewer extends NavigationDrawerActivity i private boolean mFocusTypeAnswer; /** Text to speech */ - private JavaScriptTTS mTalker = new JavaScriptTTS(AbstractFlashcardViewer.this); + private JavaScriptTTS mTalker = new JavaScriptTTS(); // ---------------------------------------------------------------------------- // LISTENERS diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/JavaScriptTTS.java b/AnkiDroid/src/main/java/com/ichi2/anki/JavaScriptTTS.java index 5bcc70cbc63a..63f0322eb936 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/JavaScriptTTS.java +++ b/AnkiDroid/src/main/java/com/ichi2/anki/JavaScriptTTS.java @@ -38,7 +38,8 @@ public class JavaScriptTTS implements TextToSpeech.OnInitListener { private static boolean mTtsOk; private static final Bundle mTtsParams = new Bundle(); - JavaScriptTTS(Context context) { + JavaScriptTTS() { + Context mContext = AnkiDroidApp.getInstance().getApplicationContext(); mTts = new TextToSpeech(context, this); }