From c701b5d1257a2bf7ddf045b886961c3e7f82bb4b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 19 Jan 2017 19:21:25 +0100 Subject: [PATCH] waiting for pump message --- .../plugins/Overview/OverviewFragment.java | 52 +++++++++++-------- .../main/res/drawable/initializingborder.xml | 7 +++ .../res/layout/nsprofileviewer_fragment.xml | 2 +- app/src/main/res/layout/overview_fragment.xml | 50 +++++++++++------- app/src/main/res/values-bg/strings.xml | 2 +- app/src/main/res/values-cs/strings.xml | 2 +- app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values-ko/strings.xml | 2 +- app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/strings.xml | 3 +- 11 files changed, 79 insertions(+), 46 deletions(-) create mode 100644 app/src/main/res/drawable/initializingborder.xml diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 709037362b..2fae08892a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -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 diff --git a/app/src/main/res/drawable/initializingborder.xml b/app/src/main/res/drawable/initializingborder.xml new file mode 100644 index 0000000000..7a46a6f1eb --- /dev/null +++ b/app/src/main/res/drawable/initializingborder.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/nsprofileviewer_fragment.xml b/app/src/main/res/layout/nsprofileviewer_fragment.xml index df7b15a654..062e81ac3c 100644 --- a/app/src/main/res/layout/nsprofileviewer_fragment.xml +++ b/app/src/main/res/layout/nsprofileviewer_fragment.xml @@ -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" diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index f695299738..69deca39d4 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -21,9 +21,9 @@ + android:textAppearance="?android:attr/textAppearanceSmall" /> + android:textColor="@color/colorProfileSwitchButton" /> + android:textColor="@color/mdtp_white" /> + + + + + + android:textStyle="bold" /> @@ -178,11 +193,11 @@ android:layout_height="160dip" /> + android:layout_alignParentEnd="true" + android:layout_alignParentTop="true" /> diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 5de8b76d62..c4053b773f 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -89,7 +89,7 @@ Базални стойности: DIA (Време на действие на инсулина): IC (Инсулин/въглехидр.): - НЕ Е ЗАДАДЕН ПРОФИЛ + НЕ Е ЗАДАДЕН ПРОФИЛ Целeва КЗ: Единици: Цели diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index eb53841f1a..aadcd60f60 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -89,7 +89,7 @@ Bazál: Trvání inzulínu: Inzulínosacharidový poměr: - ŽÁDNÝ PROFIL NENASTAVEN + ŽÁDNÝ PROFIL NENASTAVEN Cíl: Jednotky: Cíle diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 666a4d2503..49c1142d50 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -142,7 +142,7 @@ Gate: Objective: Zielsetzungen - KEIN PROFIL GESETZT + KEIN PROFIL GESETZT NSClient nicht installiert. Record lost! Verwende absolute statt prozentuelle Basalwerte beim Upload zu NightScout Bisher noch kein Profil von NS geladen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index b4e038b289..9a4475b8f7 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -25,7 +25,7 @@ ISF (Factor Sensibilidad Insulina): Dosis Basal: Objetivo: - PERFIL NO ACTIVO + PERFIL NO ACTIVO Insulina: Carbohidratos: IOB: diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 45b60c3eba..bd0720a339 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -26,7 +26,7 @@ 인슐린 민감도(ISF): 기초주입: 목표: - NO PROFILE SET + NO PROFILE SET 인슐린: 탄수화물: IOB: diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 70627dba58..5b705c4a36 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -3,6 +3,7 @@ #3F51B5 #303F9F #FF4081 + #ff2630 #121212 #779ECB diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 763562ebb8..58b69bb684 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -27,7 +27,7 @@ ISF: Basal: Target: - NO PROFILE SET + NO PROFILE SET Insulin: Carbs: IOB: @@ -413,4 +413,5 @@ Eating Soon Activity Remove record: + Initializing ...