diff --git a/app/src/main/java/info/nightscout/androidaps/HistoryBrowseActivity.java b/app/src/main/java/info/nightscout/androidaps/HistoryBrowseActivity.java index 6de079abdb..a9243ab995 100644 --- a/app/src/main/java/info/nightscout/androidaps/HistoryBrowseActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/HistoryBrowseActivity.java @@ -13,6 +13,7 @@ import android.view.View; import android.widget.Button; import android.widget.ImageButton; import android.widget.SeekBar; +import android.widget.TextView; import com.jjoe64.graphview.GraphView; import com.squareup.otto.Subscribe; @@ -58,6 +59,8 @@ public class HistoryBrowseActivity extends AppCompatActivity { GraphView iobGraph; @BindView(R.id.historybrowse_seekBar) SeekBar seekBar; + @BindView(R.id.historybrowse_noprofile) + TextView noProfile; private int rangeToDisplay = 24; // for graph private long start; @@ -182,6 +185,14 @@ public class HistoryBrowseActivity extends AppCompatActivity { void updateGUI(String from) { final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); final Profile profile = MainApp.getConfigBuilder().getProfile(); + + if (profile == null) { + noProfile.setVisibility(View.VISIBLE); + return; + } else { + noProfile.setVisibility(View.GONE); + } + final String units = profile.getUnits(); double lowLineSetting = SP.getDouble("low_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java index 892d6491d4..6e2728c95b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java @@ -181,7 +181,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick profileSpinner.setSelection(p); } - final Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile != null ? profile.getUnits() : Constants.MGDL); + final Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, units); // temp target final ArrayList reasonList = new ArrayList(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java index ac03ff2e9e..e99248c966 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java @@ -444,15 +444,15 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com } private void calculateInsulin() { - ProfileStore profile = ConfigBuilderPlugin.getActiveProfileInterface().getProfile(); - if (profileSpinner == null || profileSpinner.getSelectedItem() == null) + ProfileStore profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile(); + if (profileSpinner == null || profileSpinner.getSelectedItem() == null || profileStore == null) return; // not initialized yet String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString(); Profile specificProfile; if (selectedAlternativeProfile.equals(MainApp.sResources.getString(R.string.active))) specificProfile = MainApp.getConfigBuilder().getProfile(); else - specificProfile = profile.getSpecificProfile(selectedAlternativeProfile); + specificProfile = profileStore.getSpecificProfile(selectedAlternativeProfile); // Entered values Double c_bg = SafeParse.stringToDouble(editBg.getText()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityOref0/SensitivityOref0Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityOref0/SensitivityOref0Plugin.java index eaabb4ecc9..5c6188788c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityOref0/SensitivityOref0Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityOref0/SensitivityOref0Plugin.java @@ -114,6 +114,12 @@ public class SensitivityOref0Plugin implements PluginBase, SensitivityInterface int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours); long now = System.currentTimeMillis(); + Profile profile = MainApp.getConfigBuilder().getProfile(); + + if (profile == null) { + log.debug("No profile"); + return new AutosensResult(); + } if (autosensDataTable == null || autosensDataTable.size() < 4) { log.debug("No autosens data available"); @@ -159,8 +165,6 @@ public class SensitivityOref0Plugin implements PluginBase, SensitivityInterface Double[] deviations = new Double[deviationsArray.size()]; deviations = deviationsArray.toArray(deviations); - Profile profile = MainApp.getConfigBuilder().getProfile(); - double sens = profile.getIsf(); double ratio = 1; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java index 82c513cbb9..4bf96f470b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java @@ -142,16 +142,18 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { } private static void initializeTreatmentData() { - // Treatments - double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia(); + double dia = Constants.defaultDIA; + if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null) + dia = MainApp.getConfigBuilder().getProfile().getDia(); long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia)); treatments = MainApp.getDbHelper().getTreatmentDataFromTime(fromMills, false); } private static void initializeTempBasalData() { - // Treatments - double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia(); + double dia = Constants.defaultDIA; + if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null) + dia = MainApp.getConfigBuilder().getProfile().getDia(); long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia)); tempBasals.reset().add(MainApp.getDbHelper().getTemporaryBasalsDataFromTime(fromMills, false)); @@ -159,8 +161,9 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { } private static void initializeExtendedBolusData() { - // Treatments - double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia(); + double dia = Constants.defaultDIA; + if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null) + dia = MainApp.getConfigBuilder().getProfile().getDia(); long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia)); extendedBoluses.reset().add(MainApp.getDbHelper().getExtendedBolusDataFromTime(fromMills, false)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index e75e6ec1ef..7813e02506 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -389,8 +389,10 @@ public class WatchUpdaterService extends WearableListenerService implements if (tb1 != null) { tb_before = beginBasalValue; Profile profileTB = MainApp.getConfigBuilder().getProfile(runningTime); - tb_amount = tb1.tempBasalConvertedToAbsolute(runningTime, profileTB); - tb_start = runningTime; + if (profileTB != null) { + tb_amount = tb1.tempBasalConvertedToAbsolute(runningTime, profileTB); + tb_start = runningTime; + } } diff --git a/app/src/main/res/layout/activity_historybrowse.xml b/app/src/main/res/layout/activity_historybrowse.xml index 9993243fdf..88946033f4 100644 --- a/app/src/main/res/layout/activity_historybrowse.xml +++ b/app/src/main/res/layout/activity_historybrowse.xml @@ -11,6 +11,17 @@ android:layout_height="match_parent" android:orientation="vertical"> + + + android:text="" /> diff --git a/app/src/main/res/layout/overview_fragment_nsclient.xml b/app/src/main/res/layout/overview_fragment_nsclient.xml index bf17e197c2..89b88e1ba2 100644 --- a/app/src/main/res/layout/overview_fragment_nsclient.xml +++ b/app/src/main/res/layout/overview_fragment_nsclient.xml @@ -313,7 +313,7 @@ android:id="@+id/overview_cob" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="23 g" + android:text="" android:textColor="@android:color/white" android:textSize="14sp" /> diff --git a/app/src/main/res/layout/overview_fragment_nsclient_tablet.xml b/app/src/main/res/layout/overview_fragment_nsclient_tablet.xml index 5aabda459d..781b2f2ada 100644 --- a/app/src/main/res/layout/overview_fragment_nsclient_tablet.xml +++ b/app/src/main/res/layout/overview_fragment_nsclient_tablet.xml @@ -366,7 +366,7 @@ android:gravity="start" android:orientation="horizontal" android:paddingLeft="5dp" - android:text="23 g" + android:text="" android:textColor="@android:color/white" android:textSize="14sp" /> diff --git a/app/src/main/res/layout/overview_fragment_smallheight.xml b/app/src/main/res/layout/overview_fragment_smallheight.xml index 684bbf6982..9703c32405 100644 --- a/app/src/main/res/layout/overview_fragment_smallheight.xml +++ b/app/src/main/res/layout/overview_fragment_smallheight.xml @@ -228,7 +228,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="5dp" - android:text="23 g" /> + android:text="" />