From 9bae22f5513f7d067df23628f848c78e2e047ce7 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 30 Oct 2017 17:01:48 +0100 Subject: [PATCH] Tweaking ComboFragment's Last Connection. --- .../plugins/PumpCombo/ComboFragment.java | 21 +++++++++---------- app/src/main/res/values/strings.xml | 1 + 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java index e0e1d2f22d..ce32f0cd2d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java @@ -65,12 +65,8 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis break; case R.id.combo_error_history: // TODO show popup with pump errors and comm problems + // steal code from profile view, called on overview break; -// case R.id.combo_stats: - // TODO show TDD stats from the pump (later) - // how about rather making this a pump agnostic thing, it's all in the DB, - // add a TDD tab to Treatments? -// break; } } @@ -88,7 +84,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis // state stateView.setText(plugin.getStateSummary()); PumpState ps = plugin.getPump().state; - if ( ps.insulinState == PumpState.EMPTY || ps.batteryState == PumpState.EMPTY) { + if (ps.insulinState == PumpState.EMPTY || ps.batteryState == PumpState.EMPTY) { stateView.setTextColor(Color.RED); } else if (plugin.getPump().state.suspended) { stateView.setTextColor(Color.YELLOW); @@ -132,15 +128,18 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis if (lastCmdResult != null) { String minAgo = DateUtil.minAgo(plugin.getPump().lastSuccessfulConnection); String time = DateUtil.timeString(plugin.getPump().lastSuccessfulConnection); - if (plugin.getPump().lastSuccessfulConnection < System.currentTimeMillis() + 30 * 60 * 1000) { + String timeAgo = getString(R.string.combo_last_connection_time, minAgo, time); + if (plugin.getPump().lastSuccessfulConnection == 0) { + lastConnectionView.setText(R.string.combo_pump_never_connected); + lastConnectionView.setTextColor(Color.RED); + } else if (plugin.getPump().lastSuccessfulConnection < System.currentTimeMillis() - 30 * 60 * 1000) { lastConnectionView.setText(getString(R.string.combo_no_pump_connection, minAgo)); lastConnectionView.setTextColor(Color.RED); - } - if (plugin.getPump().lastConnectionAttempt > plugin.getPump().lastSuccessfulConnection) { - lastConnectionView.setText(R.string.combo_connect_attempt_failed); + } else if (plugin.getPump().lastConnectionAttempt > plugin.getPump().lastSuccessfulConnection) { + lastConnectionView.setText(timeAgo + "\n" + R.string.combo_connect_attempt_failed); lastConnectionView.setTextColor(Color.YELLOW); } else { - lastConnectionView.setText(getString(R.string.combo_last_connection_time, minAgo, time)); + lastConnectionView.setText(timeAgo); lastConnectionView.setTextColor(Color.WHITE); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6d6cbb4e11..58b1397805 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -783,5 +783,6 @@ Local alerts Alert if no BGs received in 30 min Alert if pump unreachable for 30 min + Never