Skip to content

Commit

Permalink
Replaced Toast with Snackbar in ReadText.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
Prince-kushwaha authored and mikehardy committed Dec 7, 2023
1 parent 42e1b65 commit 97e77a4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/anki/ReadText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ object ReadText {
// Store weak reference to Activity to prevent memory leak
flashCardViewer = WeakReference(context)
mCompletionListener = listener
val ankiActivityContext = context as? AnkiActivity
// Create new TTS object and setup its onInit Listener
textToSpeech = TextToSpeech(context) { status: Int ->
if (status == TextToSpeech.SUCCESS) {
Expand All @@ -251,7 +252,9 @@ object ReadText {
Timber.d("TTS initialized and available languages found")
(context as AbstractFlashcardViewer).ttsInitialized()
} else {
showThemedToast(context, context.getString(R.string.no_tts_available_message), false)
if (ankiActivityContext != null) {
ankiActivityContext.showSnackbar(R.string.no_tts_available_message)
}
Timber.w("TTS initialized but no available languages found")
}
textToSpeech!!.setOnUtteranceProgressListener(object : UtteranceProgressListener() {
Expand Down Expand Up @@ -286,7 +289,9 @@ object ReadText {
}
}
// Show toast that it's getting initialized, as it can take a while before the sound plays the first time
showThemedToast(context, context.getString(R.string.initializing_tts), false)
if (ankiActivityContext != null) {
ankiActivityContext.showSnackbar(R.string.initializing_tts)
}
}

fun errorToDeveloperString(errorCode: Int): String {
Expand Down

0 comments on commit 97e77a4

Please sign in to comment.