From 06559e07fe872c8db3cc3f31cd94cdd0a8e38119 Mon Sep 17 00:00:00 2001 From: GitHub Action <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Nov 2023 16:18:21 +0000 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=8F=81=20Releasing=20version=201.7.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phonenumberfx-demo/pom.xml | 6 +++--- phonenumberfx/pom.xml | 4 ++-- pom.xml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phonenumberfx-demo/pom.xml b/phonenumberfx-demo/pom.xml index d61d6bc..ad149a0 100644 --- a/phonenumberfx-demo/pom.xml +++ b/phonenumberfx-demo/pom.xml @@ -6,12 +6,12 @@ PhoneNumberFXDemo - 1.6.0 + 1.7.0 com.dlsc.phonenumberfx parent - 1.6.0 + 1.7.0 ../pom.xml @@ -141,7 +141,7 @@ com.dlsc.phonenumberfx phonenumberfx - 1.6.0 + 1.7.0 commons-logging diff --git a/phonenumberfx/pom.xml b/phonenumberfx/pom.xml index 619edba..8f0df18 100644 --- a/phonenumberfx/pom.xml +++ b/phonenumberfx/pom.xml @@ -7,13 +7,13 @@ com.dlsc.phonenumberfx parent - 1.6.0 + 1.7.0 ../pom.xml com.dlsc.phonenumberfx phonenumberfx - 1.6.0 + 1.7.0 jar PhoneNumberFX diff --git a/pom.xml b/pom.xml index 4e2e793..b055601 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ PhoneNumberFXParent com.dlsc.phonenumberfx parent - 1.6.0 + 1.7.0 pom From d30f2bd93505a63e9cacd97fc225cdf4c514d3ee Mon Sep 17 00:00:00 2001 From: GitHub Action <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 28 Nov 2023 14:10:13 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=8F=81=20Releasing=20version=201.8.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phonenumberfx-demo/pom.xml | 6 +++--- phonenumberfx/pom.xml | 4 ++-- pom.xml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phonenumberfx-demo/pom.xml b/phonenumberfx-demo/pom.xml index ad149a0..e800e72 100644 --- a/phonenumberfx-demo/pom.xml +++ b/phonenumberfx-demo/pom.xml @@ -6,12 +6,12 @@ PhoneNumberFXDemo - 1.7.0 + 1.8.0 com.dlsc.phonenumberfx parent - 1.7.0 + 1.8.0 ../pom.xml @@ -141,7 +141,7 @@ com.dlsc.phonenumberfx phonenumberfx - 1.7.0 + 1.8.0 commons-logging diff --git a/phonenumberfx/pom.xml b/phonenumberfx/pom.xml index 8f0df18..779512e 100644 --- a/phonenumberfx/pom.xml +++ b/phonenumberfx/pom.xml @@ -7,13 +7,13 @@ com.dlsc.phonenumberfx parent - 1.7.0 + 1.8.0 ../pom.xml com.dlsc.phonenumberfx phonenumberfx - 1.7.0 + 1.8.0 jar PhoneNumberFX diff --git a/pom.xml b/pom.xml index 8e1a34d..66b6130 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ PhoneNumberFXParent com.dlsc.phonenumberfx parent - 1.7.0 + 1.8.0 pom From e325ab435a19a67a1d3556da80ed9a778a31e5e2 Mon Sep 17 00:00:00 2001 From: GitHub Action <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 28 Nov 2023 14:13:57 +0000 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=8F=81=20Releasing=20version=201.9.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phonenumberfx-demo/pom.xml | 6 +++--- phonenumberfx/pom.xml | 4 ++-- pom.xml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phonenumberfx-demo/pom.xml b/phonenumberfx-demo/pom.xml index e800e72..e5591c4 100644 --- a/phonenumberfx-demo/pom.xml +++ b/phonenumberfx-demo/pom.xml @@ -6,12 +6,12 @@ PhoneNumberFXDemo - 1.8.0 + 1.9.0 com.dlsc.phonenumberfx parent - 1.8.0 + 1.9.0 ../pom.xml @@ -141,7 +141,7 @@ com.dlsc.phonenumberfx phonenumberfx - 1.8.0 + 1.9.0 commons-logging diff --git a/phonenumberfx/pom.xml b/phonenumberfx/pom.xml index 779512e..b224bf5 100644 --- a/phonenumberfx/pom.xml +++ b/phonenumberfx/pom.xml @@ -7,13 +7,13 @@ com.dlsc.phonenumberfx parent - 1.8.0 + 1.9.0 ../pom.xml com.dlsc.phonenumberfx phonenumberfx - 1.8.0 + 1.9.0 jar PhoneNumberFX diff --git a/pom.xml b/pom.xml index 66b6130..2f90fd8 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ PhoneNumberFXParent com.dlsc.phonenumberfx parent - 1.8.0 + 1.9.0 pom From fae015a2e70775049b279b5e01e664ec640ba273 Mon Sep 17 00:00:00 2001 From: Dirk Lemmermann Date: Fri, 1 Dec 2023 12:12:16 +0100 Subject: [PATCH 4/6] Add safeguard against direct calls to setText method Introduced a flag, updatingText, to prevent unnecessary actions when the setText() call is not made from the setRawPhoneNumber() function. Updated textProperty().addListener to check if setText() is called indirectly or directly to avoid overwriting the raw phone number. The flag manages this condition, it's set to true before making changes to avoid reverting them. It's reset back to false in the finally block after changes are made, ready for the next call. --- .../com/dlsc/phonenumberfx/PhoneNumberLabel.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/phonenumberfx/src/main/java/com/dlsc/phonenumberfx/PhoneNumberLabel.java b/phonenumberfx/src/main/java/com/dlsc/phonenumberfx/PhoneNumberLabel.java index b32c3f2..334d70f 100644 --- a/phonenumberfx/src/main/java/com/dlsc/phonenumberfx/PhoneNumberLabel.java +++ b/phonenumberfx/src/main/java/com/dlsc/phonenumberfx/PhoneNumberLabel.java @@ -32,6 +32,8 @@ public class PhoneNumberLabel extends Label { private final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); + private boolean updatingText; + /** * Builds a new phone number field with the default settings. The available country * calling codes are defined on {@link Country}. @@ -42,8 +44,18 @@ public PhoneNumberLabel() { validProperty().addListener((obs, oldV, newV) -> pseudoClassStateChanged(INVALID_PSEUDO_CLASS, !newV)); + textProperty().addListener(it -> { + if (!updatingText) { + // somebody called setText(...) instead of setRawPhoneNumber(...) + setRawPhoneNumber(getText()); + } + }); + rawPhoneNumber.addListener((obs, oldRawPhoneNumber, newRawPhoneNumber) -> { + updatingText = true; + errorType.set(null); + try { Phonenumber.PhoneNumber phoneNumber; @@ -94,6 +106,8 @@ public PhoneNumberLabel() { nationalPhoneNumber.set(""); setText(newRawPhoneNumber); setValid(false); + } finally { + updatingText = false; } }); From 1ddc447f01cef017b72716509eec90505f9636d6 Mon Sep 17 00:00:00 2001 From: Dirk Lemmermann Date: Fri, 1 Dec 2023 12:30:46 +0100 Subject: [PATCH 5/6] Added comment related to running the formatting code with Platform.runLater(). --- .../src/main/java/com/dlsc/phonenumberfx/PhoneNumberField.java | 1 + 1 file changed, 1 insertion(+) diff --git a/phonenumberfx/src/main/java/com/dlsc/phonenumberfx/PhoneNumberField.java b/phonenumberfx/src/main/java/com/dlsc/phonenumberfx/PhoneNumberField.java index 3c02a1c..320aaa7 100644 --- a/phonenumberfx/src/main/java/com/dlsc/phonenumberfx/PhoneNumberField.java +++ b/phonenumberfx/src/main/java/com/dlsc/phonenumberfx/PhoneNumberField.java @@ -189,6 +189,7 @@ protected void layoutChildren(double x, double y, double w, double h) { } }); + // Platform.runLater() is important or formatting will not work ChangeListener updateFormattedPhoneNumberListener = (obs, oldV, newV) -> Platform.runLater(() -> formatter.setFormattedPhoneNumber(getRawPhoneNumber())); rawPhoneNumberProperty().addListener(updateFormattedPhoneNumberListener); countryCodeVisibleProperty().addListener(updateFormattedPhoneNumberListener); From e7723be76aa4224baba6936f3884ae091344d96e Mon Sep 17 00:00:00 2001 From: Dirk Lemmermann Date: Fri, 1 Dec 2023 12:31:21 +0100 Subject: [PATCH 6/6] Created directory for unit test. --- .../dlsc/phonenumberfx/PhoneNumberFieldTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 phonenumberfx/src/main/test/com/dlsc/phonenumberfx/PhoneNumberFieldTest.java diff --git a/phonenumberfx/src/main/test/com/dlsc/phonenumberfx/PhoneNumberFieldTest.java b/phonenumberfx/src/main/test/com/dlsc/phonenumberfx/PhoneNumberFieldTest.java new file mode 100644 index 0000000..2c64f92 --- /dev/null +++ b/phonenumberfx/src/main/test/com/dlsc/phonenumberfx/PhoneNumberFieldTest.java @@ -0,0 +1,15 @@ +package com.dlsc.phonenumberfx; + +import org.junit.Before; +import org.junit.Test; + +public class PhoneNumberFieldTest { + + @Before + public void setup() { + } + + @Test + public void shouldDoThis() { + } +}