Trim down ComboFragment.
Base basal rate, TBR, last bolus are redundant, they're already displayed on the overview and the treatment tab. When they're not in sync, that's an error of the ComboPlugin.
This commit is contained in:
parent
3d6c8ee2a5
commit
4e978656f5
3 changed files with 7 additions and 201 deletions
|
@ -35,11 +35,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
|||
private TextView statusView;
|
||||
private TextView batteryView;
|
||||
private TextView reservoirView;
|
||||
|
||||
private TextView lastConnectionView;
|
||||
private TextView lastBolusView;
|
||||
private TextView basaBasalRateView;
|
||||
private TextView tempBasalText;
|
||||
|
||||
private Button refresh;
|
||||
|
||||
|
@ -51,11 +47,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
|||
statusView = (TextView) view.findViewById(R.id.combo_status);
|
||||
batteryView = (TextView) view.findViewById(R.id.combo_pumpstate_battery);
|
||||
reservoirView = (TextView) view.findViewById(R.id.combo_insulinstate);
|
||||
|
||||
lastConnectionView = (TextView) view.findViewById(R.id.combo_lastconnection);
|
||||
lastBolusView = (TextView) view.findViewById(R.id.combo_lastbolus);
|
||||
basaBasalRateView = (TextView) view.findViewById(R.id.combo_basabasalrate);
|
||||
tempBasalText = (TextView) view.findViewById(R.id.combo_temp_basal);
|
||||
|
||||
refresh = (Button) view.findViewById(R.id.combo_refresh);
|
||||
refresh.setOnClickListener(this);
|
||||
|
@ -76,6 +68,12 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
|||
});
|
||||
thread.start();
|
||||
break;
|
||||
case R.id.combo_history:
|
||||
// TODO show popup with warnings/errors from the pump
|
||||
break;
|
||||
case R.id.combo_stats:
|
||||
// TODO show TDD stats from the pump
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,16 +116,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
|||
}
|
||||
|
||||
if (plugin.isInitialized()) {
|
||||
// TBR
|
||||
PumpState ps = plugin.getPump().state;
|
||||
boolean tbrActive = ps.tbrPercent != -1 && ps.tbrPercent != 100;
|
||||
if (tbrActive) {
|
||||
String tbr = ps.tbrPercent + "% (" + ps.tbrRemainingDuration + " m remaining)";
|
||||
tempBasalText.setText(tbr);
|
||||
} else {
|
||||
tempBasalText.setText("");
|
||||
}
|
||||
|
||||
// battery
|
||||
if (ps.batteryState == PumpState.EMPTY) {
|
||||
batteryView.setText("{fa-battery-empty}");
|
||||
|
@ -158,55 +147,6 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
|||
String time = DateUtil.timeString(lastCmdResult.completionTime);
|
||||
lastConnectionView.setText("" + minAgo + " (" + time + ")");
|
||||
}
|
||||
|
||||
// last bolus
|
||||
plugin.getPump().history.bolusHistory.add(new Bolus(System.currentTimeMillis() - 7 * 60 * 1000, 12.8d));
|
||||
if (!plugin.getPump().history.bolusHistory.isEmpty()) {
|
||||
Bolus bolus = plugin.getPump().history.bolusHistory.get(0);
|
||||
// double agoHours = agoMsec / 60d / 60d / 1000d;
|
||||
// if (agoHours < 6) // max 6h back
|
||||
if (bolus.timestamp + 6 * 60 * 60 * 1000 < System.currentTimeMillis()) {
|
||||
lastBolusView.setText("");
|
||||
} else {
|
||||
// TODO only if !SMB; also: bolus history: should only be used to sync to DB;
|
||||
// remember that datum someplace else?
|
||||
long agoMsc = System.currentTimeMillis() - bolus.timestamp;
|
||||
double agoHours = agoMsc / 60d / 60d / 1000d;
|
||||
lastBolusView.setText(DateUtil.timeString(bolus.timestamp) +
|
||||
" (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " +
|
||||
DecimalFormatter.to2Decimal(bolus.amount) + " U");
|
||||
lastBolusView.setText("12.80 U (15.1 h ago, 19:04)"); // (19:04)");
|
||||
}
|
||||
}
|
||||
|
||||
// basal rate
|
||||
basaBasalRateView.setText(DecimalFormatter.to2Decimal(plugin.getBaseBasalRate()) + " U/h");
|
||||
|
||||
// temp basal
|
||||
// TemporaryBasal temporaryBasal = new TemporaryBasal(System.currentTimeMillis());
|
||||
// temporaryBasal.percentRate = 420;
|
||||
// temporaryBasal.durationInMinutes = 20;
|
||||
|
||||
// tempBasalText.setText(temporaryBasal.toStringFull());
|
||||
// tempBasalText.setText("420% 5/20' (18:45)");
|
||||
|
||||
CommandResult lastCmdResult1 = plugin.getPump().lastCmdResult;
|
||||
String lastCmd = lastCmdResult1.request;
|
||||
if (lastCmd != null) {
|
||||
// lastCmdText.setText(lastCmd);
|
||||
// lastCmdTimeText.setText(plugin.getPump().lastCmdTime.toLocaleString());
|
||||
} else {
|
||||
// lastCmdText.setText("");
|
||||
// lastCmdTimeText.setText("");
|
||||
}
|
||||
|
||||
if (lastCmdResult1.message != null) {
|
||||
// lastCmdResultText.setText(lastCmdResult1.message);
|
||||
// lastCmdDurationText.setText(lastCmdResult1.duration);
|
||||
} else {
|
||||
// lastCmdResultText.setText("");
|
||||
// lastCmdDurationText.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -562,6 +562,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
// TODO handle running into WARNING_OR_ERROR ... or scripter? purge it
|
||||
CommandResult commandResult = commandExecution.execute();
|
||||
pump.lastCmdResult = commandResult;
|
||||
pump.lastCmdResult.completionTime = System.currentTimeMillis(); // todo
|
||||
pump.state = commandResult.state;
|
||||
// TOOD
|
||||
if (commandResult.history != null)
|
||||
|
|
|
@ -199,141 +199,6 @@
|
|||
android:layout_marginTop="5dp"
|
||||
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_lastbolus_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_lastbolus"
|
||||
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
|
||||
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_basebasalrate_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_basabasalrate"
|
||||
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
|
||||
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>
|
||||
|
||||
</ScrollView>
|
||||
|
|
Loading…
Reference in a new issue