From 36c304a64bef175ae05122fc2dab7b07377a3c92 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Sat, 21 Jan 2023 18:07:05 +0530 Subject: [PATCH] Improved code and optimized imports --- .../java/org/kiwix/kiwixmobile/core/main/KiwixTextToSpeech.kt | 3 ++- .../org/kiwix/kiwixmobile/core/utils/ExternalLinkOpener.kt | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/KiwixTextToSpeech.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/KiwixTextToSpeech.kt index 4ed7a9538..3a4608809 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/KiwixTextToSpeech.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/KiwixTextToSpeech.kt @@ -117,7 +117,8 @@ class KiwixTextToSpeech internal constructor( } else { tts.language = locale if (getFeatures(tts).contains(Engine.KEY_FEATURE_NOT_INSTALLED)) { - (context as CoreMainActivity).externalLinkOpener.showTTSLanguageDownloadDialog() + val activity = context as CoreMainActivity? + activity?.externalLinkOpener?.showTTSLanguageDownloadDialog() } else if (requestAudioFocus()) { loadURL(webView) } diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ExternalLinkOpener.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ExternalLinkOpener.kt index 72ee10c47..028f02c1a 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ExternalLinkOpener.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ExternalLinkOpener.kt @@ -20,7 +20,7 @@ package org.kiwix.kiwixmobile.core.utils import android.app.Activity import android.content.Intent -import android.speech.tts.TextToSpeech +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 @@ -69,7 +69,7 @@ class ExternalLinkOpener @Inject constructor( { activity.startActivity( Intent().apply { - action = TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA + action = ACTION_INSTALL_TTS_DATA } ) }