Tweaking ComboFragment's Last Connection.

This commit is contained in:
Johannes Mockenhaupt 2017-10-30 17:01:48 +01:00
parent 79d7ec5467
commit 9bae22f551
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 11 additions and 11 deletions

View file

@ -65,12 +65,8 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
break; break;
case R.id.combo_error_history: case R.id.combo_error_history:
// TODO show popup with pump errors and comm problems // TODO show popup with pump errors and comm problems
// steal code from profile view, called on overview
break; 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;
} }
} }
@ -132,15 +128,18 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
if (lastCmdResult != null) { if (lastCmdResult != null) {
String minAgo = DateUtil.minAgo(plugin.getPump().lastSuccessfulConnection); String minAgo = DateUtil.minAgo(plugin.getPump().lastSuccessfulConnection);
String time = DateUtil.timeString(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.setText(getString(R.string.combo_no_pump_connection, minAgo));
lastConnectionView.setTextColor(Color.RED); lastConnectionView.setTextColor(Color.RED);
} } else if (plugin.getPump().lastConnectionAttempt > plugin.getPump().lastSuccessfulConnection) {
if (plugin.getPump().lastConnectionAttempt > plugin.getPump().lastSuccessfulConnection) { lastConnectionView.setText(timeAgo + "\n" + R.string.combo_connect_attempt_failed);
lastConnectionView.setText(R.string.combo_connect_attempt_failed);
lastConnectionView.setTextColor(Color.YELLOW); lastConnectionView.setTextColor(Color.YELLOW);
} else { } else {
lastConnectionView.setText(getString(R.string.combo_last_connection_time, minAgo, time)); lastConnectionView.setText(timeAgo);
lastConnectionView.setTextColor(Color.WHITE); lastConnectionView.setTextColor(Color.WHITE);
} }

View file

@ -783,5 +783,6 @@
<string name="localalertsettings_title">Local alerts</string> <string name="localalertsettings_title">Local alerts</string>
<string name="enable_missed_bg_readings_alert">Alert if no BGs received in 30 min</string> <string name="enable_missed_bg_readings_alert">Alert if no BGs received in 30 min</string>
<string name="enable_pump_unreachable_alert">Alert if pump unreachable for 30 min</string> <string name="enable_pump_unreachable_alert">Alert if pump unreachable for 30 min</string>
<string name="combo_pump_never_connected">Never</string>
</resources> </resources>