mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-16 21:54:05 +02:00
applied patch by Florin9doi, see https://github.com/oliexdev/openScale/pull/1088#issuecomment-2496265764
This commit is contained in:
@@ -322,14 +322,18 @@ public class BluetoothSettingsFragment extends Fragment {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BluetoothDeviceView deviceView = new BluetoothDeviceView(context);
|
|
||||||
deviceView.setDeviceName(formatDeviceName(bleScanResult.getDevice()));
|
|
||||||
|
|
||||||
String deviceName = device.getName();
|
String deviceName = device.getName();
|
||||||
if (deviceName == null) {
|
if (deviceName == null) {
|
||||||
deviceName = BluetoothFactory.convertNoNameToDeviceName(bleScanResult.getScanRecord().getManufacturerSpecificData());
|
deviceName = BluetoothFactory.convertNoNameToDeviceName(bleScanResult.getScanRecord().getManufacturerSpecificData());
|
||||||
|
}
|
||||||
|
if (deviceName == null) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BluetoothDeviceView deviceView = new BluetoothDeviceView(context);
|
||||||
|
deviceView.setDeviceName(formatDeviceName(deviceName, device.getAddress()));
|
||||||
|
deviceView.setAlias(deviceName);
|
||||||
|
|
||||||
BluetoothCommunication btDevice = BluetoothFactory.createDeviceDriver(context, deviceName);
|
BluetoothCommunication btDevice = BluetoothFactory.createDeviceDriver(context, deviceName);
|
||||||
if (btDevice != null) {
|
if (btDevice != null) {
|
||||||
Timber.d("Found supported device %s (driver: %s)",
|
Timber.d("Found supported device %s (driver: %s)",
|
||||||
@@ -398,6 +402,7 @@ public class BluetoothSettingsFragment extends Fragment {
|
|||||||
private TextView deviceName;
|
private TextView deviceName;
|
||||||
private ImageView deviceIcon;
|
private ImageView deviceIcon;
|
||||||
private String deviceAddress;
|
private String deviceAddress;
|
||||||
|
private String deviceAlias;
|
||||||
|
|
||||||
public BluetoothDeviceView(Context context) {
|
public BluetoothDeviceView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -427,6 +432,14 @@ public class BluetoothSettingsFragment extends Fragment {
|
|||||||
addView(deviceName);
|
addView(deviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAlias(String alias) {
|
||||||
|
deviceAlias = alias;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAlias() {
|
||||||
|
return deviceAlias;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDeviceAddress(String address) {
|
public void setDeviceAddress(String address) {
|
||||||
deviceAddress = address;
|
deviceAddress = address;
|
||||||
}
|
}
|
||||||
@@ -485,10 +498,10 @@ public class BluetoothSettingsFragment extends Fragment {
|
|||||||
|
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
.putString(PREFERENCE_KEY_BLUETOOTH_HW_ADDRESS, device.getAddress())
|
.putString(PREFERENCE_KEY_BLUETOOTH_HW_ADDRESS, device.getAddress())
|
||||||
.putString(PREFERENCE_KEY_BLUETOOTH_DEVICE_NAME, device.getName())
|
.putString(PREFERENCE_KEY_BLUETOOTH_DEVICE_NAME, getAlias())
|
||||||
.apply();
|
.apply();
|
||||||
|
|
||||||
Timber.d("Saved Bluetooth device " + device.getName() + " with address " + device.getAddress());
|
Timber.d("Saved Bluetooth device " + getAlias() + " with address " + device.getAddress());
|
||||||
|
|
||||||
stopBluetoothDiscovery();
|
stopBluetoothDiscovery();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user