From 7b0ea23b40fc2fb880fa24e42f963cb893110525 Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Thu, 20 Feb 2020 16:08:51 +0000 Subject: [PATCH 01/33] Require the connection to NS to be encrypted (unless in engineering mode) --- .../plugins/general/nsclient/services/NSClientService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java index e1c57cc7c2..4c5b9f36bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java @@ -274,7 +274,7 @@ public class NSClientService extends Service { } else if (!nsEnabled) { RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "disabled")); RxBus.INSTANCE.send(new EventNSClientStatus("Disabled")); - } else if (!nsURL.equals("")) { + } else if (!nsURL.equals("") && (MainApp.engineeringMode || nsURL.toLowerCase().startsWith("https://"))) { try { RxBus.INSTANCE.send(new EventNSClientStatus("Connecting ...")); IO.Options opt = new IO.Options(); @@ -295,6 +295,9 @@ public class NSClientService extends Service { RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "Wrong URL syntax")); RxBus.INSTANCE.send(new EventNSClientStatus("Wrong URL syntax")); } + } else if (nsURL.toLowerCase().startsWith("http://")) { + RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "NS URL not encrypted")); + RxBus.INSTANCE.send(new EventNSClientStatus("Not encrypted")); } else { RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "No NS URL specified")); RxBus.INSTANCE.send(new EventNSClientStatus("Not configured")); From 43495e2565d5bd809ae6a133379e2aa863d06508 Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Thu, 20 Feb 2020 16:38:41 +0000 Subject: [PATCH 02/33] Expose error messages where NS connection fails --- .../general/nsclient/services/NSClientService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java index 4c5b9f36bb..3a38e15ec4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java @@ -283,6 +283,9 @@ public class NSClientService extends Service { mSocket = IO.socket(nsURL, opt); mSocket.on(Socket.EVENT_CONNECT, onConnect); mSocket.on(Socket.EVENT_DISCONNECT, onDisconnect); + mSocket.on(Socket.EVENT_ERROR, onError); + mSocket.on(Socket.EVENT_CONNECT_ERROR, onError); + mSocket.on(Socket.EVENT_CONNECT_TIMEOUT, onError); mSocket.on(Socket.EVENT_PING, onPing); RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "do connect")); mSocket.connect(); @@ -395,6 +398,13 @@ public class NSClientService extends Service { nsDevice = SP.getString("careportal_enteredby", ""); } + private Emitter.Listener onError = new Emitter.Listener() { + @Override + public void call(final Object... args) { + RxBus.INSTANCE.send(new EventNSClientNewLog("ERROR", args[0].toString())); + } + }; + private Emitter.Listener onPing = new Emitter.Listener() { @Override public void call(final Object... args) { From 385781de2381b93165f65096b01b82953bf61400 Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Thu, 20 Feb 2020 16:56:56 +0000 Subject: [PATCH 03/33] Validate paramaters in onError in NS Client --- .../plugins/general/nsclient/services/NSClientService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java index 3a38e15ec4..565399dd59 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java @@ -401,7 +401,11 @@ public class NSClientService extends Service { private Emitter.Listener onError = new Emitter.Listener() { @Override public void call(final Object... args) { - RxBus.INSTANCE.send(new EventNSClientNewLog("ERROR", args[0].toString())); + String msg = "Unknown Error"; + if (args.length > 0 && args[0] != null) { + msg = args[0].toString(); + } + RxBus.INSTANCE.send(new EventNSClientNewLog("ERROR", msg)); } }; From b11707b5d44c12756138e73f43a5130fb5b4d3e4 Mon Sep 17 00:00:00 2001 From: sabsoubi Date: Fri, 21 Feb 2020 11:04:59 +0100 Subject: [PATCH 04/33] Fixed Bug that doesn't show COB if BGI disabled. --- .../general/xdripStatusline/StatuslinePlugin.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatuslinePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatuslinePlugin.java index da61b83b98..bd5b7e4eab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatuslinePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/xdripStatusline/StatuslinePlugin.java @@ -202,13 +202,13 @@ public class StatuslinePlugin extends PluginBase { + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")"; } - if (!mPrefs.getBoolean("xdripstatus_showbgi", false)) { - return status; + // BGI + if (mPrefs.getBoolean("xdripstatus_showbgi", true)) { + double bgi = -(bolusIob.activity + basalIob.activity) * 5 * profile.getIsf(); + status += " " + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to2Decimal(bgi); } - double bgi = -(bolusIob.activity + basalIob.activity) * 5 * profile.getIsf(); - - status += " " + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to2Decimal(bgi); + /* COB */ status += " " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "StatuslinePlugin").generateCOBString(); return status; From c30674036db65d7c633b7dfc340d5327d0e30e7f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 4 Mar 2020 22:38:41 +0100 Subject: [PATCH 05/33] bump 2.6.1-dev --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index b7815678f1..9add15b6d6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,7 +109,7 @@ android { targetSdkVersion 28 multiDexEnabled true versionCode 1500 - version "2.6.0" + version "2.6.1-dev" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' From a8e8659e18cb01f1b79321ac9cd4a91f9db72a9f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 4 Mar 2020 22:51:50 +0100 Subject: [PATCH 06/33] fix CareDialog rotation --- .../java/info/nightscout/androidaps/dialogs/CareDialog.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt index da4a091b1d..be9a48ad77 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -54,6 +54,8 @@ class CareDialog : DialogFragmentWithDate() { super.onSaveInstanceState(savedInstanceState) savedInstanceState.putDouble("actions_care_bg", actions_care_bg.value) savedInstanceState.putDouble("actions_care_duration", actions_care_duration.value) + savedInstanceState.putInt("event", event) + savedInstanceState.putInt("options", options.ordinal) } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, @@ -65,6 +67,11 @@ class CareDialog : DialogFragmentWithDate() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + savedInstanceState?.let { + event = savedInstanceState.getInt("event", R.string.error) + options = EventType.values()[savedInstanceState.getInt("options", 0)] + } + actions_care_icon.setImageResource(when (options) { EventType.BGCHECK -> R.drawable.icon_cp_bgcheck EventType.SENSOR_INSERT -> R.drawable.icon_cp_cgm_insert From 90a9b09395214cfdaebe49e8b6eb815862285801 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 4 Mar 2020 23:33:34 +0100 Subject: [PATCH 07/33] fix BolusProgressDialog rotation --- .../nightscout/androidaps/dialogs/BolusProgressDialog.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt index 3f629add06..ffb8db4b11 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt @@ -30,8 +30,10 @@ class BolusProgressDialog : DialogFragment() { companion object { private val DEFAULT_STATE = MainApp.gs(R.string.waitingforpump) + @JvmField var bolusEnded = false + @JvmField var stopPressed = false } @@ -62,6 +64,9 @@ class BolusProgressDialog : DialogFragment() { } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + savedInstanceState?.let { + amount = it.getDouble("amount") + } overview_bolusprogress_title.text = String.format(MainApp.gs(R.string.overview_bolusprogress_goingtodeliver), amount) overview_bolusprogress_stop.setOnClickListener { if (L.isEnabled(L.UI)) log.debug("Stop bolus delivery button pressed") @@ -136,6 +141,7 @@ class BolusProgressDialog : DialogFragment() { override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) outState.putString("state", state) + outState.putDouble("amount", amount) } private fun scheduleDismiss() { From 7412f67528134d5dd94af2c3b5b9a58af1c41c0d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 6 Mar 2020 11:35:03 +0100 Subject: [PATCH 08/33] New Crowdin translations (#2464) * New translations strings.xml (Dutch) * New translations strings.xml (Dutch) * New translations strings.xml (Dutch) * New translations strings.xml (Dutch) * New translations strings.xml (Dutch) * New translations strings.xml (Dutch) * New translations strings.xml (Dutch) * New translations strings.xml (French) * New translations strings.xml (Italian) * New translations strings.xml (Irish) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations insight_alert_titles.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations objectives.xml (Italian) * New translations strings.xml (Italian) * New translations objectives.xml (Italian) * New translations strings.xml (Italian) * New translations exam.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Italian) --- app/src/main/res/values-fr-rFR/strings.xml | 2 +- app/src/main/res/values-ga-rIE/strings.xml | 1 - app/src/main/res/values-it-rIT/exam.xml | 5 +- .../values-it-rIT/insight_alert_titles.xml | 1 - app/src/main/res/values-it-rIT/objectives.xml | 5 +- app/src/main/res/values-it-rIT/strings.xml | 71 +++++++------- app/src/main/res/values-nl-rNL/strings.xml | 57 +++++++++++- wear/src/main/res/values-it-rIT/strings.xml | 3 +- wear/src/main/res/values-nl-rNL/strings.xml | 93 ++++++++++++++++++- 9 files changed, 188 insertions(+), 50 deletions(-) diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index 1ff963cf88..269ec85497 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -565,7 +565,7 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Firmware Dernière connexion État Bluetooth - À propos de + À propos Autorisation SMS manquante Autorisation du téléphone manquante état Xdrip (montre) diff --git a/app/src/main/res/values-ga-rIE/strings.xml b/app/src/main/res/values-ga-rIE/strings.xml index d4b0807169..b3e84cab92 100644 --- a/app/src/main/res/values-ga-rIE/strings.xml +++ b/app/src/main/res/values-ga-rIE/strings.xml @@ -1,5 +1,4 @@ - diff --git a/app/src/main/res/values-it-rIT/exam.xml b/app/src/main/res/values-it-rIT/exam.xml index 4b9047c775..62abcc22bc 100644 --- a/app/src/main/res/values-it-rIT/exam.xml +++ b/app/src/main/res/values-it-rIT/exam.xml @@ -1,5 +1,4 @@ - Cosa è vero riguardo DIA? Argomento: Durata dell\'Azione dell\'Insulina @@ -47,8 +46,8 @@ Fare un cambio profilo sotto il 100%. Fare un cambio profilo sopra il 100%. Stoppare il loop. - Impostare un temp-target \"attività\" prima dell\'inizio dell\'esercizio fisico. - L\'impostazione di un temp-target \"attività\" dopo l\'inizio dell\'esercizio fisico porta a risultati peggiori rispetto all\'avviarlo prima dell\'inizio dell\'esercizio. + Impostare un temp-target \"attività fisica\" prima dell\'inizio dell\'esercizio fisico. + L\'impostazione di un temp-target \"attività fisica\" dopo l\'inizio dell\'esercizio fisico porta a risultati peggiori rispetto all\'avviarlo prima dell\'inizio dell\'esercizio. https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html#activity-temp-target Argomento: Loop Disabilitato/Sospeso Ricevo insulina quando il loop è disabilitato/sospeso? diff --git a/app/src/main/res/values-it-rIT/insight_alert_titles.xml b/app/src/main/res/values-it-rIT/insight_alert_titles.xml index d510f14df2..0e3e09339f 100644 --- a/app/src/main/res/values-it-rIT/insight_alert_titles.xml +++ b/app/src/main/res/values-it-rIT/insight_alert_titles.xml @@ -1,5 +1,4 @@ - Eroga bolo Bolo perso diff --git a/app/src/main/res/values-it-rIT/objectives.xml b/app/src/main/res/values-it-rIT/objectives.xml index d3cf5f110c..b34fde69ad 100644 --- a/app/src/main/res/values-it-rIT/objectives.xml +++ b/app/src/main/res/values-it-rIT/objectives.xml @@ -1,5 +1,4 @@ - Indietro Avvia @@ -18,7 +17,7 @@ Regolazione del loop chiuso, aumentando max IOB al di sopra di 0 e abbassando gradualmente i target glicemici Esegui l\'applicazione per alcuni giorni e almeno una notte senza allarmi di glicemia bassa, prima di abbassare il target glicemico Adatta basali e rapporti se necessario, quindi attiva auto-sens - 1 settimana di looping diurno con dichiarazione regolare dei carboidrati, eseguito con successo + 1 settimana di looping diurno con inserimento regolare dei carboidrati, eseguito con successo Abilitazione funzioni aggiuntive per l\'uso diurno, ad esempio AMA (advanced meal assist - assistenza avanzata del pasto) Abilitazione funzioni aggiuntive per l\'uso diurno, come SMB È necessario leggere il wiki e aumentare maxIOB affinché le azioni di SMB funzionino adeguatamente! Un buon inizio è maxIOB = media bolo posto + 3 x max basale giornaliera @@ -51,7 +50,7 @@ https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/Screenshots.html#config-builder https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/Screenshots.html#the-homescreen Non connesso a internet - Impossibile recuperare l\'orario + Impossibile recuperare l\'ora Requisiti obiettivo non soddisfatti %1$d giorno diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml index 952633064b..1d1fdc86ed 100644 --- a/app/src/main/res/values-it-rIT/strings.xml +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -1,5 +1,4 @@ - @@ -14,7 +13,7 @@ Vuoi davvero resettare i database? Esci Usa boli estesi per >200%% - Dispositivo DanaR Bluetooth + Dispositivo Bluetooth DanaR Utilizza sempre valori basali assoluti Per favore riavvia il tuo telefono oppure fai ripartire AndroidAPS dalle impostazioni di sistema \naltrimenti Android APS non farà il log (è importante monitorare e verificare che gli algoritmi stiano funzionando correttamente)! Questo dispositivo non sembra supportare la whitelist dell\'ottimizzazione della batteria: potrebbero verificarsi problemi di prestazioni. @@ -25,7 +24,7 @@ Visualizza l\'elenco dei cibi definiti in Nightscout Preset per insulina Humalog e NovoRapid Preset per insulina Fiasp - Ti consente di definire il picco dell\'insulina e deve essere utilizzato solo dagli utenti avanzati + Ti consente di definire il picco di attività dell\'insulina e deve essere utilizzato solo dagli utenti avanzati Attiva o disattiva l\'implementazione del loop. Sincronizza i tuoi dati con Nightscout Stato dell\'algoritmo nel 2016 @@ -42,7 +41,7 @@ Integrazione del microinfusore DANA Diabecare R con firmware aggiornato Integrazione del microinfusore DANA Diabecare RS Per le persone in terapia multi-iniettiva - Per microinfusori che non hanno ancora alcun driver (Loop Aperto) + Per microinfusori che non hanno ancora alcun driver (Loop aperto) La sensibilità è calcolata allo stesso modo di Oref0, ma puoi specificare l\'intervallo di tempo al passato. L\'assorbimento minimo dei carboidrati è calcolato da \'max tempo assorbimento pasto\' nelle preferenze. La sensibilità è calcolata dai dati delle ultime 24h e i carboidrati (se non assorbiti) vengono tagliati fuori dopo il tempo specificato nelle preferenze. La sensibilità è calcolata dai dati delle ultime 8h e i carboidrati (se non assorbiti) vengono tagliati fuori dopo il tempo specificato nelle preferenze. Il Plugin calcola anche UAM. @@ -51,7 +50,7 @@ Ricevi valori glicemia da Glimp. Ricevi valori glicemia da 600SeriesAndroidUploader. Scarica dati glicemia da Nightscout - Ricevi dati glicemia da xDrip. + Ricevi valori glicemia da xDrip. Salva tutti i trattamenti che sono stati fatti Monitora e controlla AndroidAPS usando il tuo smartwatch WearOS. Mostra le informazioni del loop sulla watchface di xDrip+. @@ -196,7 +195,7 @@ Sensore CHO Insulina - Tempo CHO + Offset CHO Frazione Durata Percentuale @@ -265,7 +264,7 @@ Quanti minuti devono trascorrere, almeno, tra un bolo e il successivo Per la tua sicurezza, per modificare questa preferenza hai bisogno di aggiungere almeno 2 numeri di telefono. Bolo di %1$.2fU erogato con successo - Sto per erogare %1$.2fU + A erogare %1$.2fU Bolo di %1$.2fU erogato con successo Bolo pasto di %1$.2fU erogato con successo Target %1$s per %2$d minuti @@ -415,7 +414,7 @@ Elimina trattamenti nel futuro Pasto a breve Ipoglicemia - Attività + Attività fisica Rimuovi record Statistiche DanaR TDD cumulativo @@ -619,7 +618,7 @@ BAS EXT Mantieni lo schermo acceso - Evita che Android disattivi lo schermo. Consumerà molta energia quando non è collegato alla presa di corrente. + Evita che Android spenga lo schermo. Consumerà molta energia quando non è collegato alla presa di corrente. Attivando la funzione Autosense, ricorda di inserire tutti i carboidrati assunti. Altrimenti le deviazioni di glicemia dovute ai carboidrati saranno identificate erroneamente come variazione di sensibilità !! Sensibilità WeightedAverage OK @@ -639,8 +638,8 @@ Abilita SMB Utilizza Super Micro Boli al posto della basale temporanea per un\'azione più veloce Rilevazione dei pasti Non Annunciati - IOB Curve Peak Time - Peak Time [min] + Momento picco Curva IOB + Momento del picco [min] Free-Peak Oref Rapid-Acting Oref Ultra-Rapid Oref @@ -650,7 +649,7 @@ NON VALIDO In attesa di associare il micro Associazione OK - Time out associazione micro + Time out associazione Accoppiamento Nessun dispositivo trovato finora Serbatoio vuoto @@ -668,8 +667,8 @@ Temp-Target predefiniti target \"pasto a breve\" - durata target \"pasto a breve\" - target \"attività\" - durata - target \"attività\" + target \"attività fisica\" - durata + target \"attività fisica\" target \"ipoglicemia\" - durata target \"ipoglicemia\" Riempimento @@ -696,7 +695,7 @@ Attesa per la fine del bolo. Rimangono %1$d sec. Evento di elaborazione Avvio erogazione bolo - Il comando verrà eseguito ora + Il comando sarà eseguito ora Driver del micro corretto Micro irraggiungibile Letture BG mancanti @@ -790,7 +789,7 @@ Abilita SMB con COB Abilita SMB quando COB è attivo (ci sono carboidrati non assorbiti). Abilita SMB con target temporanei - Abilita SMB quando è attivo un target temporaneo (pasto a breve, attività) + Abilita SMB quando è attivo un target temporaneo (pasto a breve, attività fisica) Abilita SMB con target temporanei \"alti\" Abilita SMB quando è attivo un target temporaneo \"alto\" Lascia eseguire la basale temporanea @@ -816,7 +815,7 @@ Consenti la segnalazione automatica degli errori e l\'invio dei dati di utilizzo delle funzioni dell\'app agli sviluppatori tramite il servizio fabric.io. Aggiorna la tua app Dexcom ad una versione supportata App Dexcom non installata. - Avvia TT Attività + Avvia TT Attività fisica Avvia TT Pasto a breve TT No bolo, solo record @@ -839,13 +838,13 @@ %1$.2f U/h Lettura profilo basale Lo storico del micro è cambiato dopo il calcolo del bolo. Il bolo non è stato erogato. Ricalcolare se un bolo è ancora necessario. - Bolo erogato con successo, ma impossibile aggiungere la voce ai trattamenti. Questo può accadere se due piccoli boli della stessa quantità sono stati somministrati negli ultimi due minuti. Verifica lo storico del micro e le voci della sezione Trattamenti e utilizza la sezione Portale per aggiungere eventuali voci mancanti. Assicurati di non aggiungere voci con lo stesso orario e con la stessa quantità. + Bolo erogato con successo, ma non è possibile aggiungere la voce ai trattamenti. Questo può accadere se due piccoli boli della stessa quantità sono stati somministrati negli ultimi due minuti. Verifica lo storico del micro e le voci della sezione Trattamenti e utilizza la sezione Portale per aggiungere eventuali voci mancanti. Assicurati di non aggiungere voci che si riferiscano al medesimo minuto e alla stessa quantità. Rifiuto basale temporanea \"alta\" in quanto il calcolo non ha considerato i cambiamenti recenti allo storico del micro Aggiornamento stato micro La velocità basale nel micro è cambiata e verrà aggiornata a breve Velocità basale cambiata sul micro, ma la sua lettura è fallita Controllo modifiche allo storico - Sono appena stati importati più boli con la stessa quantità nello stesso minuto. Solo un record può essere aggiunto ai trattamenti. Controlla il micro e aggiungi manualmente un record di bolo utilizzando la sezione Portale. Assicurati di creare un bolo con un orario non utilizzato da nessun altro bolo. + Sono appena stati importati più boli con la stessa quantità nello stesso minuto. Solo un record può essere aggiunto ai trattamenti. Controlla il micro e aggiungi manualmente un record di bolo utilizzando la sezione Portale. Assicurati di creare un bolo con un\'ora non utilizzata da nessun altro bolo. \n\nhttp://www.androidaps.org\nhttp://www.androidaps.de (de)\n\nfacebook:\nhttp://facebook.androidaps.org\nhttp://facebook.androidaps.de (de) L\'ultimo bolo è più vecchio di 24 ore o ha una data nel futuro. Controlla che la data sul micro sia impostata correttamente. L\'ora/la data del bolo erogato sul micro sembra errata, IOB probabilmente non è corretto. Controlla l\'ora e/o la data del micro. @@ -891,7 +890,7 @@ Micro in pausa Max tempo assorbimento pasto [h] Tempo entro il quale ogni pasto si considera assorbito. Eventuali carboidrati rimanenti verranno tagliati fuori. - Tempo + Offset Finestre tratt.nto: mostra campo note Avanti Indietro @@ -983,8 +982,8 @@ Configurazione micro non valida, controlla la documentazione e verifica che il menu Quick Info sia denominato QUICK INFO utilizzando \"360 configuration software\". Personalizzato - Grande differenza d\'orario - Grande differenza d\'orario:\nL\'orario nel micro differisce per più di 1h e 30m. \nRegola l\'ora manualmente e assicurati che la lettura dello storico dal micro non causi comportamenti imprevisti.\nSe possibile, cancella la cronologia del micro prima di cambiare l\'orario oppure disabilita il loop chiuso per un tempo corrispondente al tuo valore DIA. + Grande differenza oraria + Grande differenza oraria:\nL\'ora nel micro differisce per più di 1h e 30m. \nRegola l\'ora manualmente e assicurati che la lettura dello storico dal micro non causi comportamenti imprevisti.\nSe possibile, cancella la cronologia del micro prima di cambiare l\'ora oppure disabilita il loop chiuso per un tempo corrispondente al tuo valore DIA. Rimuovi gli eventi \"AndroidAPS avviato\" Trovate impostazioni salvate Attenzione: se attivi e connetti un micro, AndroidAPS copierà le impostazioni della basale dal profilo al micro, sovrascrivendo la velocità basale esistente memorizzata sul micro. Assicurati di avere la giusta impostazione della basale in AndroidAPS. Se non sei sicuro o non vuoi sovrascrivere le impostazioni della basale sul micro, premi annulla e ripeti il processo in un altro momento. @@ -1031,11 +1030,11 @@ Conferma Muto Avviso microinfusore - Registra cambi posizione cannula + Registra cambi posizione Registra cambi serbatoio Registra cambi catetere Registra cambi batteria - Registra cambi modalità di funzionamento + Registra cambi modalità operativa Registra avvisi Abilita emulazione TBR Usa i bolli estesi invece dei TBR per aggirare il limite del 250%% @@ -1114,9 +1113,9 @@ Glicemia %1$s %2$.1f %3$s PCT profilo %1$s %2$d IOB %1$s %2$.1f - E - O - O (esclusivo) + E (AND) + O (OR) + O (esclusivo - XOR) A %1$s Usa posizione di rete Usa posizione GPS @@ -1165,7 +1164,7 @@ Codice errato. Comando annullato. Non configurato Cambio profilo creato - Tempo ricorrente + Tempo di ripetizione Ogni Mai %1$dmin @@ -1322,7 +1321,7 @@ Max bolo errato impostato nel micro (deve essere %1$.2f). Max basale errata impostata nel micro (deve essere %1$.2f). Operazione non possibile.\n\n Devi prima configurare il micro Medtronic. - È stata richiesta una modifica d\'orario di oltre 24h. + È stata richiesta una modifica oraria di oltre 24h. Basali Configurazioni @@ -1353,7 +1352,7 @@ Il profilo basale è lo stesso, non sarà impostato di nuovo. Ottieni storico - Pagina %1$d (%2$d/16) Ottieni storico - Pagina %1$d - Ottieni orario micro + Ottieni ora micro Ottieni impostazioni Ottieni modello micro Ottieni profilo basale @@ -1378,7 +1377,7 @@ Caricamento ... Posticipa Intervallo di tempo - Il tempo è compreso tra %1$s e %2$s + L\'intervallo di tempo è compreso tra %1$s e %2$s Tra Chiudi Aumento del valore max basale perché l\'impostazione è inferiore alla tua basale massima nel profilo @@ -1420,7 +1419,7 @@ ID: Invia Profilo più comune: - Nota: solo i dati visibili su questa schermata verranno caricati (in modo anonimo). Un ID è assegnato a questa installazione di AndroidAPS. Puoi inviare nuovamente i dati se il tuo profilo principale viene modificato, ma lascialo in esecuzione almeno per una settimana per rendere visibili i risultati nel time in range. Il tuo aiuto è apprezzato. + Nota: solo i dati visibili su questa schermata verranno caricati (in modo anonimo). Un ID è assegnato a questa installazione di AndroidAPS. Puoi inviare nuovamente i dati se il tuo profilo principale viene modificato, ma lascialo in esecuzione almeno per una settimana per rendere il risultato visibile nel time in range (TIR). Il tuo aiuto è apprezzato. Sondaggio Inserimento età non valido Inserimento peso non valido @@ -1450,8 +1449,8 @@ \"PhoneChecker\" Menu grafico AS - Tempo richiesta SMB - Tempo esecuzione SMB - Tempo richiesta basale temporanea - Tempo esecuzione basale temporanea + Richiesta SMB (momento) + Esecuzione SMB (momento) + Richiesta basale temporanea (momento) + Esecuzione basale temporanea (momento) diff --git a/app/src/main/res/values-nl-rNL/strings.xml b/app/src/main/res/values-nl-rNL/strings.xml index e797344f49..b7b391a804 100644 --- a/app/src/main/res/values-nl-rNL/strings.xml +++ b/app/src/main/res/values-nl-rNL/strings.xml @@ -1,5 +1,4 @@ - @@ -143,6 +142,7 @@ In strijd met beperkingen Bolus toedien storing Tijdelijk basaal toedien storing + Basaal waarde [%] Accepteer nieuw tijdelijk basaal: Bolus Bolus wizard @@ -180,6 +180,7 @@ CGM Sens. ingebracht CGM Sens. Start Insuline ampul wissel + Profiel wissel Snack bolus Maaltijd bolus Correctie bolus @@ -200,6 +201,7 @@ Procent Absoluut Notities + Tijdstip gebeurtenis Profiel Ingegeven door Glucose type @@ -224,6 +226,7 @@ Verbinden Verbonden Niet verbonden + Dana pomp instellingen Eind gebruiker overeenkomst MUST NOT BE USED TO MAKE MEDICAL DECISIONS. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. Begrepen en goedgekeurd @@ -272,6 +275,8 @@ Vingerprik Sensor Manueel + Tijdelijk streefdoel + Tijdelijk streefdoel annuleren DanaR profiel instellingen DIA [uur] Duur van insuline activiteit @@ -410,6 +415,7 @@ Eet binnenkort Hypo Activiteit + Verwijder record DanaR Statistiek Cumulatieve TDD Exponentieel verhoogd TDD @@ -576,6 +582,7 @@ Ouderdom insuline uren Ongeldig profiel !!! + Profiel wissel uitvoeren Ouderdom batterij Pomp bat. wissel Alarm opties @@ -643,6 +650,7 @@ Wachten op koppelen van de pomp Koppeling geslaagd Koppeling verlopen + Koppelen Geen toestel gevonden Ampul leeg Bloed glucose meetpunt alarm @@ -753,6 +761,7 @@ Een bolus met dezelfde hoeveelheid was gevraagd binnen de afgelopen twee minuten. Om incidentele of door bugs veroorzaakte dubbele bolussen te voorkomen is deze bolus geannuleerd. Zojuist Lezen van pomp historiek + Historiek Instellen van basaal profiel Insuline ampul is bijna leeg Batterij pomp is bijna leeg @@ -772,6 +781,7 @@ Insight voorbij %1$.2f u + %1$d minuten Activeer SMB altijd SMB altijd aan onafhankelijk van bolussen. Enkel mogelijk met een BG bron met goed gefilterde data zoals de G5 Activeer SMB na koolhydraten @@ -935,6 +945,7 @@ Start je eerste Doel Toestemming Vragen om toestemming + Toepassing vereist systeemvenstermachtiging voor meldingen Toepassing heeft toestemming nodig voor bepalen van Locatie (voor BT scan) Applicatie heeft toestemming nodig om log bestanden op te kunnen slaan Verzoek @@ -948,7 +959,11 @@ Geluid Trillen Beide + LCD-aan tijd [sec.] + Achtergrondverlichting-aan tijd [sec.] Glucose units + Afsluiten [uren] + Laag reservoir (eenheden) Opslaan van de opties om de pomp Aan Uit @@ -1206,6 +1221,8 @@ COB %1$s %2$.0f Taaknaam EDIT + Kies een actie + Kies een type trigger Triggers: VERWIJDER Voorwaarden: @@ -1298,6 +1315,7 @@ Pomp frequentie niet ondersteund. RileyLink adres ongeldig. Gedetecteerde pomp type komt niet overeen met ingestelde pomp type. + De instelling voor basaalprofielen/patronen is niet ingeschakeld op de pomp. Schakel het in op de pomp. Basaalprofiel ingesteld op pomp is onjuist (moet STD zijn). Verkeerde Tijdelijk Basaal-type ingesteld op pomp (moet Insulinesnelh (E/H) zijn). Verkeerde Max Bolus ingesteld op pomp (moet %1$.2f zijn). @@ -1348,6 +1366,7 @@ Laatste verbinding met pomp [minuten geleden] Laatste verbinding met pomp %1$s %2$s min geleden Stuur SMS: %1$s + SMS verzenden naar alle nummers Stuur SMS met tekst %2$+.2fU]]> Bolus limiet bereikt: %2$.2fU naar %3$.2fU]]> @@ -1376,7 +1395,7 @@ %1$dg Aan Uit - Wissen voltooid + Voltooiing wissen Wissen gestart Tijd detectie Wil je dit leerdoel opnieuw starten? Je kunt je voortgang verliezen. @@ -1399,5 +1418,39 @@ Gewicht: ID: Verzenden + Meest voorkomende profiel: Opmerking: Alleen gegevens die zichtbaar zijn op dit scherm worden anoniem geüpload. ID is toegewezen aan deze installatie van AndroidAPS. U kunt gegevens opnieuw indienen als uw hoofdprofiel wordt gewijzigd, maar laat het ten minste een week draaien om resultaat zichtbaar te maken in de tijd in het bereik. Uw hulp wordt gewaardeerd. + Enquête + Ongeldige leeftijd invoer + Ongeldige gewicht invoer + %1$s: ∑: %2$.2f Bol: %3$.2f Bas: %4$.2f]]> + %1$s: Laag: %2$02d%% In: %3$02d%% Hoog: %4$02d%%]]> + Gemiddelde + TDD + TIR + Activiteitsmonitor + Wil je de activiteitenstatistieken resetten? + Statistieken + Willekeurige BG + Willekeurige BG gegevens genereren (alleen Demo modus) + BG + Hulpmiddelen + Toon berekening + Fout + 12u + 24u + Automation gebeurtenis + Al ingesteld + Bericht + Wachtrij leegmaken? Alle gegevens in de wachtrij zullen verloren gaan! + Gebruik van Vertraagde bolus functie zal de closed loop modus stoppen voor de duur van de vertraagde bolus. Wil je dit toch? + Closed loop modus uitgeschakeld vanwege afgeven Vertraagde bolus + VertrB + \"PhoneChecker\" + Grafiek menu + AS + SMB aanvraagtijd + SMB uitvoeringstijd + Tijdelijk basaal aanvraag tijd + Tijdelijke basaal uitvoering tijd diff --git a/wear/src/main/res/values-it-rIT/strings.xml b/wear/src/main/res/values-it-rIT/strings.xml index 5247ee0674..0f7282e210 100644 --- a/wear/src/main/res/values-it-rIT/strings.xml +++ b/wear/src/main/res/values-it-rIT/strings.xml @@ -1,5 +1,4 @@ - AAPS AAPS @@ -98,7 +97,7 @@ TDD CHO IOB - no stato + no status mg/dl mmol/l g diff --git a/wear/src/main/res/values-nl-rNL/strings.xml b/wear/src/main/res/values-nl-rNL/strings.xml index e1e7c4c3d6..784fdb2f19 100644 --- a/wear/src/main/res/values-nl-rNL/strings.xml +++ b/wear/src/main/res/values-nl-rNL/strings.xml @@ -1,18 +1,109 @@ - + AAPS + AAPS + AAPS + AAPS(Groot) + AAPS(GroteGrafiek) + AAPS(GeenGrafiek) + AAPS(Cirkel) + AAPSv2 + AAPS(Cockpit) + AAPS(Steampunk) + Geen gegevens! + Oude gegevens! + Sinds %1$s + Synchroniseer met AAPS! + Geen gegevens ontvangen sinds %1$s! Controleer of AAPS op de telefoon gegevens verstuurt naar horloge AAPS gegevens zijn %1$s oud! Controleer je sensor, xDrip+, NS, AAPS instellingen of andere! Aan Uit Trillen bij bolus Eenheden voor acties Toon datum + Toon IOB + Toon COB Toon Delta Toon gemiddelde delta + Toon telefoonbatterij + Toon rig batterij + Toon basaal + Toon loop status + Toon BG + Toon richtingspijl + Toon tijd geleden + Donker + Markeer basaalstanden + Bijpassende verdeler + Tijdsschaal grafiek 1 uur 2 uren 3 uren 4 uren 5 uren + Invoer ontwerp Standaard + Snel rechts + Snel links + Modern spaarzaam + Delta schaalverdeling (Steampunk) + Laag + Middel + Hoog + Automatisch + Grote nummers + Ring geschiedenis + Lichte ring geschiedenis + Animaties + Wizard in menu + Ontlucht/vul in menu + Enkel streefdoel + Wizardpercentage + Complicatie tik voor actie + Unicode in complicaties + Versie: + TijdStreefd + Wizard + Bolus + eCarb + Instellingen + Status + Ontlucht/vul + Geen + Standaard + Menu + tijdsduur + doel + laag + hoog + khd + percentage + start [min] + duur [h] + insuline + Voorinstelling 1 + Voorinstelling 2 + Voorinstelling 3 + Vrije hoeveelheid + BEVESTIGEN + STATUS POMP + STATUS LOOP + tijdsverschuiving + Gewogen TDD + bolus + Pomp + Loop + CPP + TDD + Khd + IOB + geen status + mg/dl + mmol/l + g + E + E/u + u + d + w From 6fa05f11c92a3965e0a7d901220163afd4986089 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 6 Mar 2020 19:02:34 +0100 Subject: [PATCH 09/33] LocalInsightPlugin crash fix --- .../androidaps/plugins/pump/insight/LocalInsightPlugin.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index 8dd425b12c..2197b48577 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -937,6 +937,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con @Override public JSONObject getJSONStatus(Profile profile, String profileName) { long now = System.currentTimeMillis(); + if (connectionService == null) return null; if (System.currentTimeMillis() - connectionService.getLastConnected() > (60 * 60 * 1000)) { return null; } From 95394d6cb370fb8f92f81af00b8183e4f269c9c8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 6 Mar 2020 19:13:56 +0100 Subject: [PATCH 10/33] Unregister shared preferences properly --- .../androidaps/activities/PreferencesActivity.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java index 328f143836..96a2b23b06 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.java @@ -68,6 +68,12 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this); } + @Override + protected void onDestroy() { + super.onDestroy(); + PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this); + } + @Override public void attachBaseContext(Context newBase) { super.attachBaseContext(LocaleHelper.INSTANCE.wrap(newBase)); From 4cca305e1bb9d7cba6f4672ca6e1756e8db5e1ac Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 6 Mar 2020 19:40:29 +0100 Subject: [PATCH 11/33] fix ProfileSwitch confirm dialog --- .../nightscout/androidaps/dialogs/ProfileSwitchDialog.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index f594564a78..a258cbec8a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -78,9 +78,9 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { ?: return false val actions: LinkedList = LinkedList() - val duration = overview_profileswitch_duration.value + val duration = overview_profileswitch_duration.value.toInt() if (duration > 0) - actions.add(MainApp.gs(R.string.duration) + ": " + MainApp.gs(R.string.format_hours, duration)) + actions.add(MainApp.gs(R.string.duration) + ": " + MainApp.gs(R.string.format_mins, duration)) val profile = overview_profileswitch_profile.selectedItem.toString() actions.add(MainApp.gs(R.string.profile) + ": " + profile) val percent = overview_profileswitch_percentage.value.toInt() @@ -98,7 +98,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, MainApp.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), Runnable { log.debug("USER ENTRY: PROFILE SWITCH $profile percent: $percent timeshift: $timeShift duration: $duration") - ProfileFunctions.doProfileSwitch(profileStore, profile, duration.toInt(), percent, timeShift, eventTime) + ProfileFunctions.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime) }) } return true From 70053ea61cca3faa2c585b064a8deb477fa469b7 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Fri, 6 Mar 2020 12:33:20 +0100 Subject: [PATCH 12/33] Combo: create separate bolus/carb records at driver level. --- .../plugins/pump/combo/ComboPlugin.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java index 32a17f8a89..e71a86d91f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java @@ -654,16 +654,29 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint * Creates a treatment record based on the request in DetailBolusInfo and the delivered bolus. */ private boolean addBolusToTreatments(DetailedBolusInfo detailedBolusInfo, Bolus lastPumpBolus) { - DetailedBolusInfo dbi = detailedBolusInfo.copy(); - dbi.date = calculateFakeBolusDate(lastPumpBolus); - dbi.pumpId = dbi.date; - dbi.source = Source.PUMP; - dbi.insulin = lastPumpBolus.amount; + DetailedBolusInfo bolusInfo = detailedBolusInfo.copy(); + bolusInfo.date = calculateFakeBolusDate(lastPumpBolus); + bolusInfo.pumpId = bolusInfo.date; + bolusInfo.source = Source.PUMP; + bolusInfo.insulin = lastPumpBolus.amount; try { - TreatmentsPlugin.getPlugin().addToHistoryTreatment(dbi, true); + if (bolusInfo.carbs > 0 && bolusInfo.carbTime != 0) { + // split out a separate carbs record without a pumpId + DetailedBolusInfo carbInfo = new DetailedBolusInfo(); + carbInfo.date = bolusInfo.date + bolusInfo.carbTime * 60L * 1000L; + carbInfo.carbs = bolusInfo.carbs; + carbInfo.source = Source.USER; + TreatmentsPlugin.getPlugin().addToHistoryTreatment(carbInfo, true); + + // remove carbs from bolusInfo to not trigger any unwanted code paths in + // TreatmentsPlugin.addToHistoryTreatment() method + bolusInfo.carbTime = 0; + bolusInfo.carbs = 0; + } + TreatmentsPlugin.getPlugin().addToHistoryTreatment(bolusInfo, true); } catch (Exception e) { log.error("Adding treatment record failed", e); - if (dbi.isSMB) { + if (bolusInfo.isSMB) { Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.combo_error_updating_treatment_record), Notification.URGENT); RxBus.INSTANCE.send(new EventNewNotification(notification)); } From 1e02773b71d0180bf30b6185c40b718ea268200f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 6 Mar 2020 20:27:39 +0100 Subject: [PATCH 13/33] fire immediatelly TreatmentChange if not from NS --- .../plugins/treatments/TreatmentService.java | 66 ++++++++++++------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java index 1331c8eedf..1b118da1d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java @@ -160,7 +160,7 @@ public class TreatmentService extends OrmLiteBaseService { } catch (SQLException e) { log.error("Unhandled exception", e); } - scheduleTreatmentChange(null); + scheduleTreatmentChange(null, true); } @@ -208,18 +208,30 @@ public class TreatmentService extends OrmLiteBaseService { /** * Schedule a foodChange Event. */ - public void scheduleTreatmentChange(@Nullable final Treatment treatment) { - this.scheduleEvent(new EventReloadTreatmentData(new EventTreatmentChange(treatment)), treatmentEventWorker, new ICallback() { - @Override - public void setPost(ScheduledFuture post) { - scheduledTreatmentEventPost = post; + public void scheduleTreatmentChange(@Nullable final Treatment treatment, boolean runImmediately) { + if (runImmediately) { + if (L.isEnabled(L.DATATREATMENTS)) + log.debug("Firing EventReloadTreatmentData"); + RxBus.INSTANCE.send(new EventReloadTreatmentData(new EventTreatmentChange(treatment))); + if (DatabaseHelper.earliestDataChange != null) { + if (L.isEnabled(L.DATATREATMENTS)) + log.debug("Firing EventNewHistoryData"); + RxBus.INSTANCE.send(new EventNewHistoryData(DatabaseHelper.earliestDataChange)); } + DatabaseHelper.earliestDataChange = null; + } else { + this.scheduleEvent(new EventReloadTreatmentData(new EventTreatmentChange(treatment)), treatmentEventWorker, new ICallback() { + @Override + public void setPost(ScheduledFuture post) { + scheduledTreatmentEventPost = post; + } - @Override - public ScheduledFuture getPost() { - return scheduledTreatmentEventPost; - } - }); + @Override + public ScheduledFuture getPost() { + return scheduledTreatmentEventPost; + } + }); + } } public List getTreatmentData() { @@ -294,7 +306,7 @@ public class TreatmentService extends OrmLiteBaseService { getDao().create(existingTreatment); DatabaseHelper.updateEarliestDataChange(oldDate); DatabaseHelper.updateEarliestDataChange(existingTreatment.date); - scheduleTreatmentChange(treatment); + scheduleTreatmentChange(treatment, true); return new UpdateReturn(sameSource, false); //updating a pump treatment with another one from the pump is not counted as clash } return new UpdateReturn(equalRePumpHistory, false); @@ -318,14 +330,14 @@ public class TreatmentService extends OrmLiteBaseService { getDao().create(existingTreatment); DatabaseHelper.updateEarliestDataChange(oldDate); DatabaseHelper.updateEarliestDataChange(existingTreatment.date); - scheduleTreatmentChange(treatment); + scheduleTreatmentChange(treatment, true); return new UpdateReturn(equalRePumpHistory || sameSource, false); } getDao().create(treatment); if (L.isEnabled(L.DATATREATMENTS)) log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString()); DatabaseHelper.updateEarliestDataChange(treatment.date); - scheduleTreatmentChange(treatment); + scheduleTreatmentChange(treatment, true); return new UpdateReturn(true, true); } if (treatment.source == Source.NIGHTSCOUT) { @@ -343,7 +355,7 @@ public class TreatmentService extends OrmLiteBaseService { DatabaseHelper.updateEarliestDataChange(oldDate); DatabaseHelper.updateEarliestDataChange(old.date); } - scheduleTreatmentChange(treatment); + scheduleTreatmentChange(treatment, false); return new UpdateReturn(true, true); } if (L.isEnabled(L.DATATREATMENTS)) @@ -366,7 +378,7 @@ public class TreatmentService extends OrmLiteBaseService { DatabaseHelper.updateEarliestDataChange(oldDate); DatabaseHelper.updateEarliestDataChange(old.date); } - scheduleTreatmentChange(treatment); + scheduleTreatmentChange(treatment, false); return new UpdateReturn(true, true); } if (L.isEnabled(L.DATATREATMENTS)) @@ -378,7 +390,7 @@ public class TreatmentService extends OrmLiteBaseService { if (L.isEnabled(L.DATATREATMENTS)) log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString()); DatabaseHelper.updateEarliestDataChange(treatment.date); - scheduleTreatmentChange(treatment); + scheduleTreatmentChange(treatment, false); return new UpdateReturn(true, true); } if (treatment.source == Source.USER) { @@ -386,7 +398,7 @@ public class TreatmentService extends OrmLiteBaseService { if (L.isEnabled(L.DATATREATMENTS)) log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString()); DatabaseHelper.updateEarliestDataChange(treatment.date); - scheduleTreatmentChange(treatment); + scheduleTreatmentChange(treatment, true); return new UpdateReturn(true, true); } } catch (SQLException e) { @@ -414,7 +426,7 @@ public class TreatmentService extends OrmLiteBaseService { if (L.isEnabled(L.DATATREATMENTS)) log.debug("New record from: " + Source.getString(treatment.source) + " " + treatment.toString()); DatabaseHelper.updateEarliestDataChange(treatment.date); - scheduleTreatmentChange(treatment); + scheduleTreatmentChange(treatment, true); return new UpdateReturn(true, true); } else { @@ -428,7 +440,7 @@ public class TreatmentService extends OrmLiteBaseService { } getDao().update(existingTreatment); DatabaseHelper.updateEarliestDataChange(existingTreatment.date); - scheduleTreatmentChange(treatment); + scheduleTreatmentChange(treatment, true); return new UpdateReturn(true, false); } else { if (MedtronicHistoryData.doubleBolusDebug) @@ -439,7 +451,7 @@ public class TreatmentService extends OrmLiteBaseService { optionalTreatmentCopy(existingTreatment, treatment, fromNightScout); getDao().create(existingTreatment); DatabaseHelper.updateEarliestDataChange(existingTreatment.date); - scheduleTreatmentChange(treatment); + scheduleTreatmentChange(treatment, true); return new UpdateReturn(true, false); //updating a pump treatment with another one from the pump is not counted as clash } } @@ -626,9 +638,13 @@ public class TreatmentService extends OrmLiteBaseService { if (stored != null) { if (L.isEnabled(L.DATATREATMENTS)) log.debug("Removing Treatment record from database: " + stored.toString()); - delete(stored); + try { + getDao().delete(stored); + } catch (SQLException e) { + log.error("Unhandled exception", e); + } DatabaseHelper.updateEarliestDataChange(stored.date); - scheduleTreatmentChange(null); + this.scheduleTreatmentChange(stored, false); } } @@ -643,7 +659,7 @@ public class TreatmentService extends OrmLiteBaseService { try { getDao().delete(treatment); DatabaseHelper.updateEarliestDataChange(treatment.date); - this.scheduleTreatmentChange(treatment); + this.scheduleTreatmentChange(treatment, true); } catch (SQLException e) { log.error("Unhandled exception", e); } @@ -656,7 +672,7 @@ public class TreatmentService extends OrmLiteBaseService { } catch (SQLException e) { log.error("Unhandled exception", e); } - scheduleTreatmentChange(treatment); + scheduleTreatmentChange(treatment, true); } /** From a3ee216b215eafe9137bb26ad7c2e9d7057cf3f8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 7 Mar 2020 17:34:39 +0100 Subject: [PATCH 14/33] New Crowdin translations (#2485) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (French) * New translations strings.xml (Italian) * New translations objectives.xml (Italian) * New translations strings.xml (Italian) * New translations insight_alert_titles.xml (Italian) * New translations insight_exceptions.xml (Italian) * New translations strings.xml (Italian) --- app/src/main/res/values-fr-rFR/strings.xml | 4 ++-- .../values-it-rIT/insight_alert_titles.xml | 4 ++-- .../res/values-it-rIT/insight_exceptions.xml | 5 ++-- app/src/main/res/values-it-rIT/objectives.xml | 2 +- app/src/main/res/values-it-rIT/strings.xml | 24 +++++++++---------- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index 269ec85497..5dc5649fca 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -1425,10 +1425,10 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Âge invalide Poids invalide %1$s: ∑: %2$.2f Bol: %3$.2f Bas: %4$.2f]]> - %1$s: Bas: %2$02d%% Médian: %3$02d%% Haut: %4$02d%%]]> + %1$s: Bas: %2$02d%% Cible: %3$02d%% Haut: %4$02d%%]]> Moyenne DTI - TIR + Cible Gly Moniteur d\'activité Voulez-vous réinitialiser les stats d\'activité ? Statistiques diff --git a/app/src/main/res/values-it-rIT/insight_alert_titles.xml b/app/src/main/res/values-it-rIT/insight_alert_titles.xml index 0e3e09339f..123334b48d 100644 --- a/app/src/main/res/values-it-rIT/insight_alert_titles.xml +++ b/app/src/main/res/values-it-rIT/insight_alert_titles.xml @@ -9,8 +9,8 @@ Batteria quasi scarica Ora/data non valida Fine della garanzia - TBR annullato - Bolo annullato + TBR cancellato + Bolo cancellato Avviso di prestito Cartuccia non inserita Cartuccia vuota diff --git a/app/src/main/res/values-it-rIT/insight_exceptions.xml b/app/src/main/res/values-it-rIT/insight_exceptions.xml index fa33f5f7f2..fc68ba559f 100644 --- a/app/src/main/res/values-it-rIT/insight_exceptions.xml +++ b/app/src/main/res/values-it-rIT/insight_exceptions.xml @@ -1,5 +1,4 @@ - Connessione fallita Connessione persa @@ -7,9 +6,9 @@ Creazione socket fallita Timeout Numero massimo tipo di bolo già in esecuzione - Nessun TBR attivo da annullare + Nessun TBR attivo da cancellare Nessun TBR attivo da modificare - Nessun bolo da annullare + Nessun bolo da cancellare Micro già in questo stato Modalità di esecuzione non consentita diff --git a/app/src/main/res/values-it-rIT/objectives.xml b/app/src/main/res/values-it-rIT/objectives.xml index b34fde69ad..d8026431c0 100644 --- a/app/src/main/res/values-it-rIT/objectives.xml +++ b/app/src/main/res/values-it-rIT/objectives.xml @@ -24,7 +24,7 @@ Glicemia disponibile in NS Stato micro disponibile in NS Attivazioni manuali - Compiuto: %1$s + Completato: %1$s Impara a controllare AndroidAPS Esegui varie azioni in AndroidAPS Imposta il profilo \"90%\" per 10 min (premi a lungo sul nome profilo nella sezione Panoramica) diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml index 1d1fdc86ed..191ec45424 100644 --- a/app/src/main/res/values-it-rIT/strings.xml +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -119,7 +119,7 @@ Trattamenti Quale plugin dovrebbe essere utilizzato per la gestione del trattamento? Profilo - Quale profilo dovrebbe usare AndroidAPS? + Quale profilo AndroidAPS dovrebbe usare? APS Quale algoritmo APS dovrebbe apportare aggiustamenti terapeutici? Generale @@ -247,7 +247,7 @@ OK Percentuale Assoluto - Cancellare basale temporanea + Cancella basale temporanea Comunicazioni SMS In attesa del risultato Numeri di telefono consentiti @@ -343,8 +343,8 @@ Per stoppare il bolo esteso rispondi col codice %1$s Basale temporanea cancellata Bolo esteso cancellato - Cancellazione basale temporanea fallita - Cancellazione bolo esteso fallita + Basale temporanea: cancellazione fallita + Bolo esteso: cancellazione fallita Comando sconosciuto o risposta errata Calcolatore Rapido Impostazioni Calcolatore Rapido @@ -638,8 +638,8 @@ Abilita SMB Utilizza Super Micro Boli al posto della basale temporanea per un\'azione più veloce Rilevazione dei pasti Non Annunciati - Momento picco Curva IOB - Momento del picco [min] + Tempo picco Curva IOB + Tempo del picco [min] Free-Peak Oref Rapid-Acting Oref Ultra-Rapid Oref @@ -771,7 +771,7 @@ Normale Necessario aggiornare orologio micro Attenzione - Avviso TBR CANCELLATO confermato + Avviso TBR CANCELLATO: confermato Il micro potrebbe non essere raggiungibile. Nessun bolo erogato Erogazione bolo fallita. Sembra che nessun bolo sia stato erogato. Per sicurezza, controlla il micro per evitare un doppio bolo e se è tutto ok, erogalo di nuovo. Come protezione da eventuali \"bug\", i boli non vengono ripetuti automaticamente. Solo la quantità di %1$.2f U del bolo richiesto di %2$.2f U è stata erogata a causa di un errore. Controlla il micro per verificare quanto accaduto e intraprendi le azioni necessarie. @@ -890,7 +890,7 @@ Micro in pausa Max tempo assorbimento pasto [h] Tempo entro il quale ogni pasto si considera assorbito. Eventuali carboidrati rimanenti verranno tagliati fuori. - Offset + Tempo Finestre tratt.nto: mostra campo note Avanti Indietro @@ -1161,10 +1161,10 @@ vincolo di archiviazione interna Libera almeno %1$d MB dalla memoria interna! Loop disabilitato! Formato errato - Codice errato. Comando annullato. + Codice errato. Comando cancellato. Non configurato Cambio profilo creato - Tempo di ripetizione + Tempo ricorrente Ogni Mai %1$dmin @@ -1395,8 +1395,8 @@ %1$dg On Off - Cancella completato - Cancella avviato + Cancella completamento + Cancella avvio Rilevazione tempo Vuoi resettare l\'avvio dell\'obiettivo? Potresti perdere i tuoi progressi. Nessun micro selezionato From 07aa6f20394d1f8493b7f75020c6b22fc7ed2165 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 7 Mar 2020 20:18:52 +0100 Subject: [PATCH 15/33] fix LocalProfile upload --- .../androidaps/plugins/general/nsclient/NSUpload.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java index 0bc15d1d45..ab6cae3e71 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSUpload.java @@ -396,7 +396,7 @@ public class NSUpload { public static void uploadProfileStore(JSONObject profileStore) { if (SP.getBoolean(R.string.key_ns_uploadlocalprofile, false)) { - UploadQueue.add(new DbRequest("dbAdd", "profile", String.valueOf(profileStore))); + UploadQueue.add(new DbRequest("dbAdd", "profile", profileStore)); } } From 14bda9cf719770cdd3d638475190482254bfd0a6 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 7 Mar 2020 20:37:08 +0100 Subject: [PATCH 16/33] hide overview_accepttempbutton by default --- app/src/main/res/layout/overview_fragment.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 467c8c171a..35ddd5eed4 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -477,7 +477,8 @@ app:layout_constraintBottom_toTopOf="@id/overview_buttons_layout" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/overview_toppart_scrollbar" /> + app:layout_constraintTop_toBottomOf="@id/overview_toppart_scrollbar" + android:visibility="gone"/> Date: Sat, 7 Mar 2020 20:50:49 +0100 Subject: [PATCH 17/33] scrollable buttons in landscape mode --- .../general/overview/OverviewFragment.java | 4 +- .../layout/overview_fragment_landscape.xml | 584 ++++++++++++++++++ 2 files changed, 586 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/layout/overview_fragment_landscape.xml diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java index 0976755f06..a00317eff3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java @@ -221,8 +221,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } else if (Config.NSCLIENT) { view = inflater.inflate(R.layout.overview_fragment_nsclient, container, false); shorttextmode = true; - } else if (smallHeight || landscape) { // now testing the same layout for small displays as well - view = inflater.inflate(R.layout.overview_fragment, container, false); + } else if (smallHeight || landscape) { + view = inflater.inflate(R.layout.overview_fragment_landscape, container, false); } else { view = inflater.inflate(R.layout.overview_fragment, container, false); } diff --git a/app/src/main/res/layout/overview_fragment_landscape.xml b/app/src/main/res/layout/overview_fragment_landscape.xml new file mode 100644 index 0000000000..edaa1df7a5 --- /dev/null +++ b/app/src/main/res/layout/overview_fragment_landscape.xml @@ -0,0 +1,584 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a53f173751d06b446dd581202abb02eedfa15869 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 8 Mar 2020 20:49:29 +0100 Subject: [PATCH 18/33] fix some warnings --- .../nightscout/androidaps/activities/SurveyActivity.kt | 2 +- .../general/automation/dialogs/EditActionDialog.kt | 8 ++++---- .../java/info/nightscout/androidaps/utils/OKDialog.kt | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt index bf07eda9af..d72e43441e 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt @@ -84,7 +84,7 @@ class SurveyActivity : NoSplashAppCompatActivity() { .addOnCompleteListener(this) { task -> if (task.isSuccessful) { log.debug("signInAnonymously:success") - val user = auth.currentUser // TODO: do we need this, seems unused? + // val user = auth.currentUser // TODO: do we need this, seems unused? val database = FirebaseDatabase.getInstance().reference database.child("survey").child(r.id).setValue(r) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditActionDialog.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditActionDialog.kt index e738b7f94c..63a053f29f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditActionDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/EditActionDialog.kt @@ -44,11 +44,11 @@ class EditActionDialog : DialogFragmentWithDate() { return true } - override fun onSaveInstanceState(bundle: Bundle) { - super.onSaveInstanceState(bundle) + override fun onSaveInstanceState(savedInstanceState: Bundle) { + super.onSaveInstanceState(savedInstanceState) action?.let { - bundle.putInt("actionPosition", actionPosition) - bundle.putString("action", it.toJSON()) + savedInstanceState.putInt("actionPosition", actionPosition) + savedInstanceState.putString("action", it.toJSON()) } } } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/OKDialog.kt b/app/src/main/java/info/nightscout/androidaps/utils/OKDialog.kt index 1d22c380ca..830053bef0 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/OKDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/OKDialog.kt @@ -62,13 +62,11 @@ object OKDialog { } @JvmStatic - @JvmOverloads fun showConfirmation(activity: Activity, message: String, ok: Runnable?) { showConfirmation(activity, MainApp.gs(R.string.confirmation), message, ok, null) } @JvmStatic - @JvmOverloads fun showConfirmation(activity: Activity, message: Spanned, ok: Runnable?) { showConfirmation(activity, MainApp.gs(R.string.confirmation), message, ok, null) } From 7d9c1f8af9b60c40e4713fd439d6fdc5eeb00d89 Mon Sep 17 00:00:00 2001 From: TebbeUbben Date: Mon, 9 Mar 2020 23:07:55 +0100 Subject: [PATCH 19/33] Use "Display time-sensitive notifications" for Insight alerts --- app/src/main/AndroidManifest.xml | 3 + .../pump/insight/InsightAlertService.java | 187 ++++++++++++------ .../pump/insight/LocalInsightPlugin.java | 15 ++ .../activities/InsightAlertActivity.java | 175 ++-------------- .../pump/insight/descriptors/Alert.java | 20 ++ .../plugins/pump/insight/utils/AlertUtils.kt | 107 ++++++++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 4 +- 8 files changed, 286 insertions(+), 226 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/utils/AlertUtils.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b571e247c2..6318d88e46 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,6 +23,7 @@ + @@ -264,6 +265,8 @@ alertLiveData = new MutableLiveData<>(); private Thread thread; - private InsightAlertActivity alertActivity; - private Ringtone ringtone; private Vibrator vibrator; private boolean vibrating; private InsightConnectionService connectionService; @@ -65,27 +68,6 @@ public class InsightAlertService extends Service implements InsightConnectionSer } }; - private void retrieveRingtone() { - Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); - ringtone = RingtoneManager.getRingtone(this, uri); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - ringtone.setAudioAttributes(new AudioAttributes.Builder() - .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE) - .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN) - .setLegacyStreamType(AudioManager.STREAM_RING).build()); - } else ringtone.setStreamType(AudioManager.STREAM_RING); - } - - public Alert getAlert() { - synchronized ($alertLock) { - return alert; - } - } - - public void setAlertActivity(InsightAlertActivity alertActivity) { - this.alertActivity = alertActivity; - } - public void ignore(AlertType alertType) { synchronized ($alertLock) { if (alertType == null) { @@ -98,6 +80,10 @@ public class InsightAlertService extends Service implements InsightConnectionSer } } + public MutableLiveData getAlertLiveData() { + return alertLiveData; + } + @Nullable @Override public IBinder onBind(Intent intent) { @@ -108,6 +94,7 @@ public class InsightAlertService extends Service implements InsightConnectionSer public void onCreate() { vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); bindService(new Intent(this, InsightConnectionService.class), serviceConnection, BIND_AUTO_CREATE); + alertLiveData.setValue(null); } @Override @@ -118,6 +105,12 @@ public class InsightAlertService extends Service implements InsightConnectionSer @Override public int onStartCommand(Intent intent, int flags, int startId) { + if ("mute".equals(intent.getStringExtra("command"))) { + mute(); + } else if ("confirm".equals(intent.getStringExtra("command"))) { + dismissNotification(); + confirm(); + } return START_STICKY; } @@ -127,25 +120,47 @@ public class InsightAlertService extends Service implements InsightConnectionSer thread = new Thread(this::queryActiveAlert); thread.start(); - } else if (thread != null) thread.interrupt(); + } else { + dismissNotification(); + if (thread != null) thread.interrupt(); + } } private void queryActiveAlert() { while (!Thread.currentThread().isInterrupted()) { try { Alert alert = connectionService.requestMessage(new GetActiveAlertMessage()).await().getAlert(); - if (Thread.currentThread().isInterrupted()) { - connectionService.withdrawConnectionRequest(thread); - break; - } synchronized ($alertLock) { - if ((this.alert == null && alert != null) + if (alert == null || (alert.getAlertType() == ignoreType && System.currentTimeMillis() - ignoreTimestamp < 10000)) { + if (connectionRequested) { + connectionService.withdrawConnectionRequest(this); + connectionRequested = false; + } + this.alertLiveData.postValue(null); + this.alert = null; + dismissNotification(); + stopAlerting(); + } else if (!alert.equals(this.alert)) { + if (!connectionRequested) { + connectionService.requestConnection(this); + connectionRequested = true; + } + showNotification(alert); + this.alertLiveData.postValue(alert); + this.alert = alert; + if (alert.getAlertStatus() == AlertStatus.SNOOZED) stopAlerting(); + else alert(); + } + /*if ((this.alert == null && alert != null) || (this.alert != null && alert == null) || (this.alert != null && alert != null && !this.alert.equals(alert))) { if (this.alert != null && (alert == null || this.alert.getAlertId() != alert.getAlertId())) stopAlerting(); this.alert = alert; - if (alertActivity != null && alert != null) - new Handler(Looper.getMainLooper()).post(() -> alertActivity.update(alert)); + if (alert != null) + new Handler(Looper.getMainLooper()).post(() -> { + //showNotification(alert); + //alertActivity.update(alert); + }); } if (alert == null) { stopAlerting(); @@ -153,8 +168,10 @@ public class InsightAlertService extends Service implements InsightConnectionSer connectionService.withdrawConnectionRequest(this); connectionRequested = false; } - if (alertActivity != null) - new Handler(Looper.getMainLooper()).post(() -> alertActivity.finish()); + new Handler(Looper.getMainLooper()).post(() -> { + //dismissNotification(); + //alertActivity.finish(); + }); } else if (!(alert.getAlertType() == ignoreType && System.currentTimeMillis() - ignoreTimestamp < 10000)) { if (alert.getAlertStatus() == AlertStatus.ACTIVE) alert(); else stopAlerting(); @@ -162,12 +179,12 @@ public class InsightAlertService extends Service implements InsightConnectionSer connectionService.requestConnection(this); connectionRequested = true; } - if (alertActivity == null) { + /*if (alertActivity == null) { Intent intent = new Intent(InsightAlertService.this, InsightAlertActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); new Handler(Looper.getMainLooper()).post(() -> startActivity(intent)); - } - } + }*/ + //} } } catch (InterruptedException ignored) { connectionService.withdrawConnectionRequest(thread); @@ -189,21 +206,18 @@ public class InsightAlertService extends Service implements InsightConnectionSer connectionService.withdrawConnectionRequest(thread); connectionRequested = false; } - if (alertActivity != null) - new Handler(Looper.getMainLooper()).post(() -> alertActivity.finish()); stopAlerting(); + alertLiveData.postValue(null); + this.alert = null; + dismissNotification(); thread = null; } private void alert() { if (!vibrating) { - vibrator.vibrate(new long[] {0, 1000, 1000}, 0); + vibrator.vibrate(new long[]{0, 1000, 1000}, 0); vibrating = true; } - if (ringtone == null || !ringtone.isPlaying()) { - retrieveRingtone(); - ringtone.play(); - } } private void stopAlerting() { @@ -211,15 +225,21 @@ public class InsightAlertService extends Service implements InsightConnectionSer vibrator.cancel(); vibrating = false; } - if (ringtone != null && ringtone.isPlaying()) ringtone.stop(); } public void mute() { new Thread(() -> { try { - SnoozeAlertMessage snoozeAlertMessage = new SnoozeAlertMessage(); - snoozeAlertMessage.setAlertID(alert.getAlertId()); - connectionService.requestMessage(snoozeAlertMessage).await(); + synchronized ($alertLock) { + if (alert == null) return; + alert.setAlertStatus(AlertStatus.SNOOZED); + alertLiveData.postValue(alert); + stopAlerting(); + showNotification(alert); + SnoozeAlertMessage snoozeAlertMessage = new SnoozeAlertMessage(); + snoozeAlertMessage.setAlertID(alertLiveData.getValue().getAlertId()); + connectionService.requestMessage(snoozeAlertMessage).await(); + } } catch (AppLayerErrorException e) { log.info("Exception while muting alert: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")"); ExceptionTranslator.makeToast(InsightAlertService.this, e); @@ -236,9 +256,16 @@ public class InsightAlertService extends Service implements InsightConnectionSer public void confirm() { new Thread(() -> { try { - ConfirmAlertMessage confirmAlertMessage = new ConfirmAlertMessage(); - confirmAlertMessage.setAlertID(alert.getAlertId()); - connectionService.requestMessage(confirmAlertMessage).await(); + synchronized ($alertLock) { + if (alert == null) return; + stopAlerting(); + alertLiveData.postValue(null); + dismissNotification(); + ConfirmAlertMessage confirmAlertMessage = new ConfirmAlertMessage(); + confirmAlertMessage.setAlertID(alertLiveData.getValue().getAlertId()); + connectionService.requestMessage(confirmAlertMessage).await(); + this.alert = null; + } } catch (AppLayerErrorException e) { log.info("Exception while confirming alert: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")"); ExceptionTranslator.makeToast(InsightAlertService.this, e); @@ -252,6 +279,48 @@ public class InsightAlertService extends Service implements InsightConnectionSer }).start(); } + private void showNotification(Alert alert) { + NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, LocalInsightPlugin.ALERT_CHANNEL_ID); + + notificationBuilder.setPriority(NotificationCompat.PRIORITY_MAX); + notificationBuilder.setCategory(NotificationCompat.CATEGORY_ALARM); + notificationBuilder.setVibrate(new long[0]); + notificationBuilder.setShowWhen(false); + notificationBuilder.setOngoing(true); + notificationBuilder.setOnlyAlertOnce(true); + notificationBuilder.setAutoCancel(false); + notificationBuilder.setSmallIcon(AlertUtilsKt.getAlertIcon(alert.getAlertCategory())); + + notificationBuilder.setContentTitle(AlertUtilsKt.getAlertCode(alert.getAlertType()) + " – " + AlertUtilsKt.getAlertTitle(alert.getAlertType())); + String description = AlertUtilsKt.getAlertDescription(alert); + if (description != null) + notificationBuilder.setContentText(Html.fromHtml(description).toString()); + + Intent fullScreenIntent = new Intent(this, InsightAlertActivity.class); + PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(this, 0, fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT); + notificationBuilder.setFullScreenIntent(fullScreenPendingIntent, true); + + switch (alert.getAlertStatus()) { + case ACTIVE: + Intent muteIntent = new Intent(this, InsightAlertService.class).putExtra("command", "mute"); + PendingIntent mutePendingIntent = PendingIntent.getService(this, 1, muteIntent, PendingIntent.FLAG_UPDATE_CURRENT); + notificationBuilder.addAction(0, MainApp.gs(R.string.mute_alert), mutePendingIntent); + case SNOOZED: + Intent confirmIntent = new Intent(this, InsightAlertService.class).putExtra("command", "confirm"); + PendingIntent confirmPendingIntent = PendingIntent.getService(this, 2, confirmIntent, PendingIntent.FLAG_UPDATE_CURRENT); + notificationBuilder.addAction(0, MainApp.gs(R.string.confirm), confirmPendingIntent); + } + + Notification notification = notificationBuilder.build(); + NotificationManagerCompat.from(this).notify(NOTIFICATION_ID, notification); + startForeground(NOTIFICATION_ID, notification); + } + + private void dismissNotification() { + NotificationManagerCompat.from(this).cancel(NOTIFICATION_ID); + stopForeground(true); + } + public class LocalBinder extends Binder { public InsightAlertService getService() { return InsightAlertService.this; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index 2197b48577..66ee0bed5a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -1,9 +1,12 @@ package info.nightscout.androidaps.plugins.pump.insight; +import android.app.NotificationChannel; +import android.app.NotificationManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; +import android.os.Build; import android.os.Handler; import android.os.IBinder; import android.os.Looper; @@ -132,6 +135,8 @@ import info.nightscout.androidaps.utils.SP; public class LocalInsightPlugin extends PluginBase implements PumpInterface, ConstraintsInterface, InsightConnectionService.StateCallback { + public static final String ALERT_CHANNEL_ID = "AndroidAPS-InsightAlert"; + private static LocalInsightPlugin instance = null; private Logger log = LoggerFactory.getLogger(L.PUMP); @@ -245,6 +250,15 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con super.onStart(); MainApp.instance().bindService(new Intent(MainApp.instance(), InsightConnectionService.class), serviceConnection, Context.BIND_AUTO_CREATE); MainApp.instance().bindService(new Intent(MainApp.instance(), InsightAlertService.class), serviceConnection, Context.BIND_AUTO_CREATE); + createNotificationChannel(); + } + + private void createNotificationChannel() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + NotificationManager notificationManager = (NotificationManager) MainApp.instance().getSystemService(Context.NOTIFICATION_SERVICE); + NotificationChannel channel = new NotificationChannel(ALERT_CHANNEL_ID, MainApp.gs(R.string.insight_alert_notification_channel), NotificationManager.IMPORTANCE_HIGH); + notificationManager.createNotificationChannel(channel); + } } @Override @@ -647,6 +661,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con cancelBolusMessage.setBolusID(bolusID); connectionService.requestMessage(cancelBolusMessage).await(); bolusCancelled = true; + alertService.ignore(null); } confirmAlert(AlertType.WARNING_38); } catch (AppLayerErrorException e) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/activities/InsightAlertActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/activities/InsightAlertActivity.java index 77be3ab03a..8ebd05801b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/activities/InsightAlertActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/activities/InsightAlertActivity.java @@ -12,19 +12,18 @@ import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; +import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat; -import java.text.DecimalFormat; - import info.nightscout.androidaps.R; import info.nightscout.androidaps.activities.NoSplashAppCompatActivity; import info.nightscout.androidaps.plugins.pump.insight.InsightAlertService; import info.nightscout.androidaps.plugins.pump.insight.descriptors.Alert; import info.nightscout.androidaps.plugins.pump.insight.descriptors.AlertStatus; +import info.nightscout.androidaps.plugins.pump.insight.utils.AlertUtilsKt; -public class InsightAlertActivity extends NoSplashAppCompatActivity { +public class InsightAlertActivity extends AppCompatActivity { - private Alert alert; private InsightAlertService alertService; private ImageView icon; @@ -38,10 +37,10 @@ public class InsightAlertActivity extends NoSplashAppCompatActivity { @Override public void onServiceConnected(ComponentName name, IBinder binder) { alertService = ((InsightAlertService.LocalBinder) binder).getService(); - alertService.setAlertActivity(InsightAlertActivity.this); - alert = alertService.getAlert(); - if (alert == null) finish(); - else update(alert); + alertService.getAlertLiveData().observe(InsightAlertActivity.this, alert -> { + if (alert == null) finish(); + else update(alert); + }); } @Override @@ -70,174 +69,22 @@ public class InsightAlertActivity extends NoSplashAppCompatActivity { | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); - WindowManager.LayoutParams layoutParams = getWindow().getAttributes(); - layoutParams.screenBrightness = 1.0F; - getWindow().setAttributes(layoutParams); } @Override protected void onDestroy() { - alertService.setAlertActivity(null); unbindService(serviceConnection); super.onDestroy(); } public void update(Alert alert) { - this.alert = alert; mute.setEnabled(true); mute.setVisibility(alert.getAlertStatus() == AlertStatus.SNOOZED ? View.GONE : View.VISIBLE); confirm.setEnabled(true); - int icon = 0; - int code = 0; - int title = 0; - String description = null; - switch (alert.getAlertCategory()) { - case ERROR: - icon = R.drawable.ic_error; - break; - case MAINTENANCE: - icon = R.drawable.ic_maintenance; - break; - case WARNING: - icon = R.drawable.ic_warning; - break; - case REMINDER: - icon = R.drawable.ic_reminder; - break; - } - DecimalFormat decimalFormat = new DecimalFormat("##0.00"); - int hours = alert.getTBRDuration() / 60; - int minutes = alert.getTBRDuration() - hours * 60; - switch (alert.getAlertType()) { - case REMINDER_01: - code = R.string.alert_r1_code; - title = R.string.alert_r1_title; - break; - case REMINDER_02: - code = R.string.alert_r2_code; - title = R.string.alert_r2_title; - break; - case REMINDER_03: - code = R.string.alert_r3_code; - title = R.string.alert_r3_title; - break; - case REMINDER_04: - code = R.string.alert_r4_code; - title = R.string.alert_r4_title; - break; - case REMINDER_07: - code = R.string.alert_r7_code; - title = R.string.alert_r7_title; - description = getString(R.string.alert_r7_description, alert.getTBRAmount(), new DecimalFormat("#0").format(hours) + ":" + new DecimalFormat("00").format(minutes)); - break; - case WARNING_31: - code = R.string.alert_w31_code; - title = R.string.alert_w31_title; - description = getString(R.string.alert_w31_description, decimalFormat.format(alert.getCartridgeAmount())); - break; - case WARNING_32: - code = R.string.alert_w32_code; - title = R.string.alert_w32_title; - description = getString(R.string.alert_w32_description); - break; - case WARNING_33: - code = R.string.alert_w33_code; - title = R.string.alert_w33_title; - description = getString(R.string.alert_w33_description); - break; - case WARNING_34: - code = R.string.alert_w34_code; - title = R.string.alert_w34_title; - description = getString(R.string.alert_w34_description); - break; - case WARNING_36: - code = R.string.alert_w36_code; - title = R.string.alert_w36_title; - description = getString(R.string.alert_w36_description, alert.getTBRAmount(), new DecimalFormat("#0").format(hours) + ":" + new DecimalFormat("00").format(minutes)); - break; - case WARNING_38: - code = R.string.alert_w38_code; - title = R.string.alert_w38_title; - description = getString(R.string.alert_w38_description, decimalFormat.format(alert.getProgrammedBolusAmount()), decimalFormat.format(alert.getDeliveredBolusAmount())); - break; - case WARNING_39: - code = R.string.alert_w39_code; - title = R.string.alert_w39_title; - break; - case MAINTENANCE_20: - code = R.string.alert_m20_code; - title = R.string.alert_m20_title; - description = getString(R.string.alert_m20_description); - break; - case MAINTENANCE_21: - code = R.string.alert_m21_code; - title = R.string.alert_m21_title; - description = getString(R.string.alert_m21_description); - break; - case MAINTENANCE_22: - code = R.string.alert_m22_code; - title = R.string.alert_m22_title; - description = getString(R.string.alert_m22_description); - break; - case MAINTENANCE_23: - code = R.string.alert_m23_code; - title = R.string.alert_m23_title; - description = getString(R.string.alert_m23_description); - break; - case MAINTENANCE_24: - code = R.string.alert_m24_code; - title = R.string.alert_m24_title; - description = getString(R.string.alert_m24_description); - break; - case MAINTENANCE_25: - code = R.string.alert_m25_code; - title = R.string.alert_m25_title; - description = getString(R.string.alert_m25_description); - break; - case MAINTENANCE_26: - code = R.string.alert_m26_code; - title = R.string.alert_m26_title; - description = getString(R.string.alert_m26_description); - break; - case MAINTENANCE_27: - code = R.string.alert_m27_code; - title = R.string.alert_m27_title; - description = getString(R.string.alert_m27_description); - break; - case MAINTENANCE_28: - code = R.string.alert_m28_code; - title = R.string.alert_m28_title; - description = getString(R.string.alert_m28_description); - break; - case MAINTENANCE_29: - code = R.string.alert_m29_code; - title = R.string.alert_m29_title; - description = getString(R.string.alert_m29_description); - break; - case MAINTENANCE_30: - code = R.string.alert_m30_code; - title = R.string.alert_m30_title; - description = getString(R.string.alert_m30_description); - break; - case ERROR_6: - code = R.string.alert_e6_code; - title = R.string.alert_e6_title; - description = getString(R.string.alert_e6_description); - break; - case ERROR_10: - code = R.string.alert_e10_code; - title = R.string.alert_e10_title; - description = getString(R.string.alert_e10_description); - break; - case ERROR_13: - code = R.string.alert_e13_code; - title = R.string.alert_e13_title; - description = getString(R.string.alert_e13_description); - break; - } - this.icon.setImageDrawable(ContextCompat.getDrawable(this, icon)); - this.errorCode.setText(code); - this.errorTitle.setText(title); + this.icon.setImageDrawable(ContextCompat.getDrawable(this, AlertUtilsKt.getAlertIcon(alert.getAlertCategory()))); + this.errorCode.setText(AlertUtilsKt.getAlertCode(alert.getAlertType())); + this.errorTitle.setText(AlertUtilsKt.getAlertTitle(alert.getAlertType())); + String description = AlertUtilsKt.getAlertDescription(alert); if (description == null) this.errorDescription.setVisibility(View.GONE); else { this.errorDescription.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/descriptors/Alert.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/descriptors/Alert.java index 8f6668c1ca..028fcb3b71 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/descriptors/Alert.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/descriptors/Alert.java @@ -83,4 +83,24 @@ public class Alert { public double getCartridgeAmount() { return cartridgeAmount; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Alert alert = (Alert) o; + + if (alertId != alert.alertId) return false; + if (tbrAmount != alert.tbrAmount) return false; + if (tbrDuration != alert.tbrDuration) return false; + if (Double.compare(alert.programmedBolusAmount, programmedBolusAmount) != 0) + return false; + if (Double.compare(alert.deliveredBolusAmount, deliveredBolusAmount) != 0) + return false; + if (Double.compare(alert.cartridgeAmount, cartridgeAmount) != 0) return false; + if (alertCategory != alert.alertCategory) return false; + if (alertType != alert.alertType) return false; + return alertStatus == alert.alertStatus; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/utils/AlertUtils.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/utils/AlertUtils.kt new file mode 100644 index 0000000000..7cafb950cc --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/utils/AlertUtils.kt @@ -0,0 +1,107 @@ +package info.nightscout.androidaps.plugins.pump.insight.utils + +import info.nightscout.androidaps.MainApp +import info.nightscout.androidaps.R +import info.nightscout.androidaps.plugins.pump.insight.descriptors.Alert +import info.nightscout.androidaps.plugins.pump.insight.descriptors.AlertCategory +import info.nightscout.androidaps.plugins.pump.insight.descriptors.AlertType +import java.text.DecimalFormat + +fun getAlertCode(alertType: AlertType) = MainApp.gs(when (alertType) { + AlertType.REMINDER_01 -> R.string.alert_r1_code + AlertType.REMINDER_02 -> R.string.alert_r2_code + AlertType.REMINDER_03 -> R.string.alert_r3_code + AlertType.REMINDER_04 -> R.string.alert_r4_code + AlertType.REMINDER_07 -> R.string.alert_r7_code + AlertType.WARNING_31 -> R.string.alert_w31_code + AlertType.WARNING_32 -> R.string.alert_w32_code + AlertType.WARNING_33 -> R.string.alert_w33_code + AlertType.WARNING_34 -> R.string.alert_w34_code + AlertType.WARNING_36 -> R.string.alert_w36_code + AlertType.WARNING_38 -> R.string.alert_w38_code + AlertType.WARNING_39 -> R.string.alert_w39_code + AlertType.MAINTENANCE_20 -> R.string.alert_m20_code + AlertType.MAINTENANCE_21 -> R.string.alert_m21_code + AlertType.MAINTENANCE_22 -> R.string.alert_m22_code + AlertType.MAINTENANCE_23 -> R.string.alert_m23_code + AlertType.MAINTENANCE_24 -> R.string.alert_m24_code + AlertType.MAINTENANCE_25 -> R.string.alert_m25_code + AlertType.MAINTENANCE_26 -> R.string.alert_m26_code + AlertType.MAINTENANCE_27 -> R.string.alert_m27_code + AlertType.MAINTENANCE_28 -> R.string.alert_m28_code + AlertType.MAINTENANCE_29 -> R.string.alert_m29_code + AlertType.MAINTENANCE_30 -> R.string.alert_m30_code + AlertType.ERROR_6 -> R.string.alert_e6_code + AlertType.ERROR_10 -> R.string.alert_e10_code + AlertType.ERROR_13 -> R.string.alert_e13_code +}) + +fun getAlertTitle(alertType: AlertType) = MainApp.gs(when (alertType) { + AlertType.REMINDER_01 -> R.string.alert_r1_title + AlertType.REMINDER_02 -> R.string.alert_r2_title + AlertType.REMINDER_03 -> R.string.alert_r3_title + AlertType.REMINDER_04 -> R.string.alert_r4_title + AlertType.REMINDER_07 -> R.string.alert_r7_title + AlertType.WARNING_31 -> R.string.alert_w31_title + AlertType.WARNING_32 -> R.string.alert_w32_title + AlertType.WARNING_33 -> R.string.alert_w33_title + AlertType.WARNING_34 -> R.string.alert_w34_title + AlertType.WARNING_36 -> R.string.alert_w36_title + AlertType.WARNING_38 -> R.string.alert_w38_title + AlertType.WARNING_39 -> R.string.alert_w39_title + AlertType.MAINTENANCE_20 -> R.string.alert_m20_title + AlertType.MAINTENANCE_21 -> R.string.alert_m21_title + AlertType.MAINTENANCE_22 -> R.string.alert_m22_title + AlertType.MAINTENANCE_23 -> R.string.alert_m23_title + AlertType.MAINTENANCE_24 -> R.string.alert_m24_title + AlertType.MAINTENANCE_25 -> R.string.alert_m25_title + AlertType.MAINTENANCE_26 -> R.string.alert_m26_title + AlertType.MAINTENANCE_27 -> R.string.alert_m27_title + AlertType.MAINTENANCE_28 -> R.string.alert_m28_title + AlertType.MAINTENANCE_29 -> R.string.alert_m29_title + AlertType.MAINTENANCE_30 -> R.string.alert_m30_title + AlertType.ERROR_6 -> R.string.alert_e6_title + AlertType.ERROR_10 -> R.string.alert_e10_title + AlertType.ERROR_13 -> R.string.alert_e13_title +}) + +fun getAlertDescription(alert: Alert): String? { + val decimalFormat = DecimalFormat("##0.00") + val hours = alert.tbrDuration / 60 + val minutes = alert.tbrDuration - hours * 60 + return when (alert.alertType!!) { + AlertType.REMINDER_01 -> null + AlertType.REMINDER_02 -> null + AlertType.REMINDER_03 -> null + AlertType.REMINDER_04 -> null + AlertType.REMINDER_07 -> MainApp.gs(R.string.alert_r7_description, alert.tbrAmount, DecimalFormat("#0").format(hours.toLong()) + ":" + DecimalFormat("00").format(minutes.toLong())) + AlertType.WARNING_31 -> MainApp.gs(R.string.alert_w31_description, decimalFormat.format(alert.cartridgeAmount)) + AlertType.WARNING_32 -> MainApp.gs(R.string.alert_w32_description) + AlertType.WARNING_33 -> MainApp.gs(R.string.alert_w33_description) + AlertType.WARNING_34 -> MainApp.gs(R.string.alert_w34_description) + AlertType.WARNING_36 -> MainApp.gs(R.string.alert_w36_description, alert.tbrAmount, DecimalFormat("#0").format(hours.toLong()) + ":" + DecimalFormat("00").format(minutes.toLong())) + AlertType.WARNING_38 -> MainApp.gs(R.string.alert_w38_description, decimalFormat.format(alert.programmedBolusAmount), decimalFormat.format(alert.deliveredBolusAmount)) + AlertType.WARNING_39 -> null + AlertType.MAINTENANCE_20 -> MainApp.gs(R.string.alert_m20_description) + AlertType.MAINTENANCE_21 -> MainApp.gs(R.string.alert_m21_description) + AlertType.MAINTENANCE_22 -> MainApp.gs(R.string.alert_m22_description) + AlertType.MAINTENANCE_23 -> MainApp.gs(R.string.alert_m23_description) + AlertType.MAINTENANCE_24 -> MainApp.gs(R.string.alert_m24_description) + AlertType.MAINTENANCE_25 -> MainApp.gs(R.string.alert_m25_description) + AlertType.MAINTENANCE_26 -> MainApp.gs(R.string.alert_m26_description) + AlertType.MAINTENANCE_27 -> MainApp.gs(R.string.alert_m27_description) + AlertType.MAINTENANCE_28 -> MainApp.gs(R.string.alert_m28_description) + AlertType.MAINTENANCE_29 -> MainApp.gs(R.string.alert_m29_description) + AlertType.MAINTENANCE_30 -> MainApp.gs(R.string.alert_m30_description) + AlertType.ERROR_6 -> MainApp.gs(R.string.alert_e6_description) + AlertType.ERROR_10 -> MainApp.gs(R.string.alert_e10_description) + AlertType.ERROR_13 -> MainApp.gs(R.string.alert_e13_description) + } +} + +fun getAlertIcon(alertCategory: AlertCategory) = when (alertCategory) { + AlertCategory.ERROR -> R.drawable.ic_error + AlertCategory.MAINTENANCE -> R.drawable.ic_maintenance + AlertCategory.WARNING -> R.drawable.ic_warning + AlertCategory.REMINDER -> R.drawable.ic_reminder +} \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2e06c2a027..a4c79cb63b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1698,5 +1698,6 @@ SMB execution time Temp basal request time Temp basal execution time + Insight Pump Alerts
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index d2cacff3b7..d78df37ac4 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -27,12 +27,10 @@ @android:style/Animation -