From 1ff26348fa11f280fe72105ee754986ee5afb719 Mon Sep 17 00:00:00 2001 From: fyp Date: Fri, 27 Mar 2020 16:20:00 +0800 Subject: [PATCH 1/4] fix bug when language is Chinese or Japanese --- .../main/java/com/henninghall/date_picker/LocaleUtils.java | 5 ++++- android/src/main/java/com/henninghall/date_picker/Utils.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/henninghall/date_picker/LocaleUtils.java b/android/src/main/java/com/henninghall/date_picker/LocaleUtils.java index 48a575b..1585b6b 100644 --- a/android/src/main/java/com/henninghall/date_picker/LocaleUtils.java +++ b/android/src/main/java/com/henninghall/date_picker/LocaleUtils.java @@ -26,7 +26,10 @@ public class LocaleUtils { public static String getDatePattern(Locale locale){ DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, locale); - return ((SimpleDateFormat)df).toLocalizedPattern().replace(",", ""); + return ((SimpleDateFormat) df).toLocalizedPattern() + .replaceAll(",", "") + .replaceAll("([a-zA-Z]+)", " $1") + .trim(); } static String getDateTimePattern(Locale locale){ diff --git a/android/src/main/java/com/henninghall/date_picker/Utils.java b/android/src/main/java/com/henninghall/date_picker/Utils.java index 66d49c9..1e38a7a 100644 --- a/android/src/main/java/com/henninghall/date_picker/Utils.java +++ b/android/src/main/java/com/henninghall/date_picker/Utils.java @@ -62,7 +62,7 @@ public class Utils { } public static ArrayList splitOnSpace(String value){ - String[] array = value.split(" "); + String[] array = value.split("\\s+"); ArrayList arrayList = new ArrayList<>(); Collections.addAll(arrayList, array); return arrayList; From 48718b687d61cb84cea39c855311b31de10273bd Mon Sep 17 00:00:00 2001 From: Henning Hall Date: Tue, 31 Mar 2020 23:01:39 +0200 Subject: [PATCH 2/4] Add tests for display texts in date mode --- examples/detox/e2e/tests/displayText.spec.js | 43 +++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/examples/detox/e2e/tests/displayText.spec.js b/examples/detox/e2e/tests/displayText.spec.js index 5123f61..056d783 100644 --- a/examples/detox/e2e/tests/displayText.spec.js +++ b/examples/detox/e2e/tests/displayText.spec.js @@ -1,4 +1,11 @@ -const { setLocale, expectDateString, scrollWheel } = require('../utils') +const { + setMode, + setLocale, + expectDateString, + scrollWheel, + setMinimumDate, + setMaximumDate, +} = require('../utils') describe('Display text', () => { before(async () => { @@ -32,6 +39,40 @@ describe('Display text', () => { }) }) + describe('date', () => { + before(async () => { + await device.reloadReactNative() + await element(by.text('Advanced')).tap() + await setMinimumDate(undefined) + await setMaximumDate(undefined) + await setMode('date') + }) + + it('en-US', async () => { + await expectLocaleDateString('en-US', 'February' + '1' + '2000') + }) + + it('pt-BR', async () => { + await expectLocaleDateString('pt-BR', '2janeiro' + '2000') + }) + + it('sv-SE', async () => { + await expectLocaleDateString('sv-SE', '2' + 'januari' + '2000') + }) + + it('ko', async () => { + await expectLocaleDateString('ko', '2001년' + '1월' + '1일') + }) + + it('ja', async () => { + await expectLocaleDateString('ja', '2001年' + '1月' + '1日') + }) + + it('zh-CH', async () => { + await expectLocaleDateString('zh-CH', '2001年' + '1月' + '1日') + }) + }) + const expectLocaleDateString = async (locale, dateString) => { await setLocale(locale) await scrollWheel(0, 1) From db77471ad178be6370261ff11b86aa173fe7e063 Mon Sep 17 00:00:00 2001 From: Henning Hall Date: Tue, 31 Mar 2020 23:02:45 +0200 Subject: [PATCH 3/4] Enable test runs on PR:s --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index a6601e1..697cfe8 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,6 +1,6 @@ name: "Android: build & test" -on: [push] +on: [push, pull_request] jobs: build_and_test: From 35f55a0a0f68ff93b9835b1b217860993cdebab1 Mon Sep 17 00:00:00 2001 From: Henning Hall Date: Thu, 2 Apr 2020 20:44:19 +0200 Subject: [PATCH 4/4] Update test: Chinese month name --- examples/detox/e2e/tests/displayText.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/detox/e2e/tests/displayText.spec.js b/examples/detox/e2e/tests/displayText.spec.js index 056d783..78c8e73 100644 --- a/examples/detox/e2e/tests/displayText.spec.js +++ b/examples/detox/e2e/tests/displayText.spec.js @@ -69,7 +69,7 @@ describe('Display text', () => { }) it('zh-CH', async () => { - await expectLocaleDateString('zh-CH', '2001年' + '1月' + '1日') + await expectLocaleDateString('zh-CH', '2001年' + '一月' + '1日') }) })