Skip to content

Commit f8f8669

Browse files
committed
Revert "Support for nameless OKOK scales (Myria MY4836) (#1081)"
This reverts commit 29dd632.
1 parent 29dd632 commit f8f8669

File tree

4 files changed

+7
-208
lines changed

4 files changed

+7
-208
lines changed

android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothFactory.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static BluetoothCommunication createDeviceDriver(Context context, String
8282
if (name.equals("Health Scale".toLowerCase(Locale.US))) {
8383
return new BluetoothOneByone(context);
8484
}
85-
if(name.equals("1byone scale".toLowerCase(Locale.US))) {
85+
if(name.equals("1byone scale".toLowerCase(Locale.US))){
8686
return new BluetoothOneByoneNew(context);
8787
}
8888

@@ -114,13 +114,10 @@ public static BluetoothCommunication createDeviceDriver(Context context, String
114114
}
115115
if (deviceName.equals("Hoffen BS-8107")) {
116116
return new BluetoothHoffenBBS8107(context);
117-
}
117+
}
118118
if (deviceName.equals("ADV") || deviceName.equals("Chipsea-BLE")) {
119119
return new BluetoothOKOK(context);
120120
}
121-
if (deviceName.isEmpty()) {
122-
return new BluetoothOKOK2(context);
123-
}
124121
if (deviceName.equals("BF105") || deviceName.equals("BF720")) {
125122
return new BluetoothBeurerBF105(context);
126123
}
@@ -133,10 +130,10 @@ public static BluetoothCommunication createDeviceDriver(Context context, String
133130
if (deviceName.equals("SBF72") || deviceName.equals("BF915") || deviceName.equals("SBF73")) {
134131
return new BluetoothSanitasSBF72(context, deviceName);
135132
}
136-
if (deviceName.equals("Weight Scale")) {
133+
if (deviceName.equals("Weight Scale")){
137134
return new BluetoothSinocare(context);
138135
}
139-
if (deviceName.equals("CH100")) {
136+
if (deviceName.equals("CH100")){
140137
return new BluetoothHuaweiAH100(context);
141138
}
142139
if (deviceName.equals("ES-26BB-B")){
@@ -145,7 +142,7 @@ public static BluetoothCommunication createDeviceDriver(Context context, String
145142
if (deviceName.equals("Yoda1")){
146143
return new BluetoothYoda1Scale(context);
147144
}
148-
if (deviceName.equals("AAA002") || deviceName.equals("AAA007")) {
145+
if (deviceName.equals("AAA002") || deviceName.equals("AAA007")){
149146
return new BluetoothBroadcastScale(context);
150147
}
151148
return null;

android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothOKOK2.java

-189
This file was deleted.

android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothPreferences.java

-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import android.content.SharedPreferences;
1919
import android.os.Bundle;
20-
import android.text.TextUtils;
2120
import android.view.LayoutInflater;
2221
import android.view.Menu;
2322
import android.view.MenuInflater;
@@ -42,9 +41,6 @@ public class BluetoothPreferences extends PreferenceFragmentCompat {
4241
private Preference btScanner;
4342

4443
private static final String formatDeviceName(String name, String address) {
45-
if (TextUtils.isEmpty(name) && !address.isEmpty()) {
46-
return String.format("[%s]", address);
47-
}
4844
if (name.isEmpty() || address.isEmpty()) {
4945
return "-";
5046
}

android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import android.provider.Settings;
4343
import android.text.SpannableStringBuilder;
4444
import android.text.Spanned;
45-
import android.text.TextUtils;
4645
import android.text.style.ForegroundColorSpan;
4746
import android.text.style.RelativeSizeSpan;
4847
import android.view.Gravity;
@@ -229,9 +228,6 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
229228
}
230229

231230
private static final String formatDeviceName(String name, String address) {
232-
if (TextUtils.isEmpty(name) && !address.isEmpty()) {
233-
return String.format("[%s]", address);
234-
}
235231
if (name.isEmpty() || address.isEmpty()) {
236232
return "-";
237233
}
@@ -318,15 +314,14 @@ private void onDeviceFound(final ScanResult bleScanResult) {
318314
BluetoothDevice device = bleScanResult.getDevice();
319315
Context context = getContext();
320316

321-
if (foundDevices.containsKey(device.getAddress()) || context == null) {
317+
if (device.getName() == null || foundDevices.containsKey(device.getAddress()) || context == null) {
322318
return;
323319
}
324320

325321
BluetoothDeviceView deviceView = new BluetoothDeviceView(context);
326322
deviceView.setDeviceName(formatDeviceName(bleScanResult.getDevice()));
327323

328-
String name = device.getName() != null ? device.getName() : "";
329-
BluetoothCommunication btDevice = BluetoothFactory.createDeviceDriver(context, name);
324+
BluetoothCommunication btDevice = BluetoothFactory.createDeviceDriver(context, device.getName());
330325
if (btDevice != null) {
331326
Timber.d("Found supported device %s (driver: %s)",
332327
formatDeviceName(device), btDevice.driverName());

0 commit comments

Comments
 (0)