mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-26 06:21:12 -04:00
Merge pull request #3214 from kiwix/Issue#2065
Fixed read aloud feature on the wiki med offline app
This commit is contained in:
commit
27100c1545
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user