Fixes a recent acra report where the device locale was not available. This crashes the preferences code because we query the displayName of the locale to determine if the app language is rtl or not:
Caused by: java.lang.StringIndexOutOfBoundsException: length=0; index=0
at java.lang.String.charAt(Native Method)
at com.ichi2.anki.LanguageUtils.appLanguageIsRTL(LanguageUtils.java:46)
at com.ichi2.preferences.HeaderPreference$Companion.buildHeaderSummary(HeaderPreference.kt:69)
at com.ichi2.preferences.HeaderPreference.<init>(HeaderPreference.kt:45)
at com.ichi2.preferences.HeaderPreference.<init>(HeaderPreference.kt:31)
at com.ichi2.preferences.HeaderPreference.<init>(HeaderPreference.kt)
... 35 more
I've modified the problematic method to handle an empty locale.displayName and to default to false(not rtl language) when that happens.
How Has This Been Tested?
Ran the related test, tried using rtl vs non rtl in preferences. I don't know how to test a no locale displayName.
Checklist
[x] You have a descriptive commit message with a short title (first line, max 50 chars).
[x] You have commented your code, particularly in hard-to-understand areas
[x] You have performed a self-review of your own code
[ ] UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
Purpose / Description
Fixes a recent acra report where the device locale was not available. This crashes the preferences code because we query the displayName of the locale to determine if the app language is rtl or not:
I've modified the problematic method to handle an empty locale.displayName and to default to false(not rtl language) when that happens.
How Has This Been Tested?
Ran the related test, tried using rtl vs non rtl in preferences. I don't know how to test a no locale displayName.
Checklist