Distinguish between configured and connected device for Medtronic in RileyLink fragment

This commit is contained in:
Bart Sopers 2021-01-07 02:21:41 +01:00
parent 647c0ea74a
commit f1bb85eafa
4 changed files with 80 additions and 35 deletions

View file

@ -9,8 +9,7 @@ import info.nightscout.androidaps.plugins.pump.common.R;
public enum RileyLinkTargetDevice { public enum RileyLinkTargetDevice {
MedtronicPump(R.string.rileylink_target_device_medtronic, true), // MedtronicPump(R.string.rileylink_target_device_medtronic, true), //
Omnipod(R.string.rileylink_target_device_omnipod, false), // Omnipod(R.string.rileylink_target_device_omnipod, false);
;
private final int resourceId; private final int resourceId;
private final boolean tuneUpEnabled; private final boolean tuneUpEnabled;

View file

@ -45,8 +45,10 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
private TextView configuredRileyLinkName; private TextView configuredRileyLinkName;
private TextView batteryLevel; private TextView batteryLevel;
private TextView connectionError; private TextView connectionError;
private View connectedDeviceDetails;
private TextView deviceType; private TextView deviceType;
private TextView deviceModel; private TextView configuredDeviceModel;
private TextView connectedDeviceModel;
private TextView serialNumber; private TextView serialNumber;
private TextView pumpFrequency; private TextView pumpFrequency;
private TextView lastUsedFrequency; private TextView lastUsedFrequency;
@ -59,16 +61,18 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
} }
@Override @Override
public void onStart() { public void onResume() {
super.onStart(); super.onResume();
this.connectionStatus = getActivity().findViewById(R.id.rls_t1_connection_status); this.connectionStatus = getActivity().findViewById(R.id.rls_t1_connection_status);
this.configuredRileyLinkAddress = getActivity().findViewById(R.id.rls_t1_configured_riley_link_address); this.configuredRileyLinkAddress = getActivity().findViewById(R.id.rls_t1_configured_riley_link_address);
this.configuredRileyLinkName = getActivity().findViewById(R.id.rls_t1_configured_riley_link_name); this.configuredRileyLinkName = getActivity().findViewById(R.id.rls_t1_configured_riley_link_name);
this.batteryLevel = getActivity().findViewById(R.id.rls_t1_battery_level); this.batteryLevel = getActivity().findViewById(R.id.rls_t1_battery_level);
this.connectionError = getActivity().findViewById(R.id.rls_t1_connection_error); this.connectionError = getActivity().findViewById(R.id.rls_t1_connection_error);
this.connectedDeviceDetails = getActivity().findViewById(R.id.rls_t1_connected_device_details);
this.deviceType = getActivity().findViewById(R.id.rls_t1_device_type); this.deviceType = getActivity().findViewById(R.id.rls_t1_device_type);
this.deviceModel = getActivity().findViewById(R.id.rls_t1_device_model); this.configuredDeviceModel = getActivity().findViewById(R.id.rls_t1_configured_device_model);
this.connectedDeviceModel = getActivity().findViewById(R.id.rls_t1_connected_device_model);
this.serialNumber = getActivity().findViewById(R.id.rls_t1_serial_number); this.serialNumber = getActivity().findViewById(R.id.rls_t1_serial_number);
this.pumpFrequency = getActivity().findViewById(R.id.rls_t1_pump_frequency); this.pumpFrequency = getActivity().findViewById(R.id.rls_t1_pump_frequency);
this.lastUsedFrequency = getActivity().findViewById(R.id.rls_t1_last_used_frequency); this.lastUsedFrequency = getActivity().findViewById(R.id.rls_t1_last_used_frequency);
@ -98,18 +102,24 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
Optional.ofNullable(rileyLinkServiceData.versionBLE113).orElse(PLACEHOLDER), Optional.ofNullable(rileyLinkServiceData.versionCC110).orElse(PLACEHOLDER))); Optional.ofNullable(rileyLinkServiceData.versionBLE113).orElse(PLACEHOLDER), Optional.ofNullable(rileyLinkServiceData.versionCC110).orElse(PLACEHOLDER)));
} }
RileyLinkPumpDevice pumpPlugin = (RileyLinkPumpDevice) activePlugin.getActivePump(); RileyLinkPumpDevice rileyLinkPumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
RileyLinkPumpInfo pumpInfo = pumpPlugin.getPumpInfo(); RileyLinkPumpInfo rileyLinkPumpInfo = rileyLinkPumpDevice.getPumpInfo();
this.deviceType.setText(rileyLinkServiceData.targetDevice.getResourceId()); this.deviceType.setText(targetDevice.getResourceId());
this.deviceModel.setText(pumpInfo.getConnectedDeviceModel()); if (targetDevice == RileyLinkTargetDevice.MedtronicPump) {
this.serialNumber.setText(pumpInfo.getConnectedDeviceSerialNumber()); this.connectedDeviceDetails.setVisibility(View.VISIBLE);
this.pumpFrequency.setText(pumpInfo.getPumpFrequency()); this.configuredDeviceModel.setText(activePlugin.getActivePump().getPumpDescription().pumpType.getDescription());
this.connectedDeviceModel.setText(rileyLinkPumpInfo.getConnectedDeviceModel());
} else {
this.connectedDeviceDetails.setVisibility(View.GONE);
}
this.serialNumber.setText(rileyLinkPumpInfo.getConnectedDeviceSerialNumber());
this.pumpFrequency.setText(rileyLinkPumpInfo.getPumpFrequency());
if (rileyLinkServiceData.lastGoodFrequency != null) { if (rileyLinkServiceData.lastGoodFrequency != null) {
this.lastUsedFrequency.setText(resourceHelper.gs(R.string.rileylink_pump_frequency_value, rileyLinkServiceData.lastGoodFrequency)); this.lastUsedFrequency.setText(resourceHelper.gs(R.string.rileylink_pump_frequency_value, rileyLinkServiceData.lastGoodFrequency));
} }
long lastConnectionTimeMillis = pumpPlugin.getLastConnectionTimeMillis(); long lastConnectionTimeMillis = rileyLinkPumpDevice.getLastConnectionTimeMillis();
if (lastConnectionTimeMillis == 0) { if (lastConnectionTimeMillis == 0) {
this.lastDeviceContact.setText(resourceHelper.gs(R.string.riley_link_ble_config_connected_never)); this.lastDeviceContact.setText(resourceHelper.gs(R.string.riley_link_ble_config_connected_never));
} else { } else {

View file

@ -234,6 +234,11 @@
android:textAlignment="center" /> android:textAlignment="center" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/rls_t1_connected_device_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -241,7 +246,8 @@
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal"
android:visibility="gone">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -249,10 +255,10 @@
android:layout_marginLeft="30dp" android:layout_marginLeft="30dp"
android:layout_weight="35" android:layout_weight="35"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text="@string/rileylink_device_model" /> android:text="@string/rileylink_configured_device_model" />
<TextView <TextView
android:id="@+id/rls_t1_device_model" android:id="@+id/rls_t1_configured_device_model"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
@ -262,6 +268,35 @@
android:textAlignment="center" /> android:textAlignment="center" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
android:layout_weight="35"
android:gravity="center_vertical"
android:text="@string/rileylink_connected_device_model" />
<TextView
android:id="@+id/rls_t1_connected_device_model"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:gravity="center_vertical"
android:text=" "
android:textAlignment="center" />
</LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -38,7 +38,8 @@
<string name="rileylink_connection_error">Connection Error:</string> <string name="rileylink_connection_error">Connection Error:</string>
<string name="rileylink_device">Device</string> <string name="rileylink_device">Device</string>
<string name="rileylink_device_type">Device Type:</string> <string name="rileylink_device_type">Device Type:</string>
<string name="rileylink_device_model">Device Model:</string> <string name="rileylink_configured_device_model">Configured Device Model:</string>
<string name="rileylink_connected_device_model">Connected Device Model:</string>
<string name="rileylink_last_used_frequency">Last Used Frequency:</string> <string name="rileylink_last_used_frequency">Last Used Frequency:</string>
<string name="rileylink_last_device_contact">Last Device Contact:</string> <string name="rileylink_last_device_contact">Last Device Contact:</string>
<string name="rileylink_firmware_version">Firmware Version:</string> <string name="rileylink_firmware_version">Firmware Version:</string>
@ -70,7 +71,7 @@
<!-- RileyLink - Common --> <!-- RileyLink - Common -->
<string name="rileylink_target_device_medtronic">Medtronic Pump</string> <string name="rileylink_target_device_medtronic">Medtronic Pump</string>
<string name="rileylink_target_device_omnipod">Omnipod</string> <string name="rileylink_target_device_omnipod">Omnipod (Eros)</string>
<string name="riley_link_common_yes">Yes</string> <string name="riley_link_common_yes">Yes</string>
<string name="riley_link_common_no">No</string> <string name="riley_link_common_no">No</string>