From b40cf992014fe90043106380f2b47f557e4ce6ad Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 3 Jun 2017 22:43:35 +0200 Subject: [PATCH] gui tweaking --- .../info/nightscout/androidaps/Config.java | 1 + .../androidaps/Services/DataService.java | 3 +- .../androidaps/db/CareportalEvent.java | 1 + .../Careportal/CareportalFragment.java | 73 +- .../IobCobCalculator/AutosensData.java | 4 + .../IobCobCalculatorPlugin.java | 10 +- .../androidaps/plugins/Loop/LoopPlugin.java | 5 +- .../services/NSClientService.java | 3 +- .../plugins/Overview/OverviewFragment.java | 91 ++- .../main/res/layout/careportal_fragment.xml | 1 - .../res/layout/careportal_stats_fragment.xml | 46 +- app/src/main/res/layout/overview_fragment.xml | 21 +- .../res/layout/overview_fragment_tablet.xml | 626 ++++++++++++++++++ app/src/main/res/values-cs/strings.xml | 8 +- app/src/main/res/values-sw600dp/layout.xml | 3 + app/src/main/res/values/layout.xml | 3 + app/src/main/res/values/strings.xml | 1 + 17 files changed, 832 insertions(+), 68 deletions(-) create mode 100644 app/src/main/res/layout/overview_fragment_tablet.xml create mode 100644 app/src/main/res/values-sw600dp/layout.xml create mode 100644 app/src/main/res/values/layout.xml diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index d478abae0b..2f7f6f5327 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -41,6 +41,7 @@ public class Config { public static final boolean logPumpActions = true; public static final boolean logSMSComm = true; public static final boolean logCongigBuilderActions = true; + public static final boolean logAutosensData = false; // DanaR specific public static final boolean logDanaBTComm = true; diff --git a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java index cb0e1c6835..82d94ef605 100644 --- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java @@ -501,7 +501,8 @@ public class DataService extends IntentService { if (trJson.has("eventType") && ( trJson.getString("eventType").equals(CareportalEvent.SITECHANGE) || trJson.getString("eventType").equals(CareportalEvent.INSULINCHANGE) || - trJson.getString("eventType").equals(CareportalEvent.SENSORCHANGE) + trJson.getString("eventType").equals(CareportalEvent.SENSORCHANGE) || + trJson.getString("eventType").equals(CareportalEvent.PUMPBATTERYCHANGE) )) { if (Config.logIncommingData) log.debug("Processing CareportalEvent record: " + trJson.toString()); diff --git a/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java b/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java index 8411799081..fd2b18c5c4 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java +++ b/app/src/main/java/info/nightscout/androidaps/db/CareportalEvent.java @@ -51,6 +51,7 @@ public class CareportalEvent { public static final String SITECHANGE = "Site Change"; public static final String INSULINCHANGE = "Insulin Change"; public static final String SENSORCHANGE = "Sensor Change"; + public static final String PUMPBATTERYCHANGE = "Pump Battery Change"; public CareportalEvent() { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java index 557dad36cd..2eeb52785c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/CareportalFragment.java @@ -25,6 +25,7 @@ public class CareportalFragment extends Fragment implements View.OnClickListener TextView iage; TextView cage; TextView sage; + TextView pbage; static public CareportalPlugin getPlugin() { if (careportalPlugin == null) { @@ -34,25 +35,25 @@ public class CareportalFragment extends Fragment implements View.OnClickListener } // bg,insulin,carbs,prebolus,duration,percent,absolute,profile,split,temptarget - final OptionsToShow bgcheck = new OptionsToShow(R.id.careportal_bgcheck, R.string.careportal_bgcheck, true, true, true, false, false, false, false, false, false, false); - final OptionsToShow snackbolus = new OptionsToShow(R.id.careportal_snackbolus, R.string.careportal_snackbolus, true, true, true, true, false, false, false, false, false, false); - final OptionsToShow mealbolus = new OptionsToShow(R.id.careportal_mealbolus, R.string.careportal_mealbolus, true, true, true, true, false, false, false, false, false, false); - final OptionsToShow correctionbolus = new OptionsToShow(R.id.careportal_correctionbolus, R.string.careportal_correctionbolus, true, true, true, true, false, false, false, false, false, false); - final OptionsToShow carbcorrection = new OptionsToShow(R.id.careportal_carbscorrection, R.string.careportal_carbscorrection, true, false, true, false, false, false, false, false, false, false); - final OptionsToShow combobolus = new OptionsToShow(R.id.careportal_combobolus, R.string.careportal_combobolus, true, true, true, true, true, false, false, false, true, false); - final OptionsToShow announcement = new OptionsToShow(R.id.careportal_announcement, R.string.careportal_announcement, true, false, false, false, false, false, false, false, false, false); - final OptionsToShow note = new OptionsToShow(R.id.careportal_note, R.string.careportal_note, true, false, false, false, true, false, false, false, false, false); - final OptionsToShow question = new OptionsToShow(R.id.careportal_question, R.string.careportal_question, true, false, false, false, false, false, false, false, false, false); - final OptionsToShow exercise = new OptionsToShow(R.id.careportal_exercise, R.string.careportal_exercise, false, false, false, false, true, false, false, false, false, false); - final OptionsToShow sitechange = new OptionsToShow(R.id.careportal_pumpsitechange, R.string.careportal_pumpsitechange, true, true, false, false, false, false, false, false, false, false); - final OptionsToShow sensorstart = new OptionsToShow(R.id.careportal_cgmsensorstart, R.string.careportal_cgmsensorstart, true, false, false, false, false, false, false, false, false, false); - final OptionsToShow sensorchange = new OptionsToShow(R.id.careportal_cgmsensorinsert, R.string.careportal_cgmsensorinsert, true, false, false, false, false, false, false, false, false, false); - final OptionsToShow insulinchange = new OptionsToShow(R.id.careportal_insulincartridgechange, R.string.careportal_insulincartridgechange, true, false, false, false, false, false, false, false, false, false); - final OptionsToShow tempbasalstart = new OptionsToShow(R.id.careportal_tempbasalstart, R.string.careportal_tempbasalstart, true, false, false, false, true, true, true, false, false, false); - final OptionsToShow tempbasalend = new OptionsToShow(R.id.careportal_tempbasalend, R.string.careportal_tempbasalend, true, false, false, false, false, false, false, false, false, false); - final OptionsToShow profileswitch = new OptionsToShow(R.id.careportal_profileswitch, R.string.careportal_profileswitch, true, false, false, false, true, false, false, true, false, false); - final OptionsToShow openapsoffline = new OptionsToShow(R.id.careportal_openapsoffline, R.string.careportal_openapsoffline, false, false, false, false, true, false, false, false, false, false); - final OptionsToShow temptarget = new OptionsToShow(R.id.careportal_temporarytarget, R.string.careportal_temporarytarget, false, false, false, false, true, false, false, false, false, true); + static final OptionsToShow bgcheck = new OptionsToShow(R.id.careportal_bgcheck, R.string.careportal_bgcheck, true, true, true, false, false, false, false, false, false, false); + static final OptionsToShow snackbolus = new OptionsToShow(R.id.careportal_snackbolus, R.string.careportal_snackbolus, true, true, true, true, false, false, false, false, false, false); + static final OptionsToShow mealbolus = new OptionsToShow(R.id.careportal_mealbolus, R.string.careportal_mealbolus, true, true, true, true, false, false, false, false, false, false); + static final OptionsToShow correctionbolus = new OptionsToShow(R.id.careportal_correctionbolus, R.string.careportal_correctionbolus, true, true, true, true, false, false, false, false, false, false); + static final OptionsToShow carbcorrection = new OptionsToShow(R.id.careportal_carbscorrection, R.string.careportal_carbscorrection, true, false, true, false, false, false, false, false, false, false); + static final OptionsToShow combobolus = new OptionsToShow(R.id.careportal_combobolus, R.string.careportal_combobolus, true, true, true, true, true, false, false, false, true, false); + static final OptionsToShow announcement = new OptionsToShow(R.id.careportal_announcement, R.string.careportal_announcement, true, false, false, false, false, false, false, false, false, false); + static final OptionsToShow note = new OptionsToShow(R.id.careportal_note, R.string.careportal_note, true, false, false, false, true, false, false, false, false, false); + static final OptionsToShow question = new OptionsToShow(R.id.careportal_question, R.string.careportal_question, true, false, false, false, false, false, false, false, false, false); + static final OptionsToShow exercise = new OptionsToShow(R.id.careportal_exercise, R.string.careportal_exercise, false, false, false, false, true, false, false, false, false, false); + static final OptionsToShow sitechange = new OptionsToShow(R.id.careportal_pumpsitechange, R.string.careportal_pumpsitechange, true, true, false, false, false, false, false, false, false, false); + static final OptionsToShow sensorstart = new OptionsToShow(R.id.careportal_cgmsensorstart, R.string.careportal_cgmsensorstart, true, false, false, false, false, false, false, false, false, false); + static final OptionsToShow sensorchange = new OptionsToShow(R.id.careportal_cgmsensorinsert, R.string.careportal_cgmsensorinsert, true, false, false, false, false, false, false, false, false, false); + static final OptionsToShow insulinchange = new OptionsToShow(R.id.careportal_insulincartridgechange, R.string.careportal_insulincartridgechange, true, false, false, false, false, false, false, false, false, false); + static final OptionsToShow tempbasalstart = new OptionsToShow(R.id.careportal_tempbasalstart, R.string.careportal_tempbasalstart, true, false, false, false, true, true, true, false, false, false); + static final OptionsToShow tempbasalend = new OptionsToShow(R.id.careportal_tempbasalend, R.string.careportal_tempbasalend, true, false, false, false, false, false, false, false, false, false); + static final OptionsToShow profileswitch = new OptionsToShow(R.id.careportal_profileswitch, R.string.careportal_profileswitch, true, false, false, false, true, false, false, true, false, false); + static final OptionsToShow openapsoffline = new OptionsToShow(R.id.careportal_openapsoffline, R.string.careportal_openapsoffline, false, false, false, false, true, false, false, false, false, false); + static final OptionsToShow temptarget = new OptionsToShow(R.id.careportal_temporarytarget, R.string.careportal_temporarytarget, false, false, false, false, true, false, false, false, false, true); @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -82,6 +83,7 @@ public class CareportalFragment extends Fragment implements View.OnClickListener iage = (TextView) view.findViewById(R.id.careportal_insulinage); cage = (TextView) view.findViewById(R.id.careportal_canulaage); sage = (TextView) view.findViewById(R.id.careportal_sensorage); + pbage = (TextView) view.findViewById(R.id.careportal_pbage); updateGUI(); return view; @@ -89,9 +91,12 @@ public class CareportalFragment extends Fragment implements View.OnClickListener @Override public void onClick(View view) { - FragmentManager manager = getFragmentManager(); + action(view.getId(), getFragmentManager()); + } + + public static void action(int id, FragmentManager manager) { NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); - switch (view.getId()) { + switch (id) { case R.id.careportal_bgcheck: newDialog.setOptions(bgcheck); break; @@ -175,18 +180,32 @@ public class CareportalFragment extends Fragment implements View.OnClickListener void updateGUI() { Activity activity = getActivity(); + updateAge(activity, sage, iage, cage, pbage); + } + + public static void updateAge(Activity activity, final TextView sage, final TextView iage, final TextView cage, final TextView pbage) { if (activity != null) { activity.runOnUiThread( new Runnable() { @Override public void run() { CareportalEvent careportalEvent; - careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE); - sage.setText(careportalEvent != null ? careportalEvent.age() : MainApp.sResources.getString(R.string.notavailable)); - careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE); - iage.setText(careportalEvent != null ? careportalEvent.age() : MainApp.sResources.getString(R.string.notavailable)); - careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE); - cage.setText(careportalEvent != null ? careportalEvent.age() : MainApp.sResources.getString(R.string.notavailable)); + if (sage != null) { + careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE); + sage.setText(careportalEvent != null ? careportalEvent.age() : MainApp.sResources.getString(R.string.notavailable)); + } + if (iage != null) { + careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE); + iage.setText(careportalEvent != null ? careportalEvent.age() : MainApp.sResources.getString(R.string.notavailable)); + } + if (cage != null) { + careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE); + cage.setText(careportalEvent != null ? careportalEvent.age() : MainApp.sResources.getString(R.string.notavailable)); + } + if (pbage != null) { + careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.PUMPBATTERYCHANGE); + pbage.setText(careportalEvent != null ? careportalEvent.age() : MainApp.sResources.getString(R.string.notavailable)); + } } } ); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java index 32ed9f8ed5..2c919c9fe8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java @@ -21,4 +21,8 @@ public class AutosensData { return "AutosensData: " + new Date(time).toLocaleString() + " " + pastSensitivity + " Delta=" + delta + " Bgi=" + bgi + " Deviation=" + deviation + " Absorbed=" + absorbed + " CarbsFromBolus=" + carbsFromBolus + " COB=" + cob; } + public int minOld() { + return (int) ((new Date().getTime() - time) / 1000 / 60); + } + } 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 967dfc2684..7230f7b1fb 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,6 +16,7 @@ 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; @@ -310,7 +311,8 @@ public class IobCobCalculatorPlugin implements PluginBase { previous = autosensData; autosensDataTable.put(bgTime, autosensData); - log.debug(autosensData.log(bgTime)); + if (Config.logAutosensData) + log.debug(autosensData.log(bgTime)); } } MainApp.bus().post(new EventAutosensCalculationFinished()); @@ -545,7 +547,8 @@ public class IobCobCalculatorPlugin implements PluginBase { log.debug("Invalidating cached data to: " + new Date(time).toLocaleString()); for (int index = iobTable.size() - 1; index >= 0; index--) { if (iobTable.keyAt(index) > time) { - log.debug("Removing from iobTable: " + new Date(iobTable.keyAt(index)).toLocaleString()); + if (Config.logAutosensData) + log.debug("Removing from iobTable: " + new Date(iobTable.keyAt(index)).toLocaleString()); iobTable.removeAt(index); } else { break; @@ -553,7 +556,8 @@ public class IobCobCalculatorPlugin implements PluginBase { } for (int index = autosensDataTable.size() - 1; index >= 0; index--) { if (autosensDataTable.keyAt(index) > time) { - log.debug("Removing from autosensDataTable: " + new Date(autosensDataTable.keyAt(index)).toLocaleString()); + if (Config.logAutosensData) + log.debug("Removing from autosensDataTable: " + new Date(autosensDataTable.keyAt(index)).toLocaleString()); autosensDataTable.removeAt(index); } else { break; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java index b7e4aef717..6fa9e6d677 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java @@ -12,6 +12,7 @@ import android.support.v7.app.NotificationCompat; import com.squareup.otto.Subscribe; +import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,8 +33,10 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui; import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui; import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification; +import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin; import info.nightscout.utils.NSUpload; import info.nightscout.utils.SP; +import info.nightscout.utils.SafeParse; /** * Created by mike on 05.08.2016. @@ -257,7 +260,7 @@ public class LoopPlugin implements PluginBase { lastRun.source = ((PluginBase) usedAPS).getName(); lastRun.setByPump = null; - if (constraintsInterface.isClosedModeEnabled()) { + if (constraintsInterface.isClosedModeEnabled()) { if (result.changeRequested) { final PumpEnactResult waiting = new PumpEnactResult(); final PumpEnactResult previousResult = lastRun.setByPump; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java index e51b70a014..c618b39f51 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/services/NSClientService.java @@ -394,12 +394,11 @@ public class NSClientService extends Service { latestDateInReceivedData = treatment.getMills(); if (treatment.getAction() == null) { - if (!isCurrent(treatment)) continue; addedTreatments.put(jsonTreatment); } else if (treatment.getAction().equals("update")) { - if (!isCurrent(treatment)) continue; updatedTreatments.put(jsonTreatment); } else if (treatment.getAction().equals("remove")) { + if (!isCurrent(treatment)) continue; removedTreatments.put(jsonTreatment); } } 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 1de6b1e6be..79894af82e 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 @@ -25,7 +25,6 @@ import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.view.ViewTreeObserver; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; @@ -55,6 +54,8 @@ import java.util.Calendar; import java.util.Date; import java.util.Iterator; import java.util.List; +import java.util.Timer; +import java.util.TimerTask; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -67,10 +68,12 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; +import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.DatabaseHelper; +import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TemporaryBasal; @@ -87,6 +90,7 @@ import info.nightscout.androidaps.events.EventTempTargetChange; import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.plugins.Careportal.CareportalFragment; import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; @@ -96,7 +100,6 @@ import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugi import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification; -import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA; import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog; @@ -129,16 +132,17 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, return overviewPlugin; } + TextView timeView; TextView bgView; TextView arrowView; TextView timeAgoView; TextView deltaView; TextView avgdeltaView; - TextView runningTempView; TextView baseBasalView; - LinearLayout basalLayout; + TextView extendedBolusView; TextView activeProfileView; TextView iobView; + TextView cobView; TextView apsModeView; TextView tempTargetView; TextView pumpStatusView; @@ -147,6 +151,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, GraphView bgGraph; GraphView iobGraph; + TextView iage; + TextView cage; + TextView sage; + TextView pbage; + CheckBox showPredictionView; CheckBox showBasalsView; CheckBox showIobView; @@ -179,6 +188,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor(); private static ScheduledFuture scheduledUpdate = null; + final Handler timeHandler = new Handler(); + public OverviewFragment() { super(); if (sHandlerThread == null) { @@ -202,12 +213,15 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, View view; - if (smallHeight) { + if (MainApp.sResources.getBoolean(R.bool.isTablet)) { + view = inflater.inflate(R.layout.overview_fragment_tablet, container, false); + } else if (smallHeight) { view = inflater.inflate(R.layout.overview_fragment_smallheight, container, false); } else { view = inflater.inflate(R.layout.overview_fragment, container, false); } + timeView = (TextView) view.findViewById(R.id.overview_time); bgView = (TextView) view.findViewById(R.id.overview_bg); arrowView = (TextView) view.findViewById(R.id.overview_arrow); if (smallWidth) { @@ -216,9 +230,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, timeAgoView = (TextView) view.findViewById(R.id.overview_timeago); deltaView = (TextView) view.findViewById(R.id.overview_delta); avgdeltaView = (TextView) view.findViewById(R.id.overview_avgdelta); - runningTempView = (TextView) view.findViewById(R.id.overview_runningtemp); baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal); - basalLayout = (LinearLayout) view.findViewById(R.id.overview_basallayout); + extendedBolusView = (TextView) view.findViewById(R.id.overview_extendedbolus); activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile); pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus); loopStatusLayout = (LinearLayout) view.findViewById(R.id.overview_looplayout); @@ -227,9 +240,15 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, pumpStatusView.setBackgroundColor(MainApp.sResources.getColor(R.color.colorInitializingBorder)); iobView = (TextView) view.findViewById(R.id.overview_iob); + cobView = (TextView) view.findViewById(R.id.overview_cob); apsModeView = (TextView) view.findViewById(R.id.overview_apsmode); tempTargetView = (TextView) view.findViewById(R.id.overview_temptarget); + iage = (TextView) view.findViewById(R.id.careportal_insulinage); + cage = (TextView) view.findViewById(R.id.careportal_canulaage); + sage = (TextView) view.findViewById(R.id.careportal_sensorage); + pbage = (TextView) view.findViewById(R.id.careportal_pbage); + bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph); iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph); @@ -302,6 +321,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } }); + Timer timeTimer = new Timer(); + timeTimer.schedule(new TimerTask() { + @Override + public void run() { + timeUpdate(); + } + }, 0, 30000); + return view; } @@ -823,6 +850,20 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } } + private void timeUpdate() { + Activity activity = getActivity(); + if (activity != null) + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + if (timeView != null) { //must not exists + timeView.setText(DateUtil.timeString(new Date())); + } + log.debug("Time updated"); + } + }); + } + public void scheduleUpdateGUI(final String from) { class UpdateRunnable implements Runnable { public void run() { @@ -850,6 +891,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, public void updateGUI(String from) { log.debug("updateGUI entered from: " + from); updateNotifications(); + CareportalFragment.updateAge(getActivity(), sage, iage, cage, pbage); BgReading actualBG = DatabaseHelper.actualBg(); BgReading lastBG = DatabaseHelper.lastBg(); @@ -949,22 +991,29 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()); - if (MainApp.getConfigBuilder().isTempBasalInProgress()) { + if (activeTemp != null) { cancelTempButton.setVisibility(View.VISIBLE); cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort()); - runningTempView.setVisibility(View.VISIBLE); - runningTempView.setText(activeTemp.toString()); } else { cancelTempButton.setVisibility(View.GONE); - runningTempView.setVisibility(View.GONE); } - if (pump.getPumpDescription().isTempBasalCapable) { - basalLayout.setVisibility(View.VISIBLE); - baseBasalView.setText(DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + " U/h"); - } else { - basalLayout.setVisibility(View.GONE); + String basalText = ""; + if (activeTemp != null) { + basalText = activeTemp.toString() + " - "; } + if (pump.getPumpDescription().isTempBasalCapable) { + basalText += DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + " U/h"; + } + baseBasalView.setText(basalText); + + ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()); + String extendedBolusText = ""; + if (extendedBolus != null) { + extendedBolusText = extendedBolus.toString(); + } + if (extendedBolusView != null) // must not exists in all layouts + extendedBolusView.setText(extendedBolusText); activeProfileView.setText(MainApp.getConfigBuilder().getProfileName()); activeProfileView.setBackgroundColor(Color.GRAY); @@ -1032,6 +1081,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, highLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units); } + timeUpdate(); // **** BG value **** if (lastBG != null) { @@ -1080,6 +1130,15 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, + getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)"; iobView.setText(iobtext); + // cob + if (cobView != null) { // view must not exists + String cobText = ""; + AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(new Date().getTime()); + if (autosensData != null) + cobText = (int) autosensData.cob + " g " + String.format(MainApp.sResources.getString(R.string.minago), autosensData.minOld()); + cobView.setText(cobText); + } + boolean showPrediction = showPredictionView.isChecked() && finalLastRun != null && finalLastRun.constraintsProcessed.getClass().equals(DetermineBasalResultAMA.class); if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) { showPredictionView.setVisibility(View.VISIBLE); diff --git a/app/src/main/res/layout/careportal_fragment.xml b/app/src/main/res/layout/careportal_fragment.xml index 2c943d2fd7..e538e9125c 100644 --- a/app/src/main/res/layout/careportal_fragment.xml +++ b/app/src/main/res/layout/careportal_fragment.xml @@ -17,7 +17,6 @@ diff --git a/app/src/main/res/layout/careportal_stats_fragment.xml b/app/src/main/res/layout/careportal_stats_fragment.xml index 0cf2270639..c7c8070f54 100644 --- a/app/src/main/res/layout/careportal_stats_fragment.xml +++ b/app/src/main/res/layout/careportal_stats_fragment.xml @@ -15,7 +15,6 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 27e7cd1180..277cc19c2c 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -12,12 +12,11 @@ @@ -72,14 +71,14 @@ @@ -163,7 +162,7 @@ @@ -290,17 +289,15 @@ + android:layout_height="160dip" /> - + \ No newline at end of file diff --git a/app/src/main/res/layout/overview_fragment_tablet.xml b/app/src/main/res/layout/overview_fragment_tablet.xml new file mode 100644 index 0000000000..296f5709d0 --- /dev/null +++ b/app/src/main/res/layout/overview_fragment_tablet.xml @@ -0,0 +1,626 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +