Merge pull request #3214 from kiwix/Issue#2065

Fixed read aloud feature on the wiki med offline app
This commit is contained in:
Kelson 2023-01-28 14:55:24 +01:00 committed by GitHub
commit 27100c1545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 1 deletions

View File

@ -117,7 +117,8 @@ class KiwixTextToSpeech internal constructor(
} else {
tts.language = locale
if (getFeatures(tts).contains(Engine.KEY_FEATURE_NOT_INSTALLED)) {
context.toast(R.string.tts_lang_not_supported, Toast.LENGTH_LONG)
val activity = context as CoreMainActivity?
activity?.externalLinkOpener?.showTTSLanguageDownloadDialog()
} else if (requestAudioFocus()) {
loadURL(webView)
}

View File

@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.core.utils
import android.app.Activity
import android.content.Intent
import android.speech.tts.TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.extensions.toast
import org.kiwix.kiwixmobile.core.utils.dialog.AlertDialogShower
@ -61,4 +62,17 @@ class ExternalLinkOpener @Inject constructor(
}
)
}
fun showTTSLanguageDownloadDialog() {
alertDialogShower.show(
KiwixDialog.DownloadTTSLanguage,
{
activity.startActivity(
Intent().apply {
action = ACTION_INSTALL_TTS_DATA
}
)
}
)
}
}

View File

@ -221,6 +221,13 @@ sealed class KiwixDialog(
android.R.string.cancel
)
object DownloadTTSLanguage : KiwixDialog(
R.string.download_tts_language_title,
R.string.download_tts_language_message,
R.string.download,
android.R.string.cancel
)
open class YesNoDialog(
title: Int?,
message: Int

View File

@ -323,4 +323,6 @@
<string name="open_article">Open Article</string>
<string name="delete_note_dialog_message">Note: Notes are not deleted from your storage</string>
<string name="delete_selected_notes">Delete Selected Notes?</string>
<string name="download_tts_language_title">Download this language for read aloud feature</string>
<string name="download_tts_language_message">Please click download button it will automatically download the required language.</string>
</resources>