Combo Fragment misc.
This commit is contained in:
parent
71eff7ec79
commit
3d6c8ee2a5
3 changed files with 55 additions and 63 deletions
|
@ -68,15 +68,6 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.combo_refresh:
|
case R.id.combo_refresh:
|
||||||
/* Activity activity = getActivity();
|
|
||||||
if (activity != null) {
|
|
||||||
activity.runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
statusView.setText("Refreshing");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}*/
|
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -97,6 +88,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
statusView.setText(ev.status);
|
statusView.setText(ev.status);
|
||||||
|
statusView.setTextColor(Color.WHITE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -111,6 +103,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ComboPlugin plugin = ComboPlugin.getPlugin();
|
ComboPlugin plugin = ComboPlugin.getPlugin();
|
||||||
|
// status
|
||||||
if (plugin.getPump().lastCmdResult == null) {
|
if (plugin.getPump().lastCmdResult == null) {
|
||||||
statusView.setText("Initializing");
|
statusView.setText("Initializing");
|
||||||
} else {
|
} else {
|
||||||
|
@ -118,24 +111,24 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
}
|
}
|
||||||
if (plugin.getPump().state.errorMsg != null) {
|
if (plugin.getPump().state.errorMsg != null) {
|
||||||
statusView.setTextColor(Color.RED);
|
statusView.setTextColor(Color.RED);
|
||||||
|
} else if (plugin.getPump().state.suspended ) {
|
||||||
|
statusView.setTextColor(Color.YELLOW);
|
||||||
} else {
|
} else {
|
||||||
statusView.setTextColor(Color.WHITE);
|
statusView.setTextColor(Color.WHITE);
|
||||||
}
|
}
|
||||||
// ???
|
|
||||||
if (plugin.isInitialized()) {
|
if (plugin.isInitialized()) {
|
||||||
|
// TBR
|
||||||
PumpState ps = plugin.getPump().state;
|
PumpState ps = plugin.getPump().state;
|
||||||
if (ps != null) {
|
|
||||||
boolean tbrActive = ps.tbrPercent != -1 && ps.tbrPercent != 100;
|
boolean tbrActive = ps.tbrPercent != -1 && ps.tbrPercent != 100;
|
||||||
if (tbrActive) {
|
if (tbrActive) {
|
||||||
// tbrPercentageText.setText("" + ps.tbrPercent + "%");
|
String tbr = ps.tbrPercent + "% (" + ps.tbrRemainingDuration + " m remaining)";
|
||||||
// tbrDurationText.setText("" + ps.tbrRemainingDuration + " min");
|
tempBasalText.setText(tbr);
|
||||||
// tbrRateText.setText("" + ps.tbrRate + " U/h");
|
|
||||||
} else {
|
} else {
|
||||||
// tbrPercentageText.setText("Default basal rate running");
|
tempBasalText.setText("");
|
||||||
// tbrDurationText.setText("");
|
|
||||||
// tbrRateText.setText("");
|
|
||||||
}
|
}
|
||||||
// pumpErrorText.setText(ps.errorMsg != null ? ps.errorMsg : "");
|
|
||||||
|
// battery
|
||||||
if (ps.batteryState == PumpState.EMPTY) {
|
if (ps.batteryState == PumpState.EMPTY) {
|
||||||
batteryView.setText("{fa-battery-empty}");
|
batteryView.setText("{fa-battery-empty}");
|
||||||
batteryView.setTextColor(Color.RED);
|
batteryView.setTextColor(Color.RED);
|
||||||
|
@ -146,29 +139,27 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
batteryView.setText("{fa-battery-full}");
|
batteryView.setText("{fa-battery-full}");
|
||||||
batteryView.setTextColor(Color.WHITE);
|
batteryView.setTextColor(Color.WHITE);
|
||||||
}
|
}
|
||||||
switch (ps.insulinState) {
|
|
||||||
case 0:
|
// reservoir
|
||||||
reservoirView.setText("ok");
|
if (ps.insulinState == PumpState.LOW) {
|
||||||
break;
|
reservoirView.setTextColor(Color.YELLOW);
|
||||||
case 1:
|
} else if (ps.insulinState == PumpState.EMPTY) {
|
||||||
reservoirView.setText("low");
|
reservoirView.setTextColor(Color.RED);
|
||||||
break;
|
} else {
|
||||||
case 2:
|
reservoirView.setTextColor(Color.WHITE);
|
||||||
reservoirView.setText("empty");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
int reservoirLevel = plugin.getPump().history.reservoirLevel;
|
int reservoirLevel = plugin.getPump().history.reservoirLevel;
|
||||||
reservoirView.setText(reservoirLevel == -1 ? "" : "" + reservoirLevel + " U");
|
reservoirView.setText(reservoirLevel == -1 ? "" : "" + reservoirLevel + " U");
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.getPump().lastCmdResult != null) {
|
// last connection
|
||||||
CommandResult lastCmdResult = plugin.getPump().lastCmdResult;
|
CommandResult lastCmdResult = plugin.getPump().lastCmdResult;
|
||||||
lastConnectionView.setText(
|
if (lastCmdResult != null) {
|
||||||
"4 m ago (18:58)"
|
String minAgo = DateUtil.minAgo(lastCmdResult.completionTime);
|
||||||
// new Date(lastCmdResult.completionTime).toLocaleString()
|
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));
|
plugin.getPump().history.bolusHistory.add(new Bolus(System.currentTimeMillis() - 7 * 60 * 1000, 12.8d));
|
||||||
if (!plugin.getPump().history.bolusHistory.isEmpty()) {
|
if (!plugin.getPump().history.bolusHistory.isEmpty()) {
|
||||||
Bolus bolus = plugin.getPump().history.bolusHistory.get(0);
|
Bolus bolus = plugin.getPump().history.bolusHistory.get(0);
|
||||||
|
@ -184,18 +175,20 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
lastBolusView.setText(DateUtil.timeString(bolus.timestamp) +
|
lastBolusView.setText(DateUtil.timeString(bolus.timestamp) +
|
||||||
" (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " +
|
" (" + DecimalFormatter.to1Decimal(agoHours) + " " + MainApp.sResources.getString(R.string.hoursago) + ") " +
|
||||||
DecimalFormatter.to2Decimal(bolus.amount) + " U");
|
DecimalFormatter.to2Decimal(bolus.amount) + " U");
|
||||||
lastBolusView.setText("12.80 U (15 m ago, 19:04)"); // (19:04)");
|
lastBolusView.setText("12.80 U (15.1 h ago, 19:04)"); // (19:04)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// basal rate
|
||||||
basaBasalRateView.setText(DecimalFormatter.to2Decimal(plugin.getBaseBasalRate()) + " U/h");
|
basaBasalRateView.setText(DecimalFormatter.to2Decimal(plugin.getBaseBasalRate()) + " U/h");
|
||||||
|
|
||||||
TemporaryBasal temporaryBasal = new TemporaryBasal(System.currentTimeMillis());
|
// temp basal
|
||||||
temporaryBasal.percentRate = 420;
|
// TemporaryBasal temporaryBasal = new TemporaryBasal(System.currentTimeMillis());
|
||||||
temporaryBasal.durationInMinutes = 20;
|
// temporaryBasal.percentRate = 420;
|
||||||
|
// temporaryBasal.durationInMinutes = 20;
|
||||||
|
|
||||||
tempBasalText.setText(temporaryBasal.toStringFull());
|
// tempBasalText.setText(temporaryBasal.toStringFull());
|
||||||
tempBasalText.setText("420% 5/20' (18:45)");
|
// tempBasalText.setText("420% 5/20' (18:45)");
|
||||||
|
|
||||||
CommandResult lastCmdResult1 = plugin.getPump().lastCmdResult;
|
CommandResult lastCmdResult1 = plugin.getPump().lastCmdResult;
|
||||||
String lastCmd = lastCmdResult1.request;
|
String lastCmd = lastCmdResult1.request;
|
||||||
|
|
|
@ -287,7 +287,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO uses profile values for the time being
|
// TODO uses profile values for the time being
|
||||||
// this get's called mulitple times a minute, must absolutely be cached
|
// this get's called multiple times a minute, must absolutely be cached
|
||||||
@Override
|
@Override
|
||||||
public double getBaseBasalRate() {
|
public double getBaseBasalRate() {
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
|
|
@ -90,14 +90,13 @@
|
||||||
|
|
||||||
<com.joanzapata.iconify.widget.IconTextView
|
<com.joanzapata.iconify.widget.IconTextView
|
||||||
android:id="@+id/combo_pumpstate_battery"
|
android:id="@+id/combo_pumpstate_battery"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@android:color/white"
|
android:layout_weight="1"
|
||||||
android:textSize="14sp"
|
|
||||||
android:paddingLeft="5dp"
|
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:text="" />
|
android:paddingLeft="5dp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="20dp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue