From 5a87f1452b9c7ec2dce8896d5f72c5d2f093475d Mon Sep 17 00:00:00 2001 From: oliexdev Date: Tue, 5 Aug 2025 17:54:50 +0200 Subject: [PATCH] Add new Bluetooth string resources and use them --- .../scalesJava/BluetoothBeurerSanitas.java | 8 ++++---- .../scalesJava/BluetoothCommunication.java | 2 +- .../scalesJava/BluetoothHoffenBBS8107.java | 2 +- .../bluetooth/scalesJava/BluetoothInlife.java | 2 +- .../bluetooth/scalesJava/BluetoothSenssun.java | 2 +- .../bluetooth/scalesJava/BluetoothSoehnle.java | 4 ++-- .../BluetoothStandardWeightProfile.java | 16 ++++++++-------- .../scalesJava/BluetoothTrisaBodyAnalyze.java | 4 ++-- .../app/src/main/res/values-de/strings.xml | 9 +++++++++ android_app/app/src/main/res/values/strings.xml | 10 ++++++++++ 10 files changed, 39 insertions(+), 20 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothBeurerSanitas.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothBeurerSanitas.java index fb1d1676..834ca865 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothBeurerSanitas.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothBeurerSanitas.java @@ -540,7 +540,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication { if (!stableMeasurement) { LogManager.d(TAG, String.format("Active measurement, weight: %.2f", weight)); - //TODO sendMessage(R.string.info_measuring, weight); + sendMessage(R.string.bluetooth_scale_info_measuring_weight, weight); return; } @@ -636,7 +636,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication { userReferWeightExists, userMeasurementExist, scaleVersion)); if (batteryLevel <= 10) { - //TODO sendMessage(R.string.info_scale_low_battery, batteryLevel); + sendMessage(R.string.bluetooth_scale_warning_low_battery, batteryLevel); } byte requestedUnit = (byte) currentUnit; @@ -819,7 +819,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication { // Try to start a measurement to make the scale learn the reference weight to recognize the user next time. // If we already have data, this will most likely run into time-out and the scale switches off before finishing. LogManager.d(TAG, "New user successfully added; time to step on scale"); - //TODO sendMessage(R.string.info_step_on_scale_for_reference, 0); + sendMessage(R.string.bluetooth_scale_info_step_on_for_reference, 0); LogManager.d(TAG, "Sending command: CMD_DO_MEASUREMENT"); sendCommand(CMD_DO_MEASUREMENT, encodeUserId(currentRemoteUser)); // We send a new command, so make sure we wait @@ -828,7 +828,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication { } LogManager.d(TAG, String.format("Cannot create additional scale user (error 0x%02x)", data[3])); - //TODO sendMessage(R.string.error_max_scale_users, 0); + sendMessage(R.string.bluetooth_scale_error_max_users_reached, 0); // Force disconnect LogManager.d(TAG, "Terminating state machine."); jumpNextToStepNr( 9 ); diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothCommunication.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothCommunication.java index 982fbb6e..95fad6e8 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothCommunication.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothCommunication.java @@ -192,7 +192,7 @@ public abstract class BluetoothCommunication { * @param msg the string id to be send * @param value the value to be used */ - protected void sendMessage(int msg, Object value) { + protected void sendMessage(int msg, Object value) { // TODO implement in openScale 3.0 if (callbackBtHandler != null) { callbackBtHandler.obtainMessage( BT_STATUS.SCALE_MESSAGE.ordinal(), msg, 0, value).sendToTarget(); diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothHoffenBBS8107.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothHoffenBBS8107.java index ce84c2a6..9f6aa041 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothHoffenBBS8107.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothHoffenBBS8107.java @@ -166,7 +166,7 @@ public class BluetoothHoffenBBS8107 extends BluetoothCommunication { private ScaleMeasurement parseFinalMeasurement(byte[] value) { float weight = Converters.fromUnsignedInt16Le(value, 3) / 10.0f; LogManager.d(TAG, String.format("Got final weight: %.1f %s", weight, user.getScaleUnit().toString())); - // TODO sendMessage(R.string.info_measuring, weight); + sendMessage(R.string.bluetooth_scale_info_measuring_weight, weight); if (user.getScaleUnit() != WeightUnit.KG) { // For lb and st this scale will always return result in lb diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothInlife.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothInlife.java index c878958f..b15de4e8 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothInlife.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothInlife.java @@ -128,7 +128,7 @@ public class BluetoothInlife extends BluetoothCommunication { case (byte) 0xd8: float weight = Converters.fromUnsignedInt16Be(data, 2) / 10.0f; LogManager.d(TAG, String.format("Current weight %.2f kg", weight)); - //TODO sendMessage(R.string.info_measuring, weight); + sendMessage(R.string.bluetooth_scale_info_measuring_weight, weight); break; case (byte) 0xdd: if (data[11] == (byte) 0x80 || data[11] == (byte) 0x81) { diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothSenssun.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothSenssun.java index 945026c7..b43ea97f 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothSenssun.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothSenssun.java @@ -128,7 +128,7 @@ public class BluetoothSenssun extends BluetoothCommunication { if (weightStabilized) { values |= 1; - //TODO sendMessage(R.string.info_measuring, lastWeight / 10.0f); + sendMessage(R.string.bluetooth_scale_info_measuring_weight, lastWeight / 10.0f); synchroniseUser(); } break; diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothSoehnle.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothSoehnle.java index b8134829..b29c0ab4 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothSoehnle.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothSoehnle.java @@ -152,7 +152,7 @@ public class BluetoothSoehnle extends BluetoothCommunication { LogManager.d(TAG, "Soehnle scale battery level is " + batteryLevel); if (batteryLevel <= 10) { - //TODO sendMessage(R.string.info_scale_low_battery, batteryLevel); + sendMessage(R.string.bluetooth_scale_warning_low_battery, batteryLevel); } } } @@ -170,7 +170,7 @@ public class BluetoothSoehnle extends BluetoothCommunication { LogManager.d(TAG, "User control point index is " + soehnleUserIndex + " for user id " + userId); prefs.edit().putInt("userScaleIndex" + soehnleUserIndex, userId).apply(); - //TODO sendMessage(R.string.info_step_on_scale_for_reference, 0); + sendMessage(R.string.bluetooth_scale_info_step_on_for_reference, 0); } else { LogManager.e(TAG, "Error creating new Sohnle user", null); } diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothStandardWeightProfile.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothStandardWeightProfile.java index 50bfcd13..8c18132a 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothStandardWeightProfile.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothStandardWeightProfile.java @@ -204,7 +204,7 @@ public abstract class BluetoothStandardWeightProfile extends BluetoothCommunicat if (registerNewUser) { requestMeasurement(); stopMachineState(); - // TODO sendMessage(R.string.info_step_on_scale_for_reference, 0); + sendMessage(R.string.bluetooth_scale_info_step_on_for_reference, 0); } break; default: @@ -241,7 +241,7 @@ public abstract class BluetoothStandardWeightProfile extends BluetoothCommunicat int batteryLevel = parser.getIntValue(FORMAT_UINT8); LogManager.d(TAG, String.format("Received battery level %d%%", batteryLevel)); if (batteryLevel <= 10) { - // TODO sendMessage(R.string.info_scale_low_battery, batteryLevel); + sendMessage(R.string.bluetooth_scale_warning_low_battery, batteryLevel); } } else if(characteristic.equals(BluetoothGattUuid.CHARACTERISTIC_MANUFACTURER_NAME_STRING)) { @@ -829,15 +829,15 @@ public abstract class BluetoothStandardWeightProfile extends BluetoothCommunicat for (int i = 0; i < userList.size(); ++i) { ScaleUser u = userList.get(i); String name = u.getUserName(); - /* TODO choiceStrings[i] = (name.length() > 0 ? name : String.format("P%02d", u.getId())) - + " " + context.getString(u.getGender().isMale() ? R.string.label_male : R.string.label_female).toLowerCase() - + " " + context.getString(R.string.label_height).toLowerCase() + ":" + u.getBodyHeight() - + " " + context.getString(R.string.label_birthday).toLowerCase() + ":" + dateFormat.format(u.getBirthday()) - + " " + context.getString(R.string.label_activity_level).toLowerCase() + ":" + (u.getActivityLevel().toInt() + 1);*/ + choiceStrings[i] = (name.length() > 0 ? name : String.format("P%02d", u.getId())) + + " " + (u.getGender().isMale() ? "male" : "female").toLowerCase() + + " " + "height" + ":" + u.getBodyHeight() + + " " + "birthday" + ":" + dateFormat.format(u.getBirthday()) + + " " + "activityLevel" + ":" + (u.getActivityLevel().toInt() + 1); indexArray[i] = u.getId(); } if (userList.size() < getVendorSpecificMaxUserCount()) { - // TODO choiceStrings[userList.size()] = context.getString(R.string.info_create_new_user_on_scale); + choiceStrings[userList.size()] = context.getString(R.string.bluetooth_scale_info_create_user_instruction); indexArray[userList.size()] = -1; } Pair choices = new Pair(choiceStrings, indexArray); diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothTrisaBodyAnalyze.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothTrisaBodyAnalyze.java index ab0c6252..e5224fb0 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothTrisaBodyAnalyze.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/scalesJava/BluetoothTrisaBodyAnalyze.java @@ -193,7 +193,7 @@ public class BluetoothTrisaBodyAnalyze extends BluetoothCommunication { saveDevicePassword(context, deviceId, password); } - // TODO sendMessage(R.string.trisa_scale_pairing_succeeded, null); + sendMessage(R.string.bluetooth_scale_trisa_success_pairing, null); // To complete the pairing process, we must set the scale's broadcast id, and then // disconnect. The writeCommand() call below will trigger the next state machine transition, @@ -209,7 +209,7 @@ public class BluetoothTrisaBodyAnalyze extends BluetoothCommunication { } if (password == null) { LogManager.w(TAG, "Received challenge, but password is unknown.", null); - // TODO sendMessage(R.string.trisa_scale_not_paired, null); + sendMessage(R.string.bluetooth_scale_trisa_message_not_paired_instruction, null); disconnect(); return; } diff --git a/android_app/app/src/main/res/values-de/strings.xml b/android_app/app/src/main/res/values-de/strings.xml index a22d5dbe..02a17dfc 100644 --- a/android_app/app/src/main/res/values-de/strings.xml +++ b/android_app/app/src/main/res/values-de/strings.xml @@ -363,4 +363,13 @@ Gesamte Datenbank wurde gelöscht. Fehler beim Löschen der gesamten Datenbank. + + + Diese Waage wurde nicht gekoppelt!\n\nHalten Sie die Taste an der Unterseite der Waage gedrückt, um sie in den Kopplungsmodus zu versetzen, und verbinden Sie sich dann erneut, um das Gerätepasswort abzurufen. + Kopplung erfolgreich!\n\nVerbinden Sie sich erneut, um Messdaten abzurufen. + Neuen Benutzer auf der Waage erstellen. + Niedriger Batteriestand (%d%%), bitte Batterien der Waage aufladen oder ersetzen. + Bitte stellen Sie sich barfuß auf die Waage für Referenzmessungen. + Gewichtsmessung: %.2f + Maximale Anzahl gleichzeitiger Waagenbenutzer erreicht. diff --git a/android_app/app/src/main/res/values/strings.xml b/android_app/app/src/main/res/values/strings.xml index d726ca1d..3acc80b2 100644 --- a/android_app/app/src/main/res/values/strings.xml +++ b/android_app/app/src/main/res/values/strings.xml @@ -364,4 +364,14 @@ Entire database has been deleted. Error deleting entire database. + + + This scale has not been paired!\n\nHold the button on the bottom of the scale to switch it to pairing mode, and then reconnect to retrieve the device password. + Pairing succeeded!\n\nReconnect to retrieve measurement data. + Create new user on scale. + Low battery level (%d%%), please recharge or replace scale batteries + Please step barefoot on the scale for reference measurements + Measuring weight: %.2f + Max. number of concurrent scale users reached +