Add changes of schmitzn/reservoir-view
This commit is contained in:
parent
d4ed6539d8
commit
4ebc149783
13 changed files with 126 additions and 21 deletions
|
@ -33,6 +33,8 @@ public interface PumpInterface {
|
|||
|
||||
double getBaseBasalRate(); // base basal rate, not temp basal
|
||||
|
||||
double getReservoirLevel();
|
||||
|
||||
PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo);
|
||||
void stopBolusDelivering();
|
||||
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew);
|
||||
|
|
|
@ -134,6 +134,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
TextView baseBasalView;
|
||||
TextView extendedBolusView;
|
||||
TextView activeProfileView;
|
||||
TextView reservoirView;
|
||||
TextView iobView;
|
||||
TextView cobView;
|
||||
TextView apsModeView;
|
||||
|
@ -232,6 +233,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
|
||||
extendedBolusView = (TextView) view.findViewById(R.id.overview_extendedbolus);
|
||||
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
|
||||
reservoirView = (TextView) view.findViewById(R.id.overview_reservoir);
|
||||
pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus);
|
||||
pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump);
|
||||
openapsDeviceStatusView = (TextView) view.findViewById(R.id.overview_openaps);
|
||||
|
@ -1040,25 +1042,25 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||
if (Config.APS && pump.getPumpDescription().isTempBasalCapable) {
|
||||
apsModeView.setVisibility(View.VISIBLE);
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.loopenabled));
|
||||
apsModeView.setTextColor(Color.BLACK);
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault));
|
||||
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextDefault));
|
||||
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||
if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuperBolus()) {
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.looppumpsuspended));
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning));
|
||||
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuperbolusfor), loopPlugin.minutesToEndOfSuspend()));
|
||||
apsModeView.setTextColor(Color.WHITE);
|
||||
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
|
||||
} else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isDisconnected()) {
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.looppumpsuspended));
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning));
|
||||
apsModeView.setText(String.format(MainApp.gs(R.string.loopdisconnectedfor), loopPlugin.minutesToEndOfSuspend()));
|
||||
apsModeView.setTextColor(Color.WHITE);
|
||||
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
|
||||
} else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuspended()) {
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.looppumpsuspended));
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning));
|
||||
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend()));
|
||||
apsModeView.setTextColor(Color.WHITE);
|
||||
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
|
||||
} else if (pump.isSuspended()) {
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.looppumpsuspended));
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning));
|
||||
apsModeView.setText(MainApp.gs(R.string.pumpsuspended));
|
||||
apsModeView.setTextColor(Color.WHITE);
|
||||
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
|
||||
} else if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
if (closedLoopEnabled.value()) {
|
||||
apsModeView.setText(MainApp.gs(R.string.closedloop));
|
||||
|
@ -1066,9 +1068,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
apsModeView.setText(MainApp.gs(R.string.openloop));
|
||||
}
|
||||
} else {
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.loopdisabled));
|
||||
apsModeView.setBackgroundColor(MainApp.gc(R.color.ribbonBgCritical));
|
||||
apsModeView.setText(MainApp.gs(R.string.disabledloop));
|
||||
apsModeView.setTextColor(Color.WHITE);
|
||||
apsModeView.setTextColor(MainApp.gc(R.color.ribbonTextCritical));
|
||||
}
|
||||
} else {
|
||||
apsModeView.setVisibility(View.GONE);
|
||||
|
@ -1077,13 +1079,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
// temp target
|
||||
TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory();
|
||||
if (tempTarget != null) {
|
||||
tempTargetView.setTextColor(Color.BLACK);
|
||||
tempTargetView.setBackgroundColor(MainApp.gc(R.color.tempTargetBackground));
|
||||
tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
|
||||
tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning));
|
||||
tempTargetView.setVisibility(View.VISIBLE);
|
||||
tempTargetView.setText(Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end()));
|
||||
} else {
|
||||
tempTargetView.setTextColor(Color.WHITE);
|
||||
tempTargetView.setBackgroundColor(MainApp.gc(R.color.tempTargetDisabledBackground));
|
||||
tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextDefault));
|
||||
tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault));
|
||||
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units, units));
|
||||
tempTargetView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -1190,7 +1192,30 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
}
|
||||
|
||||
activeProfileView.setText(MainApp.getConfigBuilder().getProfileName());
|
||||
activeProfileView.setBackgroundColor(Color.GRAY);
|
||||
activeProfileView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault));
|
||||
activeProfileView.setTextColor(MainApp.gc(R.color.ribbonTextDefault));
|
||||
|
||||
if (reservoirView != null) {
|
||||
boolean showReservoirView = SP.getBoolean(R.string.key_show_reservoirview, false);
|
||||
int reservoirLevel = pump.isInitialized() ? (int) Math.round(pump.getReservoirLevel()) : -1;
|
||||
if (showReservoirView && reservoirLevel != -1) {
|
||||
int levelWarning = SP.getInt(R.string.key_reservoirview_levelwarning, 80);
|
||||
int levelCritical = SP.getInt(R.string.key_reservoirview_levelcritical, 5);
|
||||
reservoirView.setText(reservoirLevel + " " + MainApp.sResources.getString(R.string.insulin_unit_shortname));
|
||||
if (reservoirLevel <= levelCritical) {
|
||||
reservoirView.setBackgroundColor(MainApp.gc(R.color.ribbonBgCritical));
|
||||
reservoirView.setTextColor(MainApp.gc(R.color.ribbonTextCritical));
|
||||
} else if (reservoirLevel <= levelWarning) {
|
||||
reservoirView.setBackgroundColor(MainApp.gc(R.color.ribbonBgWarning));
|
||||
reservoirView.setTextColor(MainApp.gc(R.color.ribbonTextWarning));
|
||||
} else {
|
||||
reservoirView.setBackgroundColor(MainApp.gc(R.color.ribbonBgDefault));
|
||||
reservoirView.setTextColor(MainApp.gc(R.color.ribbonTextDefault));
|
||||
}
|
||||
} else {
|
||||
reservoirView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
tempTargetView.setOnLongClickListener(view -> {
|
||||
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||
|
|
|
@ -423,6 +423,11 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
return pump.basalProfile.hourlyRates[currentHour];
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getReservoirLevel() {
|
||||
return pump.reservoirLevel;
|
||||
}
|
||||
|
||||
private static BolusProgressReporter bolusProgressReporter = (state, percent, delivered) -> {
|
||||
EventOverviewBolusProgress event = EventOverviewBolusProgress.getInstance();
|
||||
switch (state) {
|
||||
|
|
|
@ -150,6 +150,9 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
|||
return pump.currentBasal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getReservoirLevel() { return pump.reservoirRemainingUnits; }
|
||||
|
||||
@Override
|
||||
public void stopBolusDelivering() {
|
||||
if (sExecutionService == null) {
|
||||
|
|
|
@ -352,6 +352,11 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
|||
return pump.currentBasal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getReservoirLevel() {
|
||||
return pump.reservoirRemainingUnits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||
detailedBolusInfo.insulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(detailedBolusInfo.insulin)).value();
|
||||
|
|
|
@ -385,6 +385,9 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
|||
return basalRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getReservoirLevel() { return reservoirInUnits; }
|
||||
|
||||
public String getBaseBasalRateString() {
|
||||
final DecimalFormat df = new DecimalFormat("#.##");
|
||||
return df.format(basalRate);
|
||||
|
|
|
@ -129,6 +129,9 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
|
|||
return 0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getReservoirLevel() { return -1; }
|
||||
|
||||
@Override
|
||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
|
|
|
@ -197,6 +197,9 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
return 0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getReservoirLevel() { return reservoirInUnits; }
|
||||
|
||||
@Override
|
||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
|
|
|
@ -47,6 +47,18 @@
|
|||
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/overview_reservoir"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:text="Reservoir"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:paddingBottom="3dp"
|
||||
android:paddingTop="3dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/overview_activeprofile"
|
||||
|
|
|
@ -625,6 +625,8 @@
|
|||
<string name="tempbasal">TBR</string>
|
||||
<string name="danar_history">Pumpen-Speicher</string>
|
||||
<string name="enablesuperbolus_summary">Aktiviere die SuperBolus-Funktion im Wizard. Nicht aktivieren, wenn du nicht weißt, welche Auswirkungen dieser Bolus hat! ES KANN ZU EINER ÜBERDOSIERUNG AN INSULIN KOMMEN!</string>
|
||||
<string name="show_reservoirview">Zeige Reservoir-Füllstand in Übersicht</string>
|
||||
<string name="show_reservoirview_summary">Zeigt den Füllstand des Reservoirs in der Übersicht an.</string>
|
||||
<string name="gettingbolusstatus">Status des Bolus wird ermittelt</string>
|
||||
<string name="pairing">PAIRING</string>
|
||||
<string name="startingbolus">Bolus-Abgabe gestartet</string>
|
||||
|
|
|
@ -59,10 +59,6 @@
|
|||
<color name="colorScheduled">#de7550</color>
|
||||
<color name="colorActive">#25912e</color>
|
||||
|
||||
<color name="loopenabled">#47c8ff</color>
|
||||
<color name="loopdisabled">#FFDD7792</color>
|
||||
<color name="looppumpsuspended">#ff0400</color>
|
||||
|
||||
<color name="notificationAnnouncement">#FF8C00</color>
|
||||
<color name="notificationUrgent">#ff0400</color>
|
||||
<color name="notificationNormal">#ff5e55</color>
|
||||
|
@ -75,4 +71,11 @@
|
|||
<color name="deviationred">#72FF0000</color>
|
||||
<color name="deviationblack">#72000000</color>
|
||||
|
||||
<color name="ribbonBgDefault">#424242</color>
|
||||
<color name="ribbonBgWarning">#f4d700</color>
|
||||
<color name="ribbonBgCritical">#ff0400</color>
|
||||
<color name="ribbonTextDefault">#FFFFFF</color>
|
||||
<color name="ribbonTextWarning">#303030</color>
|
||||
<color name="ribbonTextCritical">#FFFFFF</color>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -607,6 +607,13 @@
|
|||
<string name="key_usesuperbolus" translatable="false">key_usersuperbolus</string>
|
||||
<string name="enablesuperbolus">Enable superbolus in wizard</string>
|
||||
<string name="enablesuperbolus_summary">Enable superbolus functionality in wizard. Do not enable until you learn what it really does. IT MAY CAUSE INSULIN OVERDOSE IF USED BLINDLY!</string>
|
||||
<string name="key_show_reservoirview" translatable="false">key_show_reservoirview</string>
|
||||
<string name="show_reservoirview">Show reservoir level in overview</string>
|
||||
<string name="show_reservoirview_summary">Show the reservoir level on the overview page.</string>
|
||||
<string name="key_reservoirview_levelwarning" translatable="false">key_reservoirview_levelwarning</string>
|
||||
<string name="reservoirview_levelwarning">Level warning</string>
|
||||
<string name="key_reservoirview_levelcritical" translatable="false">key_reservoirview_levelcritical</string>
|
||||
<string name="reservoirview_levelcritical">Level critical</string>
|
||||
<string name="iob">IOB</string>
|
||||
<string name="cob">COB</string>
|
||||
<string name="virtualpump_firmware_label">Firmware</string>
|
||||
|
|
|
@ -143,6 +143,38 @@
|
|||
android:summary="@string/enablesuperbolus_summary"
|
||||
android:title="@string/enablesuperbolus" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_show_reservoirview"
|
||||
android:summary="@string/show_reservoirview_summary"
|
||||
android:title="@string/show_reservoirview" />
|
||||
|
||||
<com.andreabaccega.widget.ValidatingEditTextPreference
|
||||
android:defaultValue="80"
|
||||
android:dependency="@string/key_show_reservoirview"
|
||||
android:inputType="numberSigned"
|
||||
android:key="@string/key_reservoirview_levelwarning"
|
||||
android:maxLines="20"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:title="@string/reservoirview_levelwarning"
|
||||
validate:maxNumber="300"
|
||||
validate:minNumber="0"
|
||||
validate:testType="numericRange" />
|
||||
|
||||
<com.andreabaccega.widget.ValidatingEditTextPreference
|
||||
android:defaultValue="5"
|
||||
android:dependency="@string/key_show_reservoirview"
|
||||
android:inputType="numberSigned"
|
||||
android:key="@string/key_reservoirview_levelcritical"
|
||||
android:maxLines="20"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:title="@string/reservoirview_levelcritical"
|
||||
validate:maxNumber="300"
|
||||
validate:minNumber="0"
|
||||
validate:testType="numericRange" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
|
Loading…
Reference in a new issue