mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[android] fix crash when no TTS engine
Signed-off-by: gekeleda <git@davidgekeler.eu>
This commit is contained in:
@@ -1818,9 +1818,17 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
||||
if (Config.isTtsMessageDelivered())
|
||||
return;
|
||||
|
||||
String languageDisplayName = TtsPlayer.INSTANCE.getLanguageDisplayName();
|
||||
|
||||
if (languageDisplayName != null)
|
||||
{
|
||||
String navigationStartMessage = getResources().getString(R.string.navigation_start_tts_message);
|
||||
navigationStartMessage += TtsPlayer.INSTANCE.getLanguageDisplayName();
|
||||
navigationStartMessage += languageDisplayName;
|
||||
Toast.makeText(this, navigationStartMessage, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
else
|
||||
Toast.makeText(this, getResources().getString(R.string.navigation_start_tts_disabled_message), Toast.LENGTH_LONG)
|
||||
.show();
|
||||
|
||||
Config.setTtsMessageDelivered();
|
||||
}
|
||||
|
||||
@@ -934,6 +934,7 @@
|
||||
<string name="delete_track_dialog_title">Delete %s?</string>
|
||||
<string name="pref_tts_no_system_tts_short">No text-to-speech engine found, check the app settings</string>
|
||||
<string name="navigation_start_tts_message">"Starting Navigation, voice instruction language: "</string>
|
||||
<string name="navigation_start_tts_disabled_message">"Voice instructions disabled: TTS engine not available"</string>
|
||||
<string name="unknown_power_output">unknown</string>
|
||||
<string name="charge_socket_type2">Type 2 (no cable)</string>
|
||||
<string name="charge_socket_type2_cable">Type 2 (w/ cable)</string>
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.speech.tts.TextToSpeech;
|
||||
import android.speech.tts.UtteranceProgressListener;
|
||||
import android.speech.tts.Voice;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -280,13 +281,16 @@ public enum TtsPlayer
|
||||
|
||||
public Locale getVoiceLocale()
|
||||
{
|
||||
return mTts.getVoice().getLocale();
|
||||
if (INSTANCE.mTts == null)
|
||||
return null;
|
||||
Voice voice = INSTANCE.mTts.getVoice();
|
||||
return voice != null ? voice.getLocale() : null;
|
||||
}
|
||||
|
||||
public String getLanguageDisplayName()
|
||||
{
|
||||
Locale locale = getVoiceLocale();
|
||||
return locale.getDisplayName(locale);
|
||||
return locale != null ? locale.getDisplayName(locale) : null;
|
||||
}
|
||||
|
||||
public void speak(String textToSpeak)
|
||||
|
||||
Reference in New Issue
Block a user