From a0d31b2118699dc1aa3f6e6ae02fcd2cc3a3780b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 11 May 2017 18:54:50 +0200 Subject: [PATCH] rename identical functions --- .../androidaps/PreferencesActivity.java | 4 +- .../interfaces/TempBasalsInterface.java | 6 +- .../interfaces/TreatmentsInterface.java | 6 +- .../IobCobCalculatorPlugin.java | 5 +- .../plugins/OpenAPSMA/OpenAPSMAPlugin.java | 8 +- .../Overview/Dialogs/WizardDialog.java | 11 +- .../plugins/Overview/OverviewFragment.java | 19 +- .../PersistentNotificationPlugin.java | 8 +- .../plugins/PumpDanaR/DanaRPlugin.java | 6 +- .../SmsCommunicatorPlugin.java | 10 +- .../plugins/TempBasals/TempBasalsPlugin.java | 10 +- .../Treatments/TreatmentsFragment.java | 253 ++++-------------- .../plugins/Treatments/TreatmentsPlugin.java | 12 +- .../fragments/TreatmentsBolusFragment.java | 253 ++++++++++++++++++ .../wearintegration/WatchUpdaterService.java | 8 +- .../XDripStatusline/StatuslinePlugin.java | 8 +- .../info/nightscout/utils/BolusWizard.java | 9 +- .../res/layout/treatments_bolus_fragment.xml | 68 +++++ .../main/res/layout/treatments_fragment.xml | 64 +---- 19 files changed, 432 insertions(+), 336 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java create mode 100644 app/src/main/res/layout/treatments_bolus_fragment.xml diff --git a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java index 0ac8f54220..d3d52298aa 100644 --- a/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/PreferencesActivity.java @@ -115,10 +115,10 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre if (danaRPlugin.isEnabled(PluginBase.PUMP) || danaRKoreanPlugin.isEnabled(PluginBase.PUMP)) { addPreferencesFromResource(R.xml.pref_danar); } - if (danaRv2Plugin.isEnabled(PluginBase.PUMP)) { + if (danaRv2Plugin != null && danaRv2Plugin.isEnabled(PluginBase.PUMP)) { addPreferencesFromResource(R.xml.pref_danarv2); } - if (danaRPlugin.isEnabled(PluginBase.PROFILE) || danaRKoreanPlugin.isEnabled(PluginBase.PROFILE) || danaRv2Plugin.isEnabled(PluginBase.PROFILE)) { + if (danaRPlugin.isEnabled(PluginBase.PROFILE) || danaRKoreanPlugin.isEnabled(PluginBase.PROFILE) || danaRv2Plugin != null && danaRv2Plugin.isEnabled(PluginBase.PROFILE)) { addPreferencesFromResource(R.xml.pref_danarprofile); } } diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/TempBasalsInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/TempBasalsInterface.java index aa01d77adb..7d455566fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/TempBasalsInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/TempBasalsInterface.java @@ -9,9 +9,9 @@ import info.nightscout.androidaps.data.IobTotal; * Created by mike on 14.06.2016. */ public interface TempBasalsInterface { - void updateTotalIOB(); - IobTotal getLastCalculation(); - IobTotal getCalculationToTime(long time); + void updateTotalIOBTempBasals(); + IobTotal getLastCalculationTempBasals(); + IobTotal getCalculationToTimeTempBasals(long time); TempBasal getTempBasal (Date time); TempBasal getExtendedBolus (Date time); diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java index 9ecacf9e22..fad29949b8 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java @@ -11,9 +11,9 @@ import info.nightscout.androidaps.data.IobTotal; */ public interface TreatmentsInterface { - void updateTotalIOB(); - IobTotal getLastCalculation(); - IobTotal getCalculationToTime(long time); + void updateTotalIOBTreatments(); + IobTotal getLastCalculationTreatments(); + IobTotal getCalculationToTimeTreatments(long time); MealData getMealData(); List getTreatments(); List getTreatments5MinBack(long time); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java index b28927d3ba..024a9f1e47 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java @@ -16,7 +16,6 @@ import java.util.Arrays; import java.util.Date; import java.util.List; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.IobTotal; @@ -339,8 +338,8 @@ public class IobCobCalculatorPlugin implements PluginBase { } else { //log.debug(">>> Cache miss " + new Date(time).toLocaleString()); } - IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getCalculationToTime(time).round(); - IobTotal basalIob = ConfigBuilderPlugin.getActiveTempBasals().getCalculationToTime(time).round(); + IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getCalculationToTimeTreatments(time).round(); + IobTotal basalIob = ConfigBuilderPlugin.getActiveTempBasals().getCalculationToTimeTempBasals(time).round(); /* if (basalIob.basaliob > 0) { log.debug(new Date(time).toLocaleString() + " basaliob: " + basalIob.basaliob ); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java index 1e7bec7471..e2b15acab1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java @@ -189,10 +189,10 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface { Date start = new Date(); TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments(); TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals(); - treatments.updateTotalIOB(); - tempBasals.updateTotalIOB(); - IobTotal bolusIob = treatments.getLastCalculation(); - IobTotal basalIob = tempBasals.getLastCalculation(); + treatments.updateTotalIOBTreatments(); + tempBasals.updateTotalIOBTempBasals(); + IobTotal bolusIob = treatments.getLastCalculationTreatments(); + IobTotal basalIob = tempBasals.getLastCalculationTempBasals(); IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round(); 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 2235bbe1dd..2ccb2eaf2b 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 @@ -34,7 +34,6 @@ import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.w3c.dom.Text; import java.text.DecimalFormat; import java.util.ArrayList; @@ -52,10 +51,8 @@ import info.nightscout.androidaps.interfaces.TempBasalsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.data.IobTotal; -import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; -import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA; import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.utils.BolusWizard; @@ -414,13 +411,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Co // IOB calculation TreatmentsInterface treatments = ConfigBuilderPlugin.getActiveTreatments(); - treatments.updateTotalIOB(); - IobTotal bolusIob = treatments.getLastCalculation(); + treatments.updateTotalIOBTreatments(); + IobTotal bolusIob = treatments.getLastCalculationTreatments(); TempBasalsInterface tempBasals = ConfigBuilderPlugin.getActiveTempBasals(); IobTotal basalIob = new IobTotal(new Date().getTime()); if (tempBasals != null) { - tempBasals.updateTotalIOB(); - basalIob = tempBasals.getLastCalculation().round(); + tempBasals.updateTotalIOBTempBasals(); + basalIob = tempBasals.getLastCalculationTempBasals().round(); } bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U"); 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 05b8d272a1..059bf6a014 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 @@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.Overview; import android.annotation.SuppressLint; import android.app.Activity; import android.content.DialogInterface; -import android.content.Intent; import android.graphics.Color; import android.graphics.DashPathEffect; import android.graphics.Paint; @@ -16,23 +15,19 @@ import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; import android.support.v7.widget.CardView; import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.PopupMenu; import android.support.v7.widget.RecyclerView; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.ContextMenu; import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; -import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; -import android.widget.ImageButton; import android.widget.LinearLayout; -import android.widget.RelativeLayout; import android.widget.TextView; import com.crashlytics.android.answers.Answers; @@ -63,11 +58,9 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.PreferencesActivity; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; @@ -76,7 +69,6 @@ import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.TempBasal; import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.Treatment; -import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBasalProfile; @@ -115,9 +107,6 @@ import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTarget import info.nightscout.utils.BolusWizard; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; -import info.nightscout.utils.ImportExportPrefs; -import info.nightscout.utils.LogDialog; -import info.nightscout.utils.PasswordProtection; import info.nightscout.utils.Round; import info.nightscout.utils.SP; import info.nightscout.utils.ToastUtils; @@ -1009,12 +998,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin)); // iob - ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB(); - IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round(); + ConfigBuilderPlugin.getActiveTreatments().updateTotalIOBTreatments(); + IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculationTreatments().round(); IobTotal basalIob = new IobTotal(new Date().getTime()); if (ConfigBuilderPlugin.getActiveTempBasals() != null) { - ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOB(); - basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculation().round(); + ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOBTempBasals(); + basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculationTempBasals().round(); } String iobtext = getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U (" diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java index 6acd7a810c..0bc56b7aad 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java @@ -144,12 +144,12 @@ public class PersistentNotificationPlugin implements PluginBase{ } //IOB - ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB(); - IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round(); + ConfigBuilderPlugin.getActiveTreatments().updateTotalIOBTreatments(); + IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculationTreatments().round(); IobTotal basalIob = new IobTotal(new Date().getTime()); if (ConfigBuilderPlugin.getActiveTempBasals() != null) { - ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOB(); - basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculation().round(); + ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOBTempBasals(); + basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculationTempBasals().round(); } String line2 = ctx.getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U (" + ctx.getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U " diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java index b18135d32d..14903f0e43 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java @@ -36,12 +36,12 @@ import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; -import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService; -import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin; +import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; -import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; +import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin; +import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService; import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.Round; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java index 2eeb5c0857..471909394d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java @@ -43,8 +43,6 @@ import info.nightscout.utils.SP; import info.nightscout.utils.SafeParse; import info.nightscout.utils.XdripCalibrations; -import static info.nightscout.androidaps.R.string.profile; - /** * Created by mike on 05.08.2016. */ @@ -256,10 +254,10 @@ public class SmsCommunicatorPlugin implements PluginBase { if (glucoseStatus != null) reply += MainApp.sResources.getString(R.string.sms_delta) + " " + NSProfile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", "; - ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB(); - IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round(); - ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOB(); - IobTotal basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculation().round(); + ConfigBuilderPlugin.getActiveTreatments().updateTotalIOBTreatments(); + IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculationTreatments().round(); + ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOBTempBasals(); + IobTotal basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculationTempBasals().round(); reply += MainApp.sResources.getString(R.string.sms_iob) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U (" + MainApp.sResources.getString(R.string.sms_bolus) + " " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U " diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsPlugin.java index cbc018278a..0558a2f5a9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/TempBasals/TempBasalsPlugin.java @@ -176,16 +176,16 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface { public void updateTotalIOBIfNeeded() { if (lastCalculationTimestamp > new Date().getTime() - 60 * 1000) return; - updateTotalIOB(); + updateTotalIOBTempBasals(); } @Override - public IobTotal getLastCalculation() { + public IobTotal getLastCalculationTempBasals() { return lastCalculation; } @Override - public IobTotal getCalculationToTime(long time) { + public IobTotal getCalculationToTimeTempBasals(long time) { checkForExpired(tempBasals); checkForExpired(extendedBoluses); IobTotal total = new IobTotal(time); @@ -208,8 +208,8 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface { } @Override - public void updateTotalIOB() { - IobTotal total = getCalculationToTime(new Date().getTime()); + public void updateTotalIOBTempBasals() { + IobTotal total = getCalculationToTimeTempBasals(new Date().getTime()); lastCalculationTimestamp = new Date().getTime(); lastCalculation = total; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java index e4442dde0f..4d436626ab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java @@ -1,51 +1,23 @@ package info.nightscout.androidaps.plugins.Treatments; -import android.app.Activity; import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Paint; import android.os.Bundle; -import android.preference.PreferenceManager; import android.support.v4.app.Fragment; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.AlertDialog; -import android.support.v7.widget.CardView; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; +import android.support.v7.app.AppCompatActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.Button; -import android.widget.LinearLayout; -import android.widget.TextView; - -import com.crashlytics.android.answers.Answers; -import com.crashlytics.android.answers.CustomEvent; -import com.squareup.otto.Subscribe; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Date; -import java.util.List; - -import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.Services.Intents; -import info.nightscout.androidaps.data.Iob; -import info.nightscout.androidaps.db.Treatment; -import info.nightscout.androidaps.events.EventTreatmentChange; -import info.nightscout.androidaps.interfaces.InsulinInterface; -import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; -import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; -import info.nightscout.utils.DateUtil; -import info.nightscout.utils.DecimalFormatter; -import info.nightscout.utils.SP; -import info.nightscout.utils.ToastUtils; +import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsBolusFragment; -public class TreatmentsFragment extends Fragment implements View.OnClickListener { +public class TreatmentsFragment extends Fragment { private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class); private static TreatmentsPlugin treatmentsPlugin = new TreatmentsPlugin(); @@ -54,112 +26,53 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener return treatmentsPlugin; } - RecyclerView recyclerView; - LinearLayoutManager llm; - - TextView iobTotal; - TextView activityTotal; - Button refreshFromNS; + SectionsPagerAdapter sectionsPagerAdapter; + ViewPager viewPager; Context context; - public class RecyclerViewAdapter extends RecyclerView.Adapter { + Fragment bolusFragment; - List treatments; + public class SectionsPagerAdapter extends FragmentPagerAdapter { - RecyclerViewAdapter(List treatments) { - this.treatments = treatments; + public SectionsPagerAdapter(FragmentManager fm) { + super(fm); } @Override - public TreatmentsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { - View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_item, viewGroup, false); - return new TreatmentsViewHolder(v); - } - - @Override - public void onBindViewHolder(TreatmentsViewHolder holder, int position) { - if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet - return; - NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile(); - InsulinInterface insulinInterface = ConfigBuilderPlugin.getActiveInsulin(); - if (profile == null || insulinInterface == null) - return; - holder.date.setText(DateUtil.dateAndTimeString(treatments.get(position).created_at)); - holder.insulin.setText(DecimalFormatter.to2Decimal(treatments.get(position).insulin) + " U"); - holder.carbs.setText(DecimalFormatter.to0Decimal(treatments.get(position).carbs) + " g"); - Iob iob = insulinInterface.iobCalc(treatments.get(position), new Date().getTime(), profile.getDia()); - holder.iob.setText(DecimalFormatter.to2Decimal(iob.iobContrib) + " U"); - holder.activity.setText(DecimalFormatter.to3Decimal(iob.activityContrib) + " U"); - holder.mealOrCorrection.setText(treatments.get(position).mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous)); - if (iob.iobContrib != 0) - holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.colorAffectingIOB)); - else - holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.cardColorBackground)); - holder.remove.setTag(treatments.get(position)); - } - - @Override - public int getItemCount() { - return treatments.size(); - } - - @Override - public void onAttachedToRecyclerView(RecyclerView recyclerView) { - super.onAttachedToRecyclerView(recyclerView); - } - - public class TreatmentsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { - CardView cv; - TextView date; - TextView insulin; - TextView carbs; - TextView iob; - TextView activity; - TextView mealOrCorrection; - LinearLayout dateLinearLayout; - TextView remove; - - TreatmentsViewHolder(View itemView) { - super(itemView); - cv = (CardView) itemView.findViewById(R.id.treatments_cardview); - date = (TextView) itemView.findViewById(R.id.treatments_date); - insulin = (TextView) itemView.findViewById(R.id.treatments_insulin); - carbs = (TextView) itemView.findViewById(R.id.treatments_carbs); - iob = (TextView) itemView.findViewById(R.id.treatments_iob); - activity = (TextView) itemView.findViewById(R.id.treatments_activity); - mealOrCorrection = (TextView) itemView.findViewById(R.id.treatments_mealorcorrection); - dateLinearLayout = (LinearLayout) itemView.findViewById(R.id.treatments_datelinearlayout); - remove = (TextView) itemView.findViewById(R.id.treatments_remove); - remove.setOnClickListener(this); - remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); + public Fragment getItem(int position) { + // getItem is called to instantiate the fragment for the given page. + switch (position){ + case 0: + return bolusFragment; + case 1: + return new Fragment(); +/* + case 2: + return iobcobActiveFragmentObject; + case 3: + return basalvsTempBasalObject; +*/ + default: + return null; } + } - @Override - public void onClick(View v) { - final Treatment treatment = (Treatment) v.getTag(); - switch (v.getId()) { - case R.id.treatments_remove: - AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); - builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.created_at)); - builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - final String _id = treatment._id; - if (_id != null && !_id.equals("")) { - MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id); - } - MainApp.getDbHelper().delete(treatment); - treatmentsPlugin.initializeData(); - updateGUI(); - Answers.getInstance().logCustom(new CustomEvent("RemoveTreatment")); - } - }); - builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); - builder.show(); - break; - } + @Override + public int getCount() { + // Show 1 total pages. + return 2; + } + + @Override + public CharSequence getPageTitle(int position) { + switch (position) { + case 0: + return getString(R.string.bolus); + case 1: + return "Empty"; } + return null; } } @@ -168,87 +81,13 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener Bundle savedInstanceState) { View view = inflater.inflate(R.layout.treatments_fragment, container, false); - recyclerView = (RecyclerView) view.findViewById(R.id.treatments_recyclerview); - recyclerView.setHasFixedSize(true); - llm = new LinearLayoutManager(view.getContext()); - recyclerView.setLayoutManager(llm); - - RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.treatments); - recyclerView.setAdapter(adapter); - - iobTotal = (TextView) view.findViewById(R.id.treatments_iobtotal); - activityTotal = (TextView) view.findViewById(R.id.treatments_iobactivitytotal); - - refreshFromNS = (Button) view.findViewById(R.id.treatments_reshreshfromnightscout); - refreshFromNS.setOnClickListener(this); + bolusFragment = new TreatmentsBolusFragment(); + sectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager()); + viewPager = (ViewPager) view.findViewById(R.id.treatments_pager); + viewPager.setAdapter(sectionsPagerAdapter); context = getContext(); - updateGUI(); return view; } - - @Override - public void onClick(View view) { - switch (view.getId()) { - case R.id.treatments_reshreshfromnightscout: - boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false); - if (nsUploadOnly) { - ToastUtils.showToastInUiThread(getContext(), this.getContext().getString(R.string.ns_upload_only_enabled)); - } else { - AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext()); - builder.setTitle(this.getContext().getString(R.string.confirmation)); - builder.setMessage(this.getContext().getString(R.string.refreshtreatmentsfromnightscout)); - builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - MainApp.getDbHelper().resetTreatments(); - treatmentsPlugin.initializeData(); - updateGUI(); - Intent restartNSClient = new Intent(Intents.ACTION_RESTART); - MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); - } - }); - builder.setNegativeButton(this.getContext().getString(R.string.cancel), null); - builder.show(); - } - break; - } - } - - @Override - public void onPause() { - super.onPause(); - MainApp.bus().unregister(this); - } - - @Override - public void onResume() { - super.onResume(); - MainApp.bus().register(this); - updateGUI(); - } - - @Subscribe - public void onStatusEvent(final EventTreatmentChange ev) { - updateGUI(); - } - - public void updateGUI() { - Activity activity = getActivity(); - NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); - if (profile == null) - return; - if (activity != null && recyclerView != null) - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.treatments), false); - if (TreatmentsPlugin.lastCalculation != null) - iobTotal.setText(DecimalFormatter.to2Decimal(TreatmentsPlugin.lastCalculation.iob) + " U"); - if (TreatmentsPlugin.lastCalculation != null) - activityTotal.setText(DecimalFormatter.to3Decimal(TreatmentsPlugin.lastCalculation.activity) + " U"); - } - }); - } - } 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 d0ba64f124..4ff92af182 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 @@ -120,16 +120,16 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { public void updateTotalIOBIfNeeded() { if (lastCalculationTimestamp > new Date().getTime() - 60 * 1000) return; - updateTotalIOB(); + updateTotalIOBTreatments(); } @Override - public IobTotal getLastCalculation() { + public IobTotal getLastCalculationTreatments() { return lastCalculation; } @Override - public IobTotal getCalculationToTime(long time) { + public IobTotal getCalculationToTimeTreatments(long time) { IobTotal total = new IobTotal(time); if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet @@ -154,8 +154,8 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { } @Override - public void updateTotalIOB() { - IobTotal total = getCalculationToTime(new Date().getTime()); + public void updateTotalIOBTreatments() { + IobTotal total = getCalculationToTimeTreatments(new Date().getTime()); lastCalculationTimestamp = new Date().getTime(); lastCalculation = total; @@ -209,7 +209,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { @Subscribe public void onStatusEvent(final EventTreatmentChange ev) { initializeData(); - updateTotalIOB(); + updateTotalIOBTreatments(); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java new file mode 100644 index 0000000000..d356912cb0 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/fragments/TreatmentsBolusFragment.java @@ -0,0 +1,253 @@ +package info.nightscout.androidaps.plugins.Treatments.fragments; + +import android.app.Activity; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.graphics.Paint; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.content.ContextCompat; +import android.support.v7.app.AlertDialog; +import android.support.v7.widget.CardView; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.crashlytics.android.answers.Answers; +import com.crashlytics.android.answers.CustomEvent; +import com.squareup.otto.Subscribe; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; +import java.util.List; + +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.Services.Intents; +import info.nightscout.androidaps.data.Iob; +import info.nightscout.androidaps.db.Treatment; +import info.nightscout.androidaps.events.EventTreatmentChange; +import info.nightscout.androidaps.interfaces.InsulinInterface; +import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; +import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; +import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; +import info.nightscout.utils.DateUtil; +import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.SP; +import info.nightscout.utils.ToastUtils; + +public class TreatmentsBolusFragment extends Fragment implements View.OnClickListener { + private static Logger log = LoggerFactory.getLogger(TreatmentsBolusFragment.class); + + private static TreatmentsPlugin treatmentsPlugin = new TreatmentsPlugin(); + + public static TreatmentsPlugin getPlugin() { + return treatmentsPlugin; + } + + RecyclerView recyclerView; + LinearLayoutManager llm; + + TextView iobTotal; + TextView activityTotal; + Button refreshFromNS; + + Context context; + + public class RecyclerViewAdapter extends RecyclerView.Adapter { + + List treatments; + + RecyclerViewAdapter(List treatments) { + this.treatments = treatments; + } + + @Override + public TreatmentsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { + View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_item, viewGroup, false); + return new TreatmentsViewHolder(v); + } + + @Override + public void onBindViewHolder(TreatmentsViewHolder holder, int position) { + if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet + return; + NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile(); + InsulinInterface insulinInterface = ConfigBuilderPlugin.getActiveInsulin(); + if (profile == null || insulinInterface == null) + return; + holder.date.setText(DateUtil.dateAndTimeString(treatments.get(position).created_at)); + holder.insulin.setText(DecimalFormatter.to2Decimal(treatments.get(position).insulin) + " U"); + holder.carbs.setText(DecimalFormatter.to0Decimal(treatments.get(position).carbs) + " g"); + Iob iob = insulinInterface.iobCalc(treatments.get(position), new Date().getTime(), profile.getDia()); + holder.iob.setText(DecimalFormatter.to2Decimal(iob.iobContrib) + " U"); + holder.activity.setText(DecimalFormatter.to3Decimal(iob.activityContrib) + " U"); + holder.mealOrCorrection.setText(treatments.get(position).mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous)); + if (iob.iobContrib != 0) + holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.colorAffectingIOB)); + else + holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.cardColorBackground)); + holder.remove.setTag(treatments.get(position)); + } + + @Override + public int getItemCount() { + return treatments.size(); + } + + @Override + public void onAttachedToRecyclerView(RecyclerView recyclerView) { + super.onAttachedToRecyclerView(recyclerView); + } + + public class TreatmentsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { + CardView cv; + TextView date; + TextView insulin; + TextView carbs; + TextView iob; + TextView activity; + TextView mealOrCorrection; + LinearLayout dateLinearLayout; + TextView remove; + + TreatmentsViewHolder(View itemView) { + super(itemView); + cv = (CardView) itemView.findViewById(R.id.treatments_cardview); + date = (TextView) itemView.findViewById(R.id.treatments_date); + insulin = (TextView) itemView.findViewById(R.id.treatments_insulin); + carbs = (TextView) itemView.findViewById(R.id.treatments_carbs); + iob = (TextView) itemView.findViewById(R.id.treatments_iob); + activity = (TextView) itemView.findViewById(R.id.treatments_activity); + mealOrCorrection = (TextView) itemView.findViewById(R.id.treatments_mealorcorrection); + dateLinearLayout = (LinearLayout) itemView.findViewById(R.id.treatments_datelinearlayout); + remove = (TextView) itemView.findViewById(R.id.treatments_remove); + remove.setOnClickListener(this); + remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); + } + + @Override + public void onClick(View v) { + final Treatment treatment = (Treatment) v.getTag(); + switch (v.getId()) { + case R.id.treatments_remove: + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); + builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.created_at)); + builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + final String _id = treatment._id; + if (_id != null && !_id.equals("")) { + MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id); + } + MainApp.getDbHelper().delete(treatment); + treatmentsPlugin.initializeData(); + updateGUI(); + Answers.getInstance().logCustom(new CustomEvent("RemoveTreatment")); + } + }); + builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); + builder.show(); + break; + } + } + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.treatments_bolus_fragment, container, false); + + recyclerView = (RecyclerView) view.findViewById(R.id.treatments_recyclerview); + recyclerView.setHasFixedSize(true); + llm = new LinearLayoutManager(view.getContext()); + recyclerView.setLayoutManager(llm); + + RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.treatments); + recyclerView.setAdapter(adapter); + + iobTotal = (TextView) view.findViewById(R.id.treatments_iobtotal); + activityTotal = (TextView) view.findViewById(R.id.treatments_iobactivitytotal); + + refreshFromNS = (Button) view.findViewById(R.id.treatments_reshreshfromnightscout); + refreshFromNS.setOnClickListener(this); + + context = getContext(); + + updateGUI(); + return view; + } + + @Override + public void onClick(View view) { + switch (view.getId()) { + case R.id.treatments_reshreshfromnightscout: + boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false); + if (nsUploadOnly) { + ToastUtils.showToastInUiThread(getContext(), this.getContext().getString(R.string.ns_upload_only_enabled)); + } else { + AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext()); + builder.setTitle(this.getContext().getString(R.string.confirmation)); + builder.setMessage(this.getContext().getString(R.string.refreshtreatmentsfromnightscout)); + builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + MainApp.getDbHelper().resetTreatments(); + treatmentsPlugin.initializeData(); + updateGUI(); + Intent restartNSClient = new Intent(Intents.ACTION_RESTART); + MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient); + } + }); + builder.setNegativeButton(this.getContext().getString(R.string.cancel), null); + builder.show(); + } + break; + } + } + + @Override + public void onPause() { + super.onPause(); + MainApp.bus().unregister(this); + } + + @Override + public void onResume() { + super.onResume(); + MainApp.bus().register(this); + updateGUI(); + } + + @Subscribe + public void onStatusEvent(final EventTreatmentChange ev) { + updateGUI(); + } + + public void updateGUI() { + Activity activity = getActivity(); + NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); + if (profile == null) + return; + if (activity != null && recyclerView != null) + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.treatments), false); + if (TreatmentsPlugin.lastCalculation != null) + iobTotal.setText(DecimalFormatter.to2Decimal(TreatmentsPlugin.lastCalculation.iob) + " U"); + if (TreatmentsPlugin.lastCalculation != null) + activityTotal.setText(DecimalFormatter.to3Decimal(TreatmentsPlugin.lastCalculation.activity) + " U"); + } + }); + } + +} 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 2a2ef68156..8d1da0dd2d 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 @@ -544,10 +544,10 @@ public class WatchUpdaterService extends WearableListenerService implements } //IOB - MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB(); - IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round(); - MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB(); - IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round(); + MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOBTreatments(); + IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculationTreatments().round(); + MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOBTempBasals(); + IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculationTempBasals().round(); status += (shortString?"":(getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob); if (mPrefs.getBoolean("wear_detailediob", true)) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java index 3bac27c168..45dd406eeb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java @@ -170,10 +170,10 @@ public class StatuslinePlugin implements PluginBase { } //IOB - MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB(); - IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round(); - MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB(); - IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round(); + MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOBTreatments(); + IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculationTreatments().round(); + MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOBTempBasals(); + IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculationTempBasals().round(); status += (shortString ? "" : (ctx.getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob); diff --git a/app/src/main/java/info/nightscout/utils/BolusWizard.java b/app/src/main/java/info/nightscout/utils/BolusWizard.java index f9d3748f3a..c8aeeff41e 100644 --- a/app/src/main/java/info/nightscout/utils/BolusWizard.java +++ b/app/src/main/java/info/nightscout/utils/BolusWizard.java @@ -4,7 +4,6 @@ import org.json.JSONObject; import java.util.Date; -import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.interfaces.TempBasalsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface; @@ -88,13 +87,13 @@ public class BolusWizard { // Insulin from IOB // IOB calculation TreatmentsInterface treatments = ConfigBuilderPlugin.getActiveTreatments(); - treatments.updateTotalIOB(); - IobTotal bolusIob = treatments.getLastCalculation(); + treatments.updateTotalIOBTreatments(); + IobTotal bolusIob = treatments.getLastCalculationTreatments(); TempBasalsInterface tempBasals = ConfigBuilderPlugin.getActiveTempBasals(); IobTotal basalIob = new IobTotal(new Date().getTime()); if (tempBasals != null) { - tempBasals.updateTotalIOB(); - basalIob = tempBasals.getLastCalculation().round(); + tempBasals.updateTotalIOBTempBasals(); + basalIob = tempBasals.getLastCalculationTempBasals().round(); } insulingFromBolusIOB = includeBolusIOB ? -bolusIob.iob : 0d; diff --git a/app/src/main/res/layout/treatments_bolus_fragment.xml b/app/src/main/res/layout/treatments_bolus_fragment.xml new file mode 100644 index 0000000000..ae7191a5dd --- /dev/null +++ b/app/src/main/res/layout/treatments_bolus_fragment.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + +