Skip to content
This repository was archived by the owner on Oct 27, 2025. It is now read-only.

Commit 1269f4e

Browse files
Merge pull request #284 from martenrebane/MOPPAND-933
Fixed accessibility crash on startup
2 parents 88ffb74 + 38f06d0 commit 1269f4e

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

app/src/main/java/ee/ria/DigiDoc/android/main/home/HomeMenuView.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Context;
44
import android.speech.tts.TextToSpeech;
5+
import android.speech.tts.Voice;
56
import android.util.AttributeSet;
67
import android.view.View;
78
import android.view.accessibility.AccessibilityEvent;
@@ -13,6 +14,7 @@
1314
import androidx.core.widget.NestedScrollView;
1415

1516
import java.util.Locale;
17+
import java.util.Set;
1618

1719
import ee.ria.DigiDoc.R;
1820
import ee.ria.DigiDoc.common.TextUtil;
@@ -38,8 +40,16 @@ public final class HomeMenuView extends NestedScrollView {
3840
new TextToSpeech.OnInitListener() {
3941
@Override
4042
public void onInit(int status) {
41-
Locale accessibilityLocale = textToSpeech.getVoice().getLocale();
42-
if (accessibilityLocale.getLanguage().equals("et")) {
43+
Voice textToSpeechVoice = textToSpeech.getVoice();
44+
String language = Locale.getDefault().getLanguage();
45+
boolean isESTLanguageAvailable = isTextToSpeechLanguageAvailable(textToSpeech.getAvailableLanguages(),
46+
Set.of(new Locale("est", "EST"), new Locale("et", "ET")));
47+
if ((textToSpeechVoice == null && isESTLanguageAvailable) ||
48+
(textToSpeechVoice != null &&
49+
textToSpeechVoice.getLocale().getLanguage().equals("et"))) {
50+
language = "et";
51+
}
52+
if (language.equals("et")) {
4353
helpView.setContentDescription(
4454
getResources().getString(R.string.main_home_menu_help) +
4555
" link " +
@@ -114,4 +124,10 @@ public void locale(@Nullable Integer locale) {
114124
public Observable<Integer> localeChecks() {
115125
return checkedChanges(localeView).skipInitialValue();
116126
}
127+
128+
private boolean isTextToSpeechLanguageAvailable(Set<Locale> availableLocales, Set<Locale> locales) {
129+
return locales.stream().anyMatch(lo ->
130+
availableLocales.stream().anyMatch(al -> al.getLanguage().equals(lo.getLanguage()))
131+
);
132+
}
117133
}

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
appVersionCode=39
2-
appVersionName=2.4.5
1+
appVersionCode=40
2+
appVersionName=2.4.6
33

44
appAbiFilters=arm64-v8a;armeabi-v7a;x86;x86_64
55

0 commit comments

Comments
 (0)