1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-24 09:35:50 +01:00

Bangle.js: Fix call notification in Turkish locale

Turns out toUpper/Lowercase use the current locale, so for Turkish, "INCOMING" turns into "ıncomıng" (the 'i' is different!)
This commit is contained in:
Gordon Williams 2024-12-13 11:07:21 +00:00
parent 03eb303181
commit 839cbcd3e5
2 changed files with 7 additions and 6 deletions

View File

@ -12,6 +12,7 @@
* Initial support for Xiaomi Smart Band 9 Pro * Initial support for Xiaomi Smart Band 9 Pro
* Add calories charts and widgets * Add calories charts and widgets
* Add more workout icons * Add more workout icons
* Bangle.js: Fix call notification in Turkish locale
* Casio GBX-100: Fix notification title * Casio GBX-100: Fix notification title
* Colmi R0x: Fix occasional crash on disconnection * Colmi R0x: Fix occasional crash on disconnection
* Fix crash in some chart pages * Fix crash in some chart pages

View File

@ -564,12 +564,12 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
} break; } break;
case "music": { case "music": {
GBDeviceEventMusicControl deviceEventMusicControl = new GBDeviceEventMusicControl(); 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); evaluateGBDeviceEvent(deviceEventMusicControl);
} break; } break;
case "call": { case "call": {
GBDeviceEventCallControl deviceEventCallControl = new GBDeviceEventCallControl(); 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); evaluateGBDeviceEvent(deviceEventCallControl);
} break; } break;
case "status": case "status":
@ -762,7 +762,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
*/ */
private void handleNotificationControl(JSONObject json) throws JSONException { 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); LOG.debug("Notification response: " + response);
// Wake the Android device if the setting is toggled on by user. // 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; ActivityKind activity = ActivityKind.ACTIVITY;
if (json.has("act")) { if (json.has("act")) {
try { try {
String actName = json.optString("act","").toUpperCase(); String actName = json.optString("act","").toUpperCase(Locale.US);
activity = ActivityKind.valueOf(actName); activity = ActivityKind.valueOf(actName);
} catch (final Exception e) { } catch (final Exception e) {
LOG.warn("JSON activity not known", e); LOG.warn("JSON activity not known", e);
@ -888,7 +888,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
int method = Request.Method.GET; int method = Request.Method.GET;
if (json.has("method")) { 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; if (m.equals("get")) method = Request.Method.GET;
else if (m.equals("post")) method = Request.Method.POST; else if (m.equals("post")) method = Request.Method.POST;
else if (m.equals("head")) method = Request.Method.HEAD; else if (m.equals("head")) method = Request.Method.HEAD;
@ -1579,7 +1579,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
Field[] fields = callSpec.getClass().getDeclaredFields(); Field[] fields = callSpec.getClass().getDeclaredFields();
for (Field field : fields) for (Field field : fields)
if (field.getName().startsWith("CALL_") && field.getInt(callSpec) == callSpec.command) 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) {} } catch (IllegalAccessException e) {}
o.put("cmd", cmdName); o.put("cmd", cmdName);
o.put("name", renderUnicodeAsImage(callSpec.name)); o.put("name", renderUnicodeAsImage(callSpec.name));