Browse Source

fix: prevent crash/empty wheels at unknown locale (#650)

- prevent empty wheels when unknown locale passed
- support Luxembourgish (lb) locale
master
Henning Hall 2 years ago
committed by GitHub
parent
commit
ed836dd9b0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions
  1. +10
    -0
      .maestro/display-text.yml
  2. +1
    -0
      android/src/main/java/com/henninghall/date_picker/Formats.java
  3. +1
    -1
      android/src/main/java/com/henninghall/date_picker/LocaleUtils.java

+ 10
- 0
.maestro/display-text.yml View File

@ -56,3 +56,13 @@ appId: com.rn069
- assertVisible:
id: dateStringOutput
text: 'CN 2 thg 11200 SA '
# Should be possible to use picker with invalid locale
- runFlow: utils/launch.yml
- runFlow:
file: utils/change-prop.yml
env:
PROP: locale
VALUE: xx
- runFlow: utils/swipe-wheel-1.yml
- assertVisible: '2000-01-02 00:00:00'

+ 1
- 0
android/src/main/java/com/henninghall/date_picker/Formats.java View File

@ -84,6 +84,7 @@ public class Formats {
put("kn", mapOf("EEE, d MMM", "d", "y"));
put("ko", mapOf("MMM d일 EEE", "d일", "y년"));
put("ky", mapOf("d-MMM, EEE", "d", "y"));
put("lb", mapOf("EEE d MMM", "d", "y"));
put("ln", mapOf("EEE d MMM", "d", "y"));
put("lo", mapOf("EEE d MMM", "d", "y"));
put("lt", mapOf("MM-dd, EEE", "dd", "y"));

+ 1
- 1
android/src/main/java/com/henninghall/date_picker/LocaleUtils.java View File

@ -30,7 +30,7 @@ public class LocaleUtils {
try {
String firstPartOfLanguageTag = languageTag.substring(0, languageTag.indexOf("_"));
return Formats.get(firstPartOfLanguageTag, format);
} catch (Formats.FormatNotFoundException ex) {
} catch (Formats.FormatNotFoundException | IndexOutOfBoundsException ex) {
return Formats.defaultFormat.get(format);
}
}

Loading…
Cancel
Save