From 839cbcd3e5e1d32184740e4d1c2795635675fdbe Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 13 Dec 2024 11:07:21 +0000 Subject: [PATCH] Bangle.js: Fix call notification in Turkish locale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turns out toUpper/Lowercase use the current locale, so for Turkish, "INCOMING" turns into "ıncomıng" (the 'i' is different!) --- CHANGELOG.md | 1 + .../devices/banglejs/BangleJSDeviceSupport.java | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64592a153..3fda31df9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Initial support for Xiaomi Smart Band 9 Pro * Add calories charts and widgets * Add more workout icons +* Bangle.js: Fix call notification in Turkish locale * Casio GBX-100: Fix notification title * Colmi R0x: Fix occasional crash on disconnection * Fix crash in some chart pages diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java index dbd5eeae1..7acfa199e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSDeviceSupport.java @@ -564,12 +564,12 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { } break; case "music": { GBDeviceEventMusicControl deviceEventMusicControl = new GBDeviceEventMusicControl(); - deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.valueOf(json.getString("n").toUpperCase()); + deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.valueOf(json.getString("n").toUpperCase(Locale.US)); evaluateGBDeviceEvent(deviceEventMusicControl); } break; case "call": { GBDeviceEventCallControl deviceEventCallControl = new GBDeviceEventCallControl(); - deviceEventCallControl.event = GBDeviceEventCallControl.Event.valueOf(json.getString("n").toUpperCase()); + deviceEventCallControl.event = GBDeviceEventCallControl.Event.valueOf(json.getString("n").toUpperCase(Locale.US)); evaluateGBDeviceEvent(deviceEventCallControl); } break; case "status": @@ -762,7 +762,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { */ private void handleNotificationControl(JSONObject json) throws JSONException { - String response = json.getString("n").toUpperCase(); + String response = json.getString("n").toUpperCase(Locale.US); LOG.debug("Notification response: " + response); // Wake the Android device if the setting is toggled on by user. @@ -825,7 +825,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { ActivityKind activity = ActivityKind.ACTIVITY; if (json.has("act")) { try { - String actName = json.optString("act","").toUpperCase(); + String actName = json.optString("act","").toUpperCase(Locale.US); activity = ActivityKind.valueOf(actName); } catch (final Exception e) { LOG.warn("JSON activity not known", e); @@ -888,7 +888,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { int method = Request.Method.GET; if (json.has("method")) { - String m = json.getString("method").toLowerCase(); + String m = json.getString("method").toLowerCase(Locale.US); if (m.equals("get")) method = Request.Method.GET; else if (m.equals("post")) method = Request.Method.POST; else if (m.equals("head")) method = Request.Method.HEAD; @@ -1579,7 +1579,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport { Field[] fields = callSpec.getClass().getDeclaredFields(); for (Field field : fields) if (field.getName().startsWith("CALL_") && field.getInt(callSpec) == callSpec.command) - cmdName = field.getName().substring(5).toLowerCase(); + cmdName = field.getName().substring(5).toLowerCase(Locale.US); } catch (IllegalAccessException e) {} o.put("cmd", cmdName); o.put("name", renderUnicodeAsImage(callSpec.name));