waiting for pump message

This commit is contained in:
Milos Kozak 2017-01-19 19:21:25 +01:00
parent f8feaf565b
commit c701b5d125
11 changed files with 79 additions and 46 deletions

View file

@ -81,7 +81,6 @@ import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotificati
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
import info.nightscout.androidaps.plugins.TempBasals.TempBasalsPlugin;
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.BolusWizard;
@ -113,6 +112,7 @@ public class OverviewFragment extends Fragment {
TextView iobView;
TextView apsModeView;
TextView tempTargetView;
TextView initializingView;
GraphView bgGraph;
CheckBox showPredictionView;
@ -121,7 +121,6 @@ public class OverviewFragment extends Fragment {
LinearLayout cancelTempLayout;
LinearLayout acceptTempLayout;
LinearLayout quickWizardLayout;
Button cancelTempButton;
Button treatmentButton;
Button wizardButton;
@ -158,6 +157,7 @@ public class OverviewFragment extends Fragment {
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
basalLayout = (LinearLayout) view.findViewById(R.id.overview_basallayout);
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
initializingView = (TextView) view.findViewById(R.id.overview_initializing);
iobView = (TextView) view.findViewById(R.id.overview_iob);
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
@ -171,7 +171,6 @@ public class OverviewFragment extends Fragment {
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizard);
quickWizardLayout = (LinearLayout) view.findViewById(R.id.overview_quickwizardlayout);
showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
@ -285,7 +284,7 @@ public class OverviewFragment extends Fragment {
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
if (quickWizardEntry != null && lastBG != null) {
quickWizardLayout.setVisibility(View.VISIBLE);
quickWizardButton.setVisibility(View.VISIBLE);
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText();
BolusWizard wizard = new BolusWizard();
wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), lastBG.valueToUnits(profile.getUnits()), 0d, true, true);
@ -464,8 +463,14 @@ public class OverviewFragment extends Fragment {
updateNotifications();
BgReading actualBG = MainApp.getDbHelper().actualBg();
BgReading lastBG = MainApp.getDbHelper().lastBg();
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null || MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) // app not initialized yet
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null || MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) {// app not initialized yet
initializingView.setText(R.string.noprofileset);
initializingView.setVisibility(View.VISIBLE);
return;
} else {
initializingView.setVisibility(View.GONE);
}
// Skip if not initialized yet
if (bgGraph == null)
@ -583,34 +588,24 @@ public class OverviewFragment extends Fragment {
});
activeProfileView.setLongClickable(true);
if (profile == null || !pump.isInitialized()) {
// disable all treatment buttons because we are not able to check constraints without profile
wizardButton.setVisibility(View.INVISIBLE);
treatmentButton.setVisibility(View.INVISIBLE);
return;
} else {
wizardButton.setVisibility(View.VISIBLE);
treatmentButton.setVisibility(View.VISIBLE);
}
String units = profile.getUnits();
// QuickWizard button
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
if (quickWizardEntry != null && lastBG != null && pump.isInitialized()) {
quickWizardLayout.setVisibility(View.VISIBLE);
quickWizardButton.setVisibility(View.VISIBLE);
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText() + " " + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
BolusWizard wizard = new BolusWizard();
wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), lastBG.valueToUnits(profile.getUnits()), 0d, true, true);
text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
quickWizardButton.setText(text);
if (wizard.calculatedTotalInsulin <= 0)
quickWizardLayout.setVisibility(View.GONE);
quickWizardButton.setVisibility(View.GONE);
} else
quickWizardLayout.setVisibility(View.GONE);
quickWizardButton.setVisibility(View.GONE);
String units = profile.getUnits();
// **** BG value ****
if (lastBG != null && bgView != null) {
if (lastBG != null) {
bgView.setText(lastBG.valueToUnitsToString(profile.getUnits()));
arrowView.setText(lastBG.directionToSymbol());
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
@ -885,6 +880,21 @@ public class OverviewFragment extends Fragment {
bgGraph.getSecondScale().setMaxY(maxBgValue / lowLine * maxBasalValueFound * 1.2d);
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(MainApp.instance().getResources().getColor(R.color.background_material_dark)); // same color as backround = hide
}
// Pump not initialized message
if (!pump.isInitialized()) {
// disable all treatment buttons because we are not able to check constraints without profile
wizardButton.setVisibility(View.INVISIBLE);
treatmentButton.setVisibility(View.INVISIBLE);
quickWizardButton.setVisibility(View.INVISIBLE);
initializingView.setText(R.string.waitingforpump);
initializingView.setVisibility(View.VISIBLE);
} else {
wizardButton.setVisibility(View.VISIBLE);
treatmentButton.setVisibility(View.VISIBLE);
initializingView.setVisibility(View.GONE);
}
}
//Notifications

View file

@ -0,0 +1,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="@color/colorInitializingBorder" />
<stroke android:width="1dip" android:color="@android:color/white"/>
<corners
android:radius="2dp" >
</corners>
</shape>

View file

@ -17,7 +17,7 @@
android:id="@+id/profileview_noprofile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/nsprofileview_noprofile_text"
android:text="@string/noprofileset"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@android:color/holo_red_light"
android:textStyle="bold"

View file

@ -21,9 +21,9 @@
</android.support.v7.widget.RecyclerView>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="2dp">
<TextView
@ -31,13 +31,13 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_weight="0.2"
android:background="@drawable/loopmodeborder"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Open Loop"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="0.2" />
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/overview_activeprofile"
@ -45,29 +45,44 @@
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:layout_weight="0.5"
android:background="@drawable/pillborder"
android:gravity="center_vertical|center_horizontal"
android:text="Profile"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Profile"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/colorProfileSwitchButton"
android:layout_weight="0.5" />
android:textColor="@color/colorProfileSwitchButton" />
<TextView
android:id="@+id/overview_temptarget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:layout_weight="0.2"
android:background="@drawable/temptargetborder"
android:gravity="center_vertical|center_horizontal"
android:text="TempTarget"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="TempTarget"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/mdtp_white"
android:layout_weight="0.2" />
android:textColor="@color/mdtp_white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="2dp">
<TextView
android:id="@+id/overview_initializing"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/initializingborder"
android:gravity="center_vertical|center_horizontal"
android:text="@string/initializing"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginTop="10dp" />
</LinearLayout>
<LinearLayout
@ -90,13 +105,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:layout_marginTop="-15dp"
android:gravity="center_vertical"
android:paddingLeft="-5dp"
android:paddingRight="-10dp"
android:text="→"
android:textSize="70dp"
android:textStyle="bold"
android:layout_marginTop="-15dp" />
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
@ -134,9 +149,9 @@
</LinearLayout>
<LinearLayout
android:id="@+id/overview_basallayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/overview_basallayout"
android:gravity="center_horizontal"
android:orientation="horizontal">
@ -178,11 +193,11 @@
android:layout_height="160dip" />
<CheckBox
android:id="@+id/overview_showprediction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/overview_showprediction"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
<LinearLayout
@ -259,7 +274,6 @@
</LinearLayout>
<LinearLayout
android:id="@+id/overview_quickwizardlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

View file

@ -89,7 +89,7 @@
<string name="nsprofileview_basal_label">Базални стойности:</string>
<string name="nsprofileview_dia_label">DIA (Време на действие на инсулина):</string>
<string name="nsprofileview_ic_label">IC (Инсулин/въглехидр.):</string>
<string name="nsprofileview_noprofile_text">НЕ Е ЗАДАДЕН ПРОФИЛ</string>
<string name="noprofileset">НЕ Е ЗАДАДЕН ПРОФИЛ</string>
<string name="nsprofileview_target_label">Целeва КЗ:</string>
<string name="nsprofileview_units_label">Единици:</string>
<string name="objectives">Цели</string>

View file

@ -89,7 +89,7 @@
<string name="nsprofileview_basal_label">Bazál:</string>
<string name="nsprofileview_dia_label">Trvání inzulínu:</string>
<string name="nsprofileview_ic_label">Inzulínosacharidový poměr:</string>
<string name="nsprofileview_noprofile_text">ŽÁDNÝ PROFIL NENASTAVEN</string>
<string name="noprofileset">ŽÁDNÝ PROFIL NENASTAVEN</string>
<string name="nsprofileview_target_label">Cíl:</string>
<string name="nsprofileview_units_label">Jednotky:</string>
<string name="objectives">Cíle</string>

View file

@ -142,7 +142,7 @@
<string name="objectives_gate_label_string">Gate:</string>
<string name="objectives_objective_label_string">Objective:</string>
<string name="objectives">Zielsetzungen</string>
<string name="nsprofileview_noprofile_text">KEIN PROFIL GESETZT</string>
<string name="noprofileset">KEIN PROFIL GESETZT</string>
<string name="nsclientnotinstalled">NSClient nicht installiert. Record lost!</string>
<string name="ns_sync_use_absolute_title">Verwende absolute statt prozentuelle Basalwerte beim Upload zu NightScout</string>
<string name="noprofile">Bisher noch kein Profil von NS geladen</string>

View file

@ -25,7 +25,7 @@
<string name="nsprofileview_isf_label">ISF (Factor Sensibilidad Insulina):</string>
<string name="nsprofileview_basal_label">Dosis Basal:</string>
<string name="nsprofileview_target_label">Objetivo:</string>
<string name="nsprofileview_noprofile_text">PERFIL NO ACTIVO</string>
<string name="noprofileset">PERFIL NO ACTIVO</string>
<string name="treatments_insulin_label_string">Insulina:</string>
<string name="treatments_carbs_label_string">Carbohidratos:</string>
<string name="treatments_iob_label_string">IOB:</string>

View file

@ -26,7 +26,7 @@
<string name="nsprofileview_isf_label">인슐린 민감도(ISF):</string>
<string name="nsprofileview_basal_label">기초주입:</string>
<string name="nsprofileview_target_label">목표:</string>
<string name="nsprofileview_noprofile_text">NO PROFILE SET</string>
<string name="noprofileset">NO PROFILE SET</string>
<string name="treatments_insulin_label_string">인슐린:</string>
<string name="treatments_carbs_label_string">탄수화물:</string>
<string name="treatments_iob_label_string">IOB:</string>

View file

@ -3,6 +3,7 @@
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorInitializingBorder">#ff2630</color>
<color name="cardColorBackground">#121212</color>
<color name="cardObjectiveText">#779ECB</color>

View file

@ -27,7 +27,7 @@
<string name="nsprofileview_isf_label">ISF:</string>
<string name="nsprofileview_basal_label">Basal:</string>
<string name="nsprofileview_target_label">Target:</string>
<string name="nsprofileview_noprofile_text">NO PROFILE SET</string>
<string name="noprofileset">NO PROFILE SET</string>
<string name="treatments_insulin_label_string">Insulin:</string>
<string name="treatments_carbs_label_string">Carbs:</string>
<string name="treatments_iob_label_string">IOB:</string>
@ -413,4 +413,5 @@
<string name="eatingsoon">Eating Soon</string>
<string name="activity">Activity</string>
<string name="removerecord">Remove record:</string>
<string name="initializing">Initializing ...</string>
</resources>