Add back TBR to ComboFragment.
This commit is contained in:
parent
c04d746cfc
commit
4517736122
|
@ -36,6 +36,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
private TextView batteryView;
|
private TextView batteryView;
|
||||||
private TextView reservoirView;
|
private TextView reservoirView;
|
||||||
private TextView lastConnectionView;
|
private TextView lastConnectionView;
|
||||||
|
private TextView tempBasalText;
|
||||||
|
|
||||||
private Button refresh;
|
private Button refresh;
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
batteryView = (TextView) view.findViewById(R.id.combo_pumpstate_battery);
|
batteryView = (TextView) view.findViewById(R.id.combo_pumpstate_battery);
|
||||||
reservoirView = (TextView) view.findViewById(R.id.combo_insulinstate);
|
reservoirView = (TextView) view.findViewById(R.id.combo_insulinstate);
|
||||||
lastConnectionView = (TextView) view.findViewById(R.id.combo_lastconnection);
|
lastConnectionView = (TextView) view.findViewById(R.id.combo_lastconnection);
|
||||||
|
tempBasalText = (TextView) view.findViewById(R.id.combo_temp_basal);
|
||||||
|
|
||||||
refresh = (Button) view.findViewById(R.id.combo_refresh);
|
refresh = (Button) view.findViewById(R.id.combo_refresh);
|
||||||
refresh.setOnClickListener(this);
|
refresh.setOnClickListener(this);
|
||||||
|
@ -115,7 +117,8 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
statusView.setTextColor(Color.WHITE);
|
statusView.setTextColor(Color.WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.isInitialized()) {
|
CommandResult lastCmdResult = plugin.getPump().lastCmdResult;
|
||||||
|
if (plugin.isInitialized() && lastCmdResult != null) {
|
||||||
PumpState ps = plugin.getPump().state;
|
PumpState ps = plugin.getPump().state;
|
||||||
// battery
|
// battery
|
||||||
if (ps.batteryState == PumpState.EMPTY) {
|
if (ps.batteryState == PumpState.EMPTY) {
|
||||||
|
@ -141,11 +144,18 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
reservoirView.setText(reservoirLevel == -1 ? "" : "" + reservoirLevel + " U");
|
reservoirView.setText(reservoirLevel == -1 ? "" : "" + reservoirLevel + " U");
|
||||||
|
|
||||||
// last connection
|
// last connection
|
||||||
CommandResult lastCmdResult = plugin.getPump().lastCmdResult;
|
String minAgo = DateUtil.minAgo(lastCmdResult.completionTime);
|
||||||
if (lastCmdResult != null) {
|
String time = DateUtil.timeString(lastCmdResult.completionTime);
|
||||||
String minAgo = DateUtil.minAgo(lastCmdResult.completionTime);
|
lastConnectionView.setText("" + minAgo + " (" + time + ")");
|
||||||
String time = DateUtil.timeString(lastCmdResult.completionTime);
|
|
||||||
lastConnectionView.setText("" + minAgo + " (" + time + ")");
|
// TBR
|
||||||
|
boolean tbrActive = ps.tbrPercent != -1 && ps.tbrPercent != 100;
|
||||||
|
if (tbrActive) {
|
||||||
|
long minSinceRead = (System.currentTimeMillis() - lastCmdResult.completionTime) / 1000 / 60;
|
||||||
|
String tbr = ps.tbrPercent + "% (" + (ps.tbrRemainingDuration - minSinceRead) + " min remaining)";
|
||||||
|
tempBasalText.setText(tbr);
|
||||||
|
} else {
|
||||||
|
tempBasalText.setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,7 +280,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
runCommand("Refreshing", new CommandExecution() {
|
runCommand("Refreshing", new CommandExecution() {
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute() {
|
public CommandResult execute() {
|
||||||
return ruffyScripter.readHistory(new PumpHistoryRequest().reservoirLevel(true));
|
return ruffyScripter.readHistory(new PumpHistoryRequest().reservoirLevel(true).bolusHistory(PumpHistoryRequest.LAST));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,6 +199,51 @@
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:background="@color/listdelimiter" />
|
android:background="@color/listdelimiter" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1.5"
|
||||||
|
android:gravity="end"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:text="@string/pump_tempbasal_label"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="5dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:text=":"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/combo_temp_basal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingLeft="5dp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="2dip"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:background="@color/listdelimiter" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
Loading…
Reference in a new issue