1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-19 07:07:46 +01:00

Use hw version to make device names unique, then mac addr

This commit is contained in:
cpfeiffer 2016-03-13 20:10:02 +01:00
parent 91f02ae920
commit 4aaf3dd162

View File

@ -42,24 +42,28 @@ public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
} }
TextView deviceStatusLabel = (TextView) view.findViewById(R.id.device_status); TextView deviceStatusLabel = (TextView) view.findViewById(R.id.device_status);
TextView deviceNameLabel = (TextView) view.findViewById(R.id.device_name); TextView deviceNameLabel = (TextView) view.findViewById(R.id.device_name);
TextView deviceInfoLabel = (TextView) view.findViewById(R.id.device_info); TextView deviceInfo1Label = (TextView) view.findViewById(R.id.device_info1);
TextView deviceInfo2Label = (TextView) view.findViewById(R.id.device_info2);
TextView batteryStatusLabel = (TextView) view.findViewById(R.id.battery_status); TextView batteryStatusLabel = (TextView) view.findViewById(R.id.battery_status);
ImageView deviceImageView = (ImageView) view.findViewById(R.id.device_image); ImageView deviceImageView = (ImageView) view.findViewById(R.id.device_image);
ProgressBar busyIndicator = (ProgressBar) view.findViewById(R.id.device_busy_indicator); ProgressBar busyIndicator = (ProgressBar) view.findViewById(R.id.device_busy_indicator);
deviceNameLabel.setText(getUniqueDeviceName(device)); deviceNameLabel.setText(getUniqueDeviceName(device));
deviceInfoLabel.setText(device.getInfoString()); deviceInfo1Label.setText(device.getHWInfoString());
deviceInfo2Label.setText(device.getInfoString());
if (device.isBusy()) { if (device.isBusy()) {
deviceStatusLabel.setText(device.getBusyTask()); deviceStatusLabel.setText(device.getBusyTask());
busyIndicator.setVisibility(View.VISIBLE); busyIndicator.setVisibility(View.VISIBLE);
batteryStatusLabel.setVisibility(View.GONE); batteryStatusLabel.setVisibility(View.GONE);
deviceInfoLabel.setVisibility(View.GONE); deviceInfo1Label.setVisibility(View.GONE);
deviceInfo2Label.setVisibility(View.GONE);
} else { } else {
deviceStatusLabel.setText(device.getStateString()); deviceStatusLabel.setText(device.getStateString());
busyIndicator.setVisibility(View.GONE); busyIndicator.setVisibility(View.GONE);
batteryStatusLabel.setVisibility(View.VISIBLE); batteryStatusLabel.setVisibility(View.VISIBLE);
deviceInfoLabel.setVisibility(View.VISIBLE); deviceInfo1Label.setVisibility(View.VISIBLE);
deviceInfo2Label.setVisibility(View.VISIBLE);
} }
short batteryLevel = device.getBatteryLevel(); short batteryLevel = device.getBatteryLevel();
@ -97,7 +101,10 @@ public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
private String getUniqueDeviceName(GBDevice device) { private String getUniqueDeviceName(GBDevice device) {
String deviceName = device.getName(); String deviceName = device.getName();
if (!isUniqueDeviceName(device, deviceName)) { if (!isUniqueDeviceName(device, deviceName)) {
deviceName = deviceName + " " + device.getShortAddress(); deviceName = deviceName + " " + device.getHardwareVersion();
if (!isUniqueDeviceName(device, deviceName)) {
deviceName = deviceName + " " + device.getShortAddress();
}
} }
return deviceName; return deviceName;
} }