From 36d6edf0dbfa6c524886be1c510269e2e67256b5 Mon Sep 17 00:00:00 2001 From: McHoffi Date: Sun, 6 May 2018 12:16:51 +0200 Subject: [PATCH 01/25] Update strings.xml --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e0ce1ebbf0..590e68d289 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -305,7 +305,7 @@ Adjust basals and ratios if needed, and then enable auto-sens 1 week successful daytime looping with regular carb entry Enabling additional features for daytime use, such as advanced meal assist - Enabling additional features for daytime use, such as SMB + Enabling additional features for daytime use, such as SMB. You must read the wiki and rise maxIOB! You reached allowed limit No profile selected Loop has been disabled From 06948ca0f4fe3aa69f5a5b023ecab9fa5652b517 Mon Sep 17 00:00:00 2001 From: McHoffi Date: Sun, 6 May 2018 18:16:42 +0200 Subject: [PATCH 02/25] Update strings.xml --- app/src/main/res/values/strings.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 590e68d289..79f461e14d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -305,7 +305,8 @@ Adjust basals and ratios if needed, and then enable auto-sens 1 week successful daytime looping with regular carb entry Enabling additional features for daytime use, such as advanced meal assist - Enabling additional features for daytime use, such as SMB. You must read the wiki and rise maxIOB! + Enabling additional features for daytime use, such as SMB + You must read the wiki and rise maxIOB to get SMBs working fine! You reached allowed limit No profile selected Loop has been disabled From 9d367c1fa1f1a6d6df05b363f1b2862332d011fb Mon Sep 17 00:00:00 2001 From: McHoffi Date: Sun, 6 May 2018 18:18:34 +0200 Subject: [PATCH 03/25] Update ObjectivesFragment.java --- .../plugins/ConstraintsObjectives/ObjectivesFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java index 1424013440..adceccb15a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesFragment.java @@ -255,6 +255,7 @@ public class ObjectivesFragment extends SubscriberFragment { ObjectivesPlugin.objectives.get(3).gate = MainApp.gs(R.string.objectives_3_gate); ObjectivesPlugin.objectives.get(4).gate = MainApp.gs(R.string.objectives_4_gate); ObjectivesPlugin.objectives.get(5).gate = MainApp.gs(R.string.objectives_5_gate); + ObjectivesPlugin.objectives.get(7).gate = MainApp.gs(R.string.objectives_7_gate); updateGUI(); @@ -276,4 +277,4 @@ public class ObjectivesFragment extends SubscriberFragment { }); } -} \ No newline at end of file +} From 2ae63693629c55ad4e9dae85c5b87e099d5baa56 Mon Sep 17 00:00:00 2001 From: boysim Date: Sun, 6 May 2018 22:52:04 +0200 Subject: [PATCH 04/25] added dutch translations --- app/src/main/res/values-nl/strings.xml | 125 +++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index dd14859672..a21188d657 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -739,5 +739,130 @@ Creëer een Nightscout melding voor storingen en lokale waarschuwingen (ook zichtbaar inder het Careportal en behandelingen) Datum/tijd van de geleverde bolus op de pomp is niet correct, IOB is waarschijnlijk foutief. Controleer aub de datum/tijd op de pomp. Profiel wissel ontbreekt. Doe aub een profiel wissel of duw op Activeer Profiel in het Lokale profiel. + tijdelijk basaal gezet door pomp + line resistente volwassene + SMB + Activeer UAM + Activeer SMB + Verwisseld + Pomp Gestopt + Status vernieuwd + status + Insight pomp + Français + Hypo + OpenAPS SMB + Gebruik SMB in plaats van tijdelijke basalen voor snellere reactie + Detectie van niet aangekondigde maaltijden + m + u + Insight + Hypo tijdsduur + Initialiseren + Logboek + Storing E13: Taal storing + Storing E10: Terugdraai storing + Storing E7: Elektronische storing + Storing E6: Mechanische storing + Blijf altijd verbonden + Syncroniseren + Rust + Bezig + Gesyncroniseerd + Niet geautoriseerd + incompatibel + seconde + minuut + uur + dag + week + s + Statistieken + Automatische verbinden wanneer AndroidAPS scherm geopend wordt, voordat er een pomp commande wordt uitgevoerd om zo de verbindingsvertraging te omzeilen + Code geweigerd + Niet aangewezen door hoog batterij verbuik + Activeer SMB altijd + Activeer SMB altijd onafhangkelijk van bolussen. Enkel mogelijk met een BG bron met goed gefilterde gevens zoals de G5 + Activeer SMB na koolhydraten + Activeer SMB voor 6u, eveneens met 0 COB. Enkel mogelijk met een BG bron met goed gefilterde gevens zoals de G5 + Insuline + Koolhydraten + Knoppen + Stuurt een kalibratie naar xDrip+ of opent het G5 calibratie venster + Opent xDrip+, terug knop voor terug naar AAPS te gaan + Aantal koolhydraten toevoegen wanneer de knop wordt ingeduwd + Hoeveelheid insuline dat wordt toegevoegd wanneer er op de knop geduwt word + Kon de CGM applicatie niet starten. Zorg dat deze geïnstalleerd is. + CGM + Historiek venster + Waarschuw bij SMB + Laat tijdelijk basaal lopen + Voorspellingen + Fabric Upload + Categorie + subcategorie + Bolus zal enkel opgeslaan worden + SMB op de pomp ingesteld + Gevoeligheid + Afwijkingen + Geef geen bolus, enkel opslaan in database + Basalen + n/a + Wizard instellingen + Berekeningen inclusief in het resultaat van de wizard + Scherm instellingen + Algemene instellingen + Waarschuwing W31: Patroon bijna leeg + Waarschuwing W38: Bolus geannuleerd + Waarschuwing W36: Tijdelijk basaal geannuleerd + Waarschuwing W32: Batterij niveau laag + Waarschuwing W33: Datum/tijd onjuist + Waarschuwing W34: Einde van garantie periode + Onderhoudsmelding M20: Insuline patroon niet geplaatst + Onderhoudsmelding M21: Insuline patroon leeg + Onderhoudsmelding M22: Batterij leeg + Onderhoudsmelding M23: Automatische uit + Onderhoudsmelding M24: Verstopping + Onderhoudsmelding m25: Huur periode voorbij - einde van werking + Onderhoudsmelding M26: Insuline patroon wissl niet compleet + Onderhoudsmelding M27: Gegevens download mislukt + Onderhoudsmelding M26: Gepauzeerde modus verlopen + Onderhoudsmelding M29: Batterij type niet ingesteld + Onderhoudsmelding M30: Insuline patroon type niet ingesteld + Waarschuwing W39: Huurperiode waarschuwing + WiFi SSID + Gebuik enkel de WiFi verbinding + Toegelaten SSIDs (gescheiden door puntkomma) + Pomp gestopt + Pomp gestart + Pomp gepauzeerd + Maximum maaltijd absorbtie tijd (h) + Tijd + Toon het notities veld in het behandelings dialoog + CGM + Voeding + Reset + Wachttijd voor syncronisatie (%d sec) + Voorbij + met + Actieve TBR + resterende minuten + Opstarten + benodigd + min + Laatst afgewerkte actie + totaal + Activeer SMB met Koolhydraten + Activeer SMB met actieve koolhydraten + Gebruik SMB met tijdelijke doelen + Gebruik SMB wanneer er een tiijdelijk bassaal actief is (binnenkort eten, inspanningen) + Gebruik SMB met een hoog tijdelijk doel + Gebruik SMB wanneer er een hoog tijdelijk doen actief is (Inspanningen) + Start inspanning TT + Start binnenkort eten TT + TT + Aantal bolussen + Aantal TBR + Doel %d niet gestart From 77522d077067888e19fec9e2a088caee46109bb5 Mon Sep 17 00:00:00 2001 From: McHoffi Date: Wed, 9 May 2018 09:45:53 +0200 Subject: [PATCH 05/25] Update strings.xml --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 79f461e14d..cdd3cb7348 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -306,7 +306,7 @@ 1 week successful daytime looping with regular carb entry Enabling additional features for daytime use, such as advanced meal assist Enabling additional features for daytime use, such as SMB - You must read the wiki and rise maxIOB to get SMBs working fine! + You must read the wiki and rise maxIOB to get SMBs working fine! A good start is maxIOB=average mealbolus + 3 x max daily basal You reached allowed limit No profile selected Loop has been disabled From 0227fc00895be3e86e49963bf8a4077a4d8d88a1 Mon Sep 17 00:00:00 2001 From: boysim Date: Thu, 10 May 2018 11:53:38 +0200 Subject: [PATCH 06/25] added dutch translations --- app/src/main/res/values-nl/strings.xml | 57 ++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index a21188d657..6c20e0d94e 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -864,5 +864,62 @@ Aantal bolussen Aantal TBR Doel %d niet gestart + Toon SMB op horloge zoals gewone bolussen. + Toon de voorspellingen op het horloge + Data Keuzes + Sta automatische crashrapporten en verder gebruik van data toe zodat deze naar de ontwikelaars via fabric.io kan verzonden worden. + Automatische BG aanvullen + Actuele veiliheids verhoger van basaal + Maximale dagelijkse veiligheids vermeningvuldigings factor + Bolus snooze dia deler + Min autosens factor + Max autosens factor + Sta verbinding tijdens roaming toe + Verbindings instellingen + Enkel tijdens opladen + Gevraagd: %.2fU Afgegeven: %.2fU Storings code: %d + Românesc + Chinese + Autosens regelt de BG streefwaarde bij + Hypo streefwaarde + Maximum aantal minuten basaal om de SMB te limiteren tot + Verbind preëntief + Opgenomen Koolhydraten + Opgenomen Insuline + Geen actie geselecteerd, er zal niets uitgevoerd worden + Keep-alive status + Update juoq G5 app naar de ondersteunde versie + automatische ontbenkende BGs aanvullen van NS + Start Hypo TT + Engineering modus is geactiveerd + Engineering modus is niet geactiveerd en dit is niet de relaese branche + Doel %d niet afgewerkt + Pomp kan geen tijdelijk basaal aanvaarden + Geen plausibel basale snelheid van pomp kunnen lezen + Autosens gedeactiveerd in de voorkeuren + Closed Loop modus gedeactiveerd in de voorkeuren + SMB gedeactiveerd in de voorkeuren + Ongekend + Begrezen van max basaal tot %.2f E/U want de %s + Pomp limiet + dit moet een positieve waarde zijn + Basaal correct ingesteld + Begrezen van max procentuele wijzigen tot %d%% want de %s + SMB altijd gedeactiveerd doordat de gekozen BG bron geen optimale filtering toepast + SMB niet toegestaan in Open Loop modus + Niet verbonden (%d m) + max limiet (SC) + Onveilig gebruik + Dev cersie actief. Closed loop gedeactiveerd + Anneuleren van een TBR zorgt voor een alarm op de pomp, daarom wordt pomp op 90% gezet voor 1 minuut + Wacht op confirmatie van code + Incompatiebele hulp app, we hebben deze versie nodig + app koppeling + Gebruik echte TBR uischakelingen + Niet verbonden met de hulpapp! + Hulp app lijkt niet geïnstalleerd + Markeer een infuuwissel in NS + Leezen van status mislukt + Markeer een insuline ampull wissel in NS From bf5e8e7142494174bfc3d0848e0d3770b8820937 Mon Sep 17 00:00:00 2001 From: boysim Date: Fri, 11 May 2018 21:26:42 +0200 Subject: [PATCH 07/25] added dutch translations --- app/src/main/res/values-nl/strings.xml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 6c20e0d94e..8b247cf528 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -921,5 +921,28 @@ Markeer een infuuwissel in NS Leezen van status mislukt Markeer een insuline ampull wissel in NS + Automatische Careportal gebeurtenissen + resterende van + op voorhand met + %ds verloopt %s + " http://www.androidaps.org facebook: http://facebook.androidaps.org" + "Eerste insuline increment" + Tweede insuline increment + Derde insuline increment + Eerste koolhydraten increment + Tweede koolhydraten increment + Derde koolhydraten increment + Bolus beperkt tot %.1f E doordat %s + Er is een bolus toegediend gedurende de afgelopen 3 minuten, SMB wordt overgeslagen + Max IOB wordt beperkt tot %1.f E doordat %s + Koolhydraten worden beperkt tot %d gr doordat %s + Maximum waarde in voorkeuren + IOB gelimmiteerd tot %.1f E doordat %s + Automatische Insuline, infusieset wissels, batterij wissels en pomp alarmen naar NS uploaden + Tijdspanne waarbinnen elke maaltijd vollezig is opgenomen. Resterende KH worden niet mee gerekend. + Max yoyzlr IOB OpenAPS niet kan overschrijden (E) + Max basaal vermenigvuldiger + Max dagelijks basaal vermenigvuldiger + Deze waarde is MAX IOB genoemd in OpenAPS context, OpenAPS zal geen insuline toedenen in de actuele IOB groter is dan deze waarde From aab85fe298357b28324d36fb215d456d21214cd4 Mon Sep 17 00:00:00 2001 From: boysim Date: Fri, 11 May 2018 23:23:55 +0200 Subject: [PATCH 08/25] added dutch translations --- app/src/main/res/values-nl/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 8b247cf528..32b227451e 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -740,7 +740,7 @@ Datum/tijd van de geleverde bolus op de pomp is niet correct, IOB is waarschijnlijk foutief. Controleer aub de datum/tijd op de pomp. Profiel wissel ontbreekt. Doe aub een profiel wissel of duw op Activeer Profiel in het Lokale profiel. tijdelijk basaal gezet door pomp - line resistente volwassene + insuline resistente volwassene SMB Activeer UAM Activeer SMB From da8acd4a1e7cb4438ea9fdc2d970236ccc39f328 Mon Sep 17 00:00:00 2001 From: boysim Date: Sun, 20 May 2018 12:55:52 +0200 Subject: [PATCH 09/25] dutch typo fixes --- app/src/main/res/values-nl/strings.xml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 32b227451e..22414b1263 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -170,7 +170,7 @@ Opslaan Veiligheid Verzend calibratie %.1f naar xDrip? - Vergeet niet alle gegeten koolhydraten in te geven bij het activeren van de Autosens functie. Anders zullen BG wijzigingen door maaltijden foutief geïnterpreteerd worden!! + Vergeet niet alle opgenomen koolhydraten in te geven. Anders zullen BG wijzigingen door maaltijden foutief geïnterpreteerd worden!! Gevoeligheid AAPS Gevoeligheid Oref0 Accepteer nieuw tijdelijk basaal: @@ -410,7 +410,7 @@ Standaardwaarde: waar Dit wordt gebruikt om autosens de bevoegdheid te geven BG doelen aan te passen alsook ISF en basalen Interval voor autosens [u] Aantal uren in het verleden voor gevoeligheids detectie (koolhy. absorbtie tijd niet meegerekend) - Gebruik de AMA autosens functie + Activeer AMA autosens OpenAPS MA Autosens gegevens Plugin is gedeactiveerd @@ -544,7 +544,7 @@ Vaste maaltijd Vaste maaltijd instellingen Verwijder gegeven: - Verzend alle gegevens opnieuw + Update Wear gegevens Wil je echt de databank wissen? SENS Klein gemiddeld verschil @@ -752,7 +752,7 @@ Français Hypo OpenAPS SMB - Gebruik SMB in plaats van tijdelijke basalen voor snellere reactie + SMB in plaats van tijdelijke basalen voor snellere reactie Detectie van niet aangekondigde maaltijden m u @@ -782,9 +782,9 @@ Code geweigerd Niet aangewezen door hoog batterij verbuik Activeer SMB altijd - Activeer SMB altijd onafhangkelijk van bolussen. Enkel mogelijk met een BG bron met goed gefilterde gevens zoals de G5 + SMB altijd onafhangkelijk van bolussen. Enkel mogelijk met een BG bron met goed gefilterde data zoals de G5 Activeer SMB na koolhydraten - Activeer SMB voor 6u, eveneens met 0 COB. Enkel mogelijk met een BG bron met goed gefilterde gevens zoals de G5 + SMB actief gedurende 6u, zelfs met 0 COB. Enkel mogelijk met een BG bron met goed gefilterde data zoals de G5 Insuline Koolhydraten Knoppen @@ -853,11 +853,11 @@ Laatst afgewerkte actie totaal Activeer SMB met Koolhydraten - Activeer SMB met actieve koolhydraten + SMB actief tijdens actieve koolhydraten Gebruik SMB met tijdelijke doelen - Gebruik SMB wanneer er een tiijdelijk bassaal actief is (binnenkort eten, inspanningen) + Gebruik SMB bij een actief tijdelijk basaal (binnenkort eten, inspanningen) Gebruik SMB met een hoog tijdelijk doel - Gebruik SMB wanneer er een hoog tijdelijk doen actief is (Inspanningen) + Gebruik SMB tijdens een verhoogd tijdelijk doel (Inspanningen) Start inspanning TT Start binnenkort eten TT TT @@ -900,7 +900,7 @@ Closed Loop modus gedeactiveerd in de voorkeuren SMB gedeactiveerd in de voorkeuren Ongekend - Begrezen van max basaal tot %.2f E/U want de %s + Beperken van basaal tot max %.2f E/U aangezien de %s Pomp limiet dit moet een positieve waarde zijn Basaal correct ingesteld @@ -940,9 +940,9 @@ IOB gelimmiteerd tot %.1f E doordat %s Automatische Insuline, infusieset wissels, batterij wissels en pomp alarmen naar NS uploaden Tijdspanne waarbinnen elke maaltijd vollezig is opgenomen. Resterende KH worden niet mee gerekend. - Max yoyzlr IOB OpenAPS niet kan overschrijden (E) + Max totaal IOB dat OpenAPS niet kan overschrijden (E) Max basaal vermenigvuldiger Max dagelijks basaal vermenigvuldiger - Deze waarde is MAX IOB genoemd in OpenAPS context, OpenAPS zal geen insuline toedenen in de actuele IOB groter is dan deze waarde + MAX IOB in OpenAPS context, OpenAPS zal geen extra insuline toedenen als de actuele IOB onderstaande waarde overschreden heeft From e2bfb224f2fe6fd35ba7836add8806c7cec49aa5 Mon Sep 17 00:00:00 2001 From: boysim Date: Sun, 20 May 2018 13:36:28 +0200 Subject: [PATCH 10/25] dutch typo fixes --- app/src/main/res/values-nl/strings.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 22414b1263..ab69eaccb5 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -900,7 +900,7 @@ Closed Loop modus gedeactiveerd in de voorkeuren SMB gedeactiveerd in de voorkeuren Ongekend - Beperken van basaal tot max %.2f E/U aangezien de %s + Beperken van basaal tot max %.2f E/U wegens de %s Pomp limiet dit moet een positieve waarde zijn Basaal correct ingesteld @@ -944,5 +944,6 @@ Max basaal vermenigvuldiger Max dagelijks basaal vermenigvuldiger MAX IOB in OpenAPS context, OpenAPS zal geen extra insuline toedenen als de actuele IOB onderstaande waarde overschreden heeft + "Geen bolus toedienen enkel in behandeleingen zetten" From 5c346f5b794da13c947575e7f464a9a4a19eabb0 Mon Sep 17 00:00:00 2001 From: boysim Date: Sun, 20 May 2018 14:18:37 +0200 Subject: [PATCH 11/25] addedd formattng="false" --- app/src/main/res/values-nl/strings.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index ab69eaccb5..5b12604696 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -888,12 +888,12 @@ Opgenomen Insuline Geen actie geselecteerd, er zal niets uitgevoerd worden Keep-alive status - Update juoq G5 app naar de ondersteunde versie + Update dexcom G5 app naar de ondersteunde versie automatische ontbenkende BGs aanvullen van NS Start Hypo TT Engineering modus is geactiveerd Engineering modus is niet geactiveerd en dit is niet de relaese branche - Doel %d niet afgewerkt + Doel %d niet afgewerkt Pomp kan geen tijdelijk basaal aanvaarden Geen plausibel basale snelheid van pomp kunnen lezen Autosens gedeactiveerd in de voorkeuren @@ -904,7 +904,7 @@ Pomp limiet dit moet een positieve waarde zijn Basaal correct ingesteld - Begrezen van max procentuele wijzigen tot %d%% want de %s + Begrezen van max procentuele wijzigen tot %d%% want de %s SMB altijd gedeactiveerd doordat de gekozen BG bron geen optimale filtering toepast SMB niet toegestaan in Open Loop modus Niet verbonden (%d m) @@ -932,12 +932,12 @@ Eerste koolhydraten increment Tweede koolhydraten increment Derde koolhydraten increment - Bolus beperkt tot %.1f E doordat %s + Bolus beperkt tot %.1f E doordat %s Er is een bolus toegediend gedurende de afgelopen 3 minuten, SMB wordt overgeslagen - Max IOB wordt beperkt tot %1.f E doordat %s - Koolhydraten worden beperkt tot %d gr doordat %s + Max IOB wordt beperkt tot %1.f E doordat %s + Koolhydraten worden beperkt tot %d gr doordat %s Maximum waarde in voorkeuren - IOB gelimmiteerd tot %.1f E doordat %s + IOB gelimmiteerd tot %.1f E doordat %s Automatische Insuline, infusieset wissels, batterij wissels en pomp alarmen naar NS uploaden Tijdspanne waarbinnen elke maaltijd vollezig is opgenomen. Resterende KH worden niet mee gerekend. Max totaal IOB dat OpenAPS niet kan overschrijden (E) From 953128ffe5956e1e841e1b82e2ad8305db414a44 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 20 May 2018 19:17:46 +0200 Subject: [PATCH 12/25] UAM without advanced filtering --- .../plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java index da96241e61..396338efa4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java @@ -250,7 +250,7 @@ public class DetermineBasalAdapterSMBJS { mProfile.put("min_5m_carbimpact", SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact)); } mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap); - mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false)&& advancedFiltering); + mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false)); mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable); mProfile.put("enableSMB_with_COB", SP.getBoolean(R.string.key_enableSMB_with_COB, false)); mProfile.put("enableSMB_with_temptarget", SP.getBoolean(R.string.key_enableSMB_with_temptarget, false)); From 2626e5bb6307f9a88a2c2b712f3eba9f2e8bf2a1 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 22 May 2018 17:34:09 +0200 Subject: [PATCH 13/25] SW android permissions --- .../nightscout/androidaps/MainActivity.java | 105 +++--------------- .../androidaps/setupwizard/SWDefinition.java | 42 +++++++ .../setupwizard/SetupWizardActivity.java | 27 +++++ .../nightscout/utils/AndroidPermission.java | 78 +++++++++++++ app/src/main/res/values/strings.xml | 4 + 5 files changed, 164 insertions(+), 92 deletions(-) create mode 100644 app/src/main/java/info/nightscout/utils/AndroidPermission.java diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index cdd5c59523..84f297c0ae 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -2,19 +2,15 @@ package info.nightscout.androidaps; import android.Manifest; import android.app.Activity; -import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Rect; -import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.PowerManager; -import android.provider.Settings; import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; @@ -52,24 +48,17 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.setupwizard.SetupWizardActivity; import info.nightscout.androidaps.tabs.SlidingTabLayout; import info.nightscout.androidaps.tabs.TabPageAdapter; +import info.nightscout.utils.AndroidPermission; import info.nightscout.utils.ImportExportPrefs; import info.nightscout.utils.LocaleHelper; import info.nightscout.utils.LogDialog; import info.nightscout.utils.OKDialog; import info.nightscout.utils.PasswordProtection; import info.nightscout.utils.SP; -import info.nightscout.utils.ToastUtils; public class MainActivity extends AppCompatActivity implements View.OnClickListener { private static Logger log = LoggerFactory.getLogger(MainActivity.class); - static final int CASE_STORAGE = 0x1; - static final int CASE_SMS = 0x2; - static final int CASE_LOCATION = 0x3; - - private boolean askForSMS = false; - private boolean askForLocation = true; - ImageButton menuButton; protected PowerManager.WakeLock mWakeLock; @@ -85,10 +74,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe checkEula(); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - askForPermission(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE}, CASE_STORAGE); + AndroidPermission.askForPermission(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE}, AndroidPermission.CASE_STORAGE); } - askForBatteryOptimizationPermission(); + AndroidPermission.askForBatteryOptimizationPermission(this); doMigrations(); if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) { @@ -219,22 +208,18 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { synchronized (this) { if (SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)) { - setAskForSMS(); + AndroidPermission.setAskForSMS(); } } } } } - private synchronized void setAskForSMS() { - askForSMS = true; - } - @Override protected void onResume() { super.onResume(); - askForSMSPermissions(); - askForLocationPermissions(); + AndroidPermission.askForSMSPermissions(this); + AndroidPermission.askForLocationPermissions(this); MainApp.bus().post(new EventFeatureRunning(EventFeatureRunning.Feature.MAIN)); } @@ -246,86 +231,22 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe super.onDestroy(); } - private void askForBatteryOptimizationPermission() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - final String packageName = getPackageName(); - - final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); - if (!pm.isIgnoringBatteryOptimizations(packageName)) { - log.debug("Requesting ignore battery optimization"); - - OKDialog.show(this, MainApp.gs(R.string.pleaseallowpermission), String.format(MainApp.gs(R.string.needwhitelisting), MainApp.gs(R.string.app_name)), new Runnable() { - - @Override - public void run() { - try { - final Intent intent = new Intent(); - - // ignoring battery optimizations required for constant connection - intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); - intent.setData(Uri.parse("package:" + packageName)); - startActivity(intent); - - } catch (ActivityNotFoundException e) { - final String msg = MainApp.gs(R.string.batteryoptimalizationerror); - ToastUtils.showToastInUiThread(getApplicationContext(), msg); - log.error(msg); - } - } - }); - } - } - } - - private synchronized void askForSMSPermissions() { - if (askForSMS) { //only when settings were changed an MainActivity resumes. - askForSMS = false; - if (SP.getBoolean(R.string.smscommunicator_remotecommandsallowed, false)) { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - askForPermission(new String[]{Manifest.permission.RECEIVE_SMS, - Manifest.permission.SEND_SMS, - Manifest.permission.RECEIVE_MMS}, CASE_SMS); - } - } - } - } - - private synchronized void askForLocationPermissions() { - if (askForLocation) { //only when settings were changed an MainActivity resumes. - askForLocation = false; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - askForPermission(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION}, CASE_LOCATION); - } - } - } - - private void askForPermission(String[] permission, Integer requestCode) { - boolean test = false; - for (int i = 0; i < permission.length; i++) { - test = test || (ContextCompat.checkSelfPermission(this, permission[i]) != PackageManager.PERMISSION_GRANTED); - } - if (test) { - ActivityCompat.requestPermissions(this, permission, requestCode); - } - } - @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (permissions.length != 0) { if (ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED) { switch (requestCode) { - case CASE_STORAGE: + case AndroidPermission.CASE_STORAGE: //show dialog after permission is granted AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setMessage(R.string.alert_dialog_storage_permission_text); alert.setPositiveButton(R.string.ok, null); alert.show(); break; - case CASE_LOCATION: - case CASE_SMS: + case AndroidPermission.CASE_LOCATION: + case AndroidPermission.CASE_SMS: + case AndroidPermission.CASE_BATTERY: break; } } @@ -420,13 +341,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe if (MainApp.engineeringMode) message += "\n" + MainApp.gs(R.string.engineering_mode_enabled); message += MainApp.gs(R.string.about_link_urls); - final SpannableString messageSpanned = new SpannableString(message); + final SpannableString messageSpanned = new SpannableString(message); Linkify.addLinks(messageSpanned, Linkify.WEB_URLS); builder.setMessage(messageSpanned); builder.setPositiveButton(MainApp.gs(R.string.ok), null); AlertDialog alertDialog = builder.create(); alertDialog.show(); - ((TextView)alertDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); + ((TextView) alertDialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); break; case R.id.nav_exit: log.debug("Exiting"); diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java index 66f1d07d33..fbff517c32 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java @@ -1,6 +1,13 @@ package info.nightscout.androidaps.setupwizard; +import android.Manifest; +import android.content.ActivityNotFoundException; +import android.content.Context; import android.content.Intent; +import android.net.Uri; +import android.os.Build; +import android.os.PowerManager; +import android.provider.Settings; import android.support.v7.app.AppCompatActivity; import com.squareup.otto.Subscribe; @@ -45,19 +52,24 @@ import info.nightscout.androidaps.setupwizard.elements.SWEditString; import info.nightscout.androidaps.setupwizard.elements.SWEditUrl; import info.nightscout.androidaps.setupwizard.events.EventSWLabel; import info.nightscout.androidaps.setupwizard.events.EventSWUpdate; +import info.nightscout.utils.AndroidPermission; import info.nightscout.utils.ImportExportPrefs; import info.nightscout.utils.LocaleHelper; import info.nightscout.utils.PasswordProtection; import info.nightscout.utils.SP; +import info.nightscout.utils.ToastUtils; public class SWDefinition { private static Logger log = LoggerFactory.getLogger(SWDefinition.class); + private String packageName; + private AppCompatActivity activity; private List screens = new ArrayList<>(); public void setActivity(AppCompatActivity activity) { this.activity = activity; + packageName = activity.getPackageName(); } public AppCompatActivity getActivity() { @@ -99,6 +111,36 @@ public class SWDefinition { return SP.contains(R.string.key_language); }) ) + .add(new SWScreen(R.string.permission) + .skippable(true) + .add(new SWInfotext() + .label(String.format(MainApp.gs(R.string.needwhitelisting), MainApp.gs(R.string.app_name)))) + .add(new SWBreak()) + .add(new SWButton() + .text(R.string.askforpermission) + .action(() -> AndroidPermission.askForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, AndroidPermission.CASE_BATTERY))) + .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)) + ) + .add(new SWScreen(R.string.permission) + .skippable(true) + .add(new SWInfotext() + .label(MainApp.gs(R.string.needlocationpermission))) + .add(new SWBreak()) + .add(new SWButton() + .text(R.string.askforpermission) + .action(() -> AndroidPermission.askForPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION, AndroidPermission.CASE_LOCATION))) + .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)) + ) + .add(new SWScreen(R.string.permission) + .skippable(true) + .add(new SWInfotext() + .label(MainApp.gs(R.string.needstoragepermission))) + .add(new SWBreak()) + .add(new SWButton() + .text(R.string.askforpermission) + .action(() -> AndroidPermission.askForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE, AndroidPermission.CASE_STORAGE))) + .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) + ) .add(new SWScreen(R.string.nsclientinternal_title) .skippable(true) .add(new SWInfotext() diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java index 68ebcafdad..fde19eafaa 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java @@ -1,7 +1,10 @@ package info.nightscout.androidaps.setupwizard; import android.content.Intent; +import android.content.pm.PackageManager; import android.os.Bundle; +import android.support.v4.app.ActivityCompat; +import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.LinearLayout; @@ -24,6 +27,7 @@ import info.nightscout.androidaps.plugins.ConstraintsObjectives.events.EventObje import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus; import info.nightscout.androidaps.setupwizard.elements.SWItem; import info.nightscout.androidaps.setupwizard.events.EventSWUpdate; +import info.nightscout.utils.AndroidPermission; import info.nightscout.utils.LocaleHelper; import info.nightscout.utils.OKDialog; import info.nightscout.utils.SP; @@ -187,4 +191,27 @@ public class SetupWizardActivity extends AppCompatActivity { } return currentWizardPage; } + + @Override + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + if (permissions.length != 0) { + if (ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED) { + switch (requestCode) { + case AndroidPermission.CASE_STORAGE: + //show dialog after permission is granted + AlertDialog.Builder alert = new AlertDialog.Builder(this); + alert.setMessage(R.string.alert_dialog_storage_permission_text); + alert.setPositiveButton(R.string.ok, null); + alert.show(); + break; + case AndroidPermission.CASE_LOCATION: + case AndroidPermission.CASE_SMS: + case AndroidPermission.CASE_BATTERY: + break; + } + } + } + } + } diff --git a/app/src/main/java/info/nightscout/utils/AndroidPermission.java b/app/src/main/java/info/nightscout/utils/AndroidPermission.java new file mode 100644 index 0000000000..c0ce505e9b --- /dev/null +++ b/app/src/main/java/info/nightscout/utils/AndroidPermission.java @@ -0,0 +1,78 @@ +package info.nightscout.utils; + +import android.Manifest; +import android.app.Activity; +import android.content.Context; +import android.content.pm.PackageManager; +import android.os.Build; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; + +import info.nightscout.androidaps.R; + +public class AndroidPermission { + + private static boolean askForSMS = false; + private static boolean askForLocation = true; + + public static final int CASE_STORAGE = 0x1; + public static final int CASE_SMS = 0x2; + public static final int CASE_LOCATION = 0x3; + public static final int CASE_BATTERY = 0x4; + + public static void askForPermission(Activity activity, String[] permission, Integer requestCode) { + boolean test = false; + for (int i = 0; i < permission.length; i++) { + test = test || (ContextCompat.checkSelfPermission(activity, permission[i]) != PackageManager.PERMISSION_GRANTED); + } + if (test) { + ActivityCompat.requestPermissions(activity, permission, requestCode); + } + } + + public static void askForPermission(Activity activity, String permission, Integer requestCode) { + String[] permissions = {permission}; + + if (ContextCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) + ActivityCompat.requestPermissions(activity, permissions, requestCode); + } + + public static boolean checkForPermission(Context context, String permission) { + return ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED; + } + + public static synchronized void askForSMSPermissions(Activity activity) { + if (askForSMS) { //only when settings were changed an MainActivity resumes. + askForSMS = false; + if (SP.getBoolean(R.string.smscommunicator_remotecommandsallowed, false)) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { + AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.RECEIVE_SMS, + Manifest.permission.SEND_SMS, + Manifest.permission.RECEIVE_MMS}, AndroidPermission.CASE_SMS); + } + } + } + } + + public static synchronized void askForBatteryOptimizationPermission(Activity activity) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS}, AndroidPermission.CASE_BATTERY); + } + } + + public static synchronized void askForLocationPermissions(Activity activity) { + if (askForLocation) { //only when settings were changed an MainActivity resumes. + askForLocation = false; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.ACCESS_FINE_LOCATION}, AndroidPermission.CASE_LOCATION); + } + } + } + + public static synchronized void setAskForSMS() { + askForSMS = true; + } + +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index beb1efd994..27695b1d6a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1080,4 +1080,8 @@ Please select source of profile. If patient is a child you should use NS profile. If there is nobody following you on Nightscout you will probably prefer Local profile. Please remember that you are only selecting the profile source. To use it you must activate it by executing \"Profile switch\" Select one from availables algorithms. They are sorted from oldest to newest. Newer algorithm is usualy more powerfull and more aggresive. Thus if you are new looper you may probably start with AMA and not with latest one. Do not forget to read the OpenAPS documentation and configure it before use. Start your first objective + Permission + Ask for permission + Application needs location permission for BT scan + Application needs storage permission to be able store log files From 250f9f74a074067a883a6449bf2636d7bbcc87dc Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 22 May 2018 18:59:34 +0200 Subject: [PATCH 14/25] move askForStoragePermission --- .../info/nightscout/androidaps/MainActivity.java | 14 +++++--------- .../info/nightscout/utils/AndroidPermission.java | 7 +++++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 84f297c0ae..c3231814db 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -1,6 +1,5 @@ package info.nightscout.androidaps; -import android.Manifest; import android.app.Activity; import android.content.Context; import android.content.DialogInterface; @@ -72,19 +71,16 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe menuButton = (ImageButton) findViewById(R.id.overview_menuButton); menuButton.setOnClickListener(this); - checkEula(); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - AndroidPermission.askForPermission(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE}, AndroidPermission.CASE_STORAGE); - } - AndroidPermission.askForBatteryOptimizationPermission(this); - doMigrations(); - if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) { Intent intent = new Intent(this, SetupWizardActivity.class); startActivity(intent); } + checkEula(); + AndroidPermission.askForStoragePermission(this); + AndroidPermission.askForBatteryOptimizationPermission(this); + doMigrations(); + if (Config.logFunctionCalls) log.debug("onCreate"); diff --git a/app/src/main/java/info/nightscout/utils/AndroidPermission.java b/app/src/main/java/info/nightscout/utils/AndroidPermission.java index c0ce505e9b..45db300cef 100644 --- a/app/src/main/java/info/nightscout/utils/AndroidPermission.java +++ b/app/src/main/java/info/nightscout/utils/AndroidPermission.java @@ -60,6 +60,13 @@ public class AndroidPermission { } } + public static synchronized void askForStoragePermission(Activity activity) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { + AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE}, AndroidPermission.CASE_STORAGE); + } + } + public static synchronized void askForLocationPermissions(Activity activity) { if (askForLocation) { //only when settings were changed an MainActivity resumes. askForLocation = false; From 5d27a28dc90546cf8c6695a3044d8794aac928a1 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 22 May 2018 20:02:38 +0200 Subject: [PATCH 15/25] SW eula --- .../nightscout/androidaps/MainActivity.java | 19 +++++++------ .../androidaps/setupwizard/SWDefinition.java | 27 ++++++++++++++++--- .../setupwizard/SetupWizardActivity.java | 3 +++ 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index c3231814db..555eef8267 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -65,6 +65,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + if (Config.logFunctionCalls) + log.debug("onCreate"); + Iconify.with(new FontAwesomeModule()); LocaleHelper.onCreate(this, "en"); setContentView(R.layout.activity_main); @@ -74,16 +78,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) { Intent intent = new Intent(this, SetupWizardActivity.class); startActivity(intent); + finish(); } - checkEula(); - AndroidPermission.askForStoragePermission(this); - AndroidPermission.askForBatteryOptimizationPermission(this); - doMigrations(); - - if (Config.logFunctionCalls) - log.debug("onCreate"); - onStatusEvent(new EventSetWakeLock(SP.getBoolean("lockscreen", false))); registerBus(); @@ -214,6 +211,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe @Override protected void onResume() { super.onResume(); + + checkEula(); + AndroidPermission.askForStoragePermission(this); + AndroidPermission.askForBatteryOptimizationPermission(this); + doMigrations(); + AndroidPermission.askForSMSPermissions(this); AndroidPermission.askForLocationPermissions(this); MainApp.bus().post(new EventFeatureRunning(EventFeatureRunning.Feature.MAIN)); diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java index fbff517c32..54be2153f1 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java @@ -111,35 +111,56 @@ public class SWDefinition { return SP.contains(R.string.key_language); }) ) + .add(new SWScreen(R.string.end_user_license_agreement) + .skippable(false) + .add(new SWInfotext() + .label(R.string.end_user_license_agreement_text)) + .add(new SWBreak()) + .add(new SWButton() + .text(R.string.end_user_license_agreement_i_understand) + .visibility(() -> !SP.getBoolean(R.string.key_i_understand, false)) + .action(() -> { + SP.putBoolean(R.string.key_i_understand, true); + MainApp.bus().post(new EventSWUpdate(false)); + })) + .visibility(() -> !SP.getBoolean(R.string.key_i_understand, false)) + .validator(() -> SP.getBoolean(R.string.key_i_understand, false)) + ) .add(new SWScreen(R.string.permission) - .skippable(true) + .skippable(false) .add(new SWInfotext() .label(String.format(MainApp.gs(R.string.needwhitelisting), MainApp.gs(R.string.app_name)))) .add(new SWBreak()) .add(new SWButton() .text(R.string.askforpermission) + .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)) .action(() -> AndroidPermission.askForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, AndroidPermission.CASE_BATTERY))) .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)) + .validator(() -> !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS))) ) .add(new SWScreen(R.string.permission) - .skippable(true) + .skippable(false) .add(new SWInfotext() .label(MainApp.gs(R.string.needlocationpermission))) .add(new SWBreak()) .add(new SWButton() .text(R.string.askforpermission) + .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)) .action(() -> AndroidPermission.askForPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION, AndroidPermission.CASE_LOCATION))) .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)) + .validator(() -> !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION))) ) .add(new SWScreen(R.string.permission) - .skippable(true) + .skippable(false) .add(new SWInfotext() .label(MainApp.gs(R.string.needstoragepermission))) .add(new SWBreak()) .add(new SWButton() .text(R.string.askforpermission) + .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) .action(() -> AndroidPermission.askForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE, AndroidPermission.CASE_STORAGE))) .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) + .validator(() -> !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE))) ) .add(new SWScreen(R.string.nsclientinternal_title) .skippable(true) diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java index fde19eafaa..3212a8c10f 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java @@ -70,6 +70,7 @@ public class SetupWizardActivity extends AppCompatActivity { } public void exitPressed(View view) { + SP.putBoolean(R.string.key_setupwizard_processed, true); OKDialog.showConfirmation(this, MainApp.gs(R.string.exitwizard), this::finish); } @@ -170,6 +171,7 @@ public class SetupWizardActivity extends AppCompatActivity { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); + finish(); } private int nextPage() { @@ -212,6 +214,7 @@ public class SetupWizardActivity extends AppCompatActivity { } } } + updateButtons(); } } From 53bdb0bf09579276d8032f04879ce7e106666a14 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 22 May 2018 23:06:17 +0200 Subject: [PATCH 16/25] asking permissions to notifications --- .../nightscout/androidaps/MainActivity.java | 71 ++++++++----------- .../plugins/Overview/OverviewFragment.java | 9 ++- .../Overview/notifications/Notification.java | 4 ++ .../NotificationRecyclerViewAdapter.java | 10 ++- .../notifications/NotificationStore.java | 2 +- .../notifications/NotificationWithAction.java | 16 +++++ .../nightscout/utils/AndroidPermission.java | 69 ++++++++++-------- app/src/main/res/values/strings.xml | 1 + 8 files changed, 104 insertions(+), 78 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationWithAction.java diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 555eef8267..9d869cdde6 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -75,18 +75,41 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe menuButton = (ImageButton) findViewById(R.id.overview_menuButton); menuButton.setOnClickListener(this); - if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) { - Intent intent = new Intent(this, SetupWizardActivity.class); - startActivity(intent); - finish(); - } - onStatusEvent(new EventSetWakeLock(SP.getBoolean("lockscreen", false))); + doMigrations(); + registerBus(); setUpTabs(false); } + @Override + protected void onResume() { + super.onResume(); + + if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) { + Intent intent = new Intent(this, SetupWizardActivity.class); + startActivity(intent); + } else { + checkEula(); + } + + AndroidPermission.notifyForStoragePermission(this); + AndroidPermission.notifyForBatteryOptimizationPermission(this); + AndroidPermission.notifyForLocationPermissions(this); + AndroidPermission.notifyForSMSPermissions(this); + + MainApp.bus().post(new EventFeatureRunning(EventFeatureRunning.Feature.MAIN)); + } + + @Override + public void onDestroy() { + if (mWakeLock != null) + if (mWakeLock.isHeld()) + mWakeLock.release(); + super.onDestroy(); + } + @Subscribe public void onStatusEvent(final EventSetWakeLock ev) { final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); @@ -194,42 +217,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe } } - //check for sms permission if enable in prefernces - @Subscribe - public void onStatusEvent(final EventPreferenceChange ev) { - if (ev.isChanged(R.string.key_smscommunicator_remotecommandsallowed)) { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - synchronized (this) { - if (SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)) { - AndroidPermission.setAskForSMS(); - } - } - } - } - } - - @Override - protected void onResume() { - super.onResume(); - - checkEula(); - AndroidPermission.askForStoragePermission(this); - AndroidPermission.askForBatteryOptimizationPermission(this); - doMigrations(); - - AndroidPermission.askForSMSPermissions(this); - AndroidPermission.askForLocationPermissions(this); - MainApp.bus().post(new EventFeatureRunning(EventFeatureRunning.Feature.MAIN)); - } - - @Override - public void onDestroy() { - if (mWakeLock != null) - if (mWakeLock.isHeld()) - mWakeLock.release(); - super.onDestroy(); - } - @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); 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 7d7c0e7efb..31aa098579 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 @@ -981,16 +981,19 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, if (timeView != null) { //must not exists timeView.setText(DateUtil.timeString(new Date())); } + + updateNotifications(); + + pumpStatusLayout.setVisibility(View.GONE); + loopStatusLayout.setVisibility(View.GONE); + if (!MainApp.getConfigBuilder().isProfileValid("Overview")) { pumpStatusView.setText(R.string.noprofileset); pumpStatusLayout.setVisibility(View.VISIBLE); - loopStatusLayout.setVisibility(View.GONE); return; } - pumpStatusLayout.setVisibility(View.GONE); loopStatusLayout.setVisibility(View.VISIBLE); - updateNotifications(); CareportalFragment.updateAge(getActivity(), sage, iage, cage, pbage); BgReading actualBG = DatabaseHelper.actualBg(); BgReading lastBG = DatabaseHelper.lastBg(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java index d4fc034d10..9a374bf3f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java @@ -60,6 +60,10 @@ public class Notification { public static final int PROFILE_SWITCH_MISSING = 32; public static final int NOT_ENG_MODE_OR_RELEASE = 33; public static final int WRONG_PUMP_PASSWORD = 34; + public static final int PERMISSION_STORAGE = 35; + public static final int PERMISSION_LOCATION = 36; + public static final int PERMISSION_BATTERY = 37; + public static final int PERMISSION_SMS = 38; public int id; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java index 5024c2699a..895b99a43e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationRecyclerViewAdapter.java @@ -42,9 +42,12 @@ public class NotificationRecyclerViewAdapter extends RecyclerView.Adapter Build.VERSION_CODES.LOLLIPOP_MR1) { - AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.RECEIVE_SMS, + public static synchronized void notifyForSMSPermissions(Activity activity) { + if (SP.getBoolean(R.string.smscommunicator_remotecommandsallowed, false)) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { + if (!checkForPermission(activity, Manifest.permission.RECEIVE_SMS)) { + NotificationWithAction notification = new NotificationWithAction(Notification.PERMISSION_SMS, MainApp.gs(R.string.smscommunicator_missingsmspermission), Notification.URGENT); + notification.action(MainApp.gs(R.string.request), () -> AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.RECEIVE_SMS, Manifest.permission.SEND_SMS, - Manifest.permission.RECEIVE_MMS}, AndroidPermission.CASE_SMS); - } + Manifest.permission.RECEIVE_MMS}, AndroidPermission.CASE_SMS)); + MainApp.bus().post(new EventNewNotification(notification)); + } else + MainApp.bus().post(new EventDismissNotification(Notification.PERMISSION_SMS)); } } } - public static synchronized void askForBatteryOptimizationPermission(Activity activity) { + public static synchronized void notifyForBatteryOptimizationPermission(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS}, AndroidPermission.CASE_BATTERY); + if (!checkForPermission(activity, Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)) { + NotificationWithAction notification = new NotificationWithAction(Notification.PERMISSION_BATTERY, String.format(MainApp.gs(R.string.needwhitelisting), MainApp.gs(R.string.app_name)), Notification.URGENT); + notification.action(MainApp.gs(R.string.request), () -> AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS}, AndroidPermission.CASE_BATTERY)); + MainApp.bus().post(new EventNewNotification(notification)); + } else + MainApp.bus().post(new EventDismissNotification(Notification.PERMISSION_BATTERY)); } } - public static synchronized void askForStoragePermission(Activity activity) { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE}, AndroidPermission.CASE_STORAGE); + public static synchronized void notifyForStoragePermission(Activity activity) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (!checkForPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { + NotificationWithAction notification = new NotificationWithAction(Notification.PERMISSION_STORAGE, MainApp.gs(R.string.needstoragepermission), Notification.URGENT); + notification.action(MainApp.gs(R.string.request), () -> AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE}, AndroidPermission.CASE_STORAGE)); + MainApp.bus().post(new EventNewNotification(notification)); + } else + MainApp.bus().post(new EventDismissNotification(Notification.PERMISSION_STORAGE)); } } - public static synchronized void askForLocationPermissions(Activity activity) { - if (askForLocation) { //only when settings were changed an MainActivity resumes. - askForLocation = false; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION}, AndroidPermission.CASE_LOCATION); - } + public static synchronized void notifyForLocationPermissions(Activity activity) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (!checkForPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION)) { + NotificationWithAction notification = new NotificationWithAction(Notification.PERMISSION_LOCATION, MainApp.gs(R.string.needlocationpermission), Notification.URGENT); + notification.action(MainApp.gs(R.string.request), () -> AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, AndroidPermission.CASE_LOCATION)); + MainApp.bus().post(new EventNewNotification(notification)); + } else + MainApp.bus().post(new EventDismissNotification(Notification.PERMISSION_LOCATION)); } } - - public static synchronized void setAskForSMS() { - askForSMS = true; - } - } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 27695b1d6a..ebcbfe5b61 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1084,4 +1084,5 @@ Ask for permission Application needs location permission for BT scan Application needs storage permission to be able store log files + Request From a7cfcd56e39a6877106c563912c35800b51a6f9a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 23 May 2018 13:20:24 +0200 Subject: [PATCH 17/25] SW fix return to 1st page --- .../nightscout/androidaps/setupwizard/SetupWizardActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java index 3212a8c10f..eff723ae41 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java @@ -186,7 +186,7 @@ public class SetupWizardActivity extends AppCompatActivity { private int previousPage() { int page = currentWizardPage - 1; - while (page > 0) { + while (page >= 0) { if (screens.get(page).visibility == null || screens.get(page).visibility.isValid()) return page; page--; From 683caf78f882e81d6bc8d36f0223280ae645b5af Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 23 May 2018 13:47:16 +0200 Subject: [PATCH 18/25] SW configure insulin button --- .../androidaps/setupwizard/SWDefinition.java | 18 +++++++++++++++--- app/src/main/res/values/strings.xml | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java index 54be2153f1..dbdb22782a 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java @@ -217,11 +217,11 @@ public class SWDefinition { .add(new SWScreen(R.string.configbuilder_insulin) .skippable(false) .add(new SWInfotext() - .label(MainApp.gs(R.string.fastactinginsulincomment) + " = " + MainApp.gs(R.string.rapid_acting_oref))) + .label(MainApp.gs(R.string.rapid_acting_oref) + ": " + MainApp.gs(R.string.fastactinginsulincomment))) .add(new SWInfotext() - .label(MainApp.gs(R.string.ultrafastactinginsulincomment) + " = " + MainApp.gs(R.string.ultrarapid_oref))) + .label(MainApp.gs(R.string.ultrarapid_oref) + ": " + MainApp.gs(R.string.ultrafastactinginsulincomment))) .add(new SWInfotext() - .label(MainApp.gs(R.string.free_peak_oref_description) + " = " + MainApp.gs(R.string.free_peak_oref))) + .label(MainApp.gs(R.string.free_peak_oref) + ": " + MainApp.gs(R.string.free_peak_oref_description))) .add(new SWBreak()) .add(new SWInfotext() .label(R.string.diawarning)) @@ -229,6 +229,18 @@ public class SWDefinition { .add(new SWPlugin() .option(PluginType.INSULIN) .label(R.string.configbuilder_insulin)) + .add(new SWBreak()) + .add(new SWButton() + .text(R.string.insulinsourcesetup) + .action(() -> { + final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActiveInsulin(); + PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> { + Intent i = new Intent(activity, PreferencesActivity.class); + i.putExtra("id", plugin.getPreferencesId()); + activity.startActivity(i); + }, null); + }) + .visibility(() -> MainApp.getConfigBuilder().getActiveInsulin()!= null && ((PluginBase) MainApp.getConfigBuilder().getActiveInsulin()).getPreferencesId() > 0)) .validator(() -> MainApp.getConfigBuilder().getActiveInsulin() != null) ) .add(new SWScreen(R.string.configbuilder_bgsource) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c6718f9c0e..b7b5930978 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1086,4 +1086,5 @@ Application needs location permission for BT scan Application needs storage permission to be able store log files Request + Configure Insulin plugin From d642418e0215a652390198763c7a3378977e02e2 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 23 May 2018 23:43:41 +0200 Subject: [PATCH 19/25] resolve NPE --- .../plugins/IobCobCalculator/IobCobCalculatorPlugin.java | 3 +-- .../androidaps/plugins/Overview/graphData/GraphData.java | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) 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 89d66fd891..2e8e16a226 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 @@ -347,13 +347,12 @@ public class IobCobCalculatorPlugin extends PluginBase { return null; } - public BasalData getBasalData(long time) { + public BasalData getBasalData(Profile profile, long time) { long now = System.currentTimeMillis(); time = roundUpTime(time); BasalData retval = basalDataTable.get(time); if (retval == null) { retval = new BasalData(); - Profile profile = MainApp.getConfigBuilder().getProfile(time); TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(time); retval.basal = profile.getBasal(time); if (tb != null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java index 1c8b27c113..30e2ad97e4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java @@ -136,7 +136,9 @@ public class GraphData { double lastBaseBasal = 0; double lastTempBasal = 0; for (long time = fromTime; time < toTime; time += 60 * 1000L) { - BasalData basalData = IobCobCalculatorPlugin.getPlugin().getBasalData(time); + Profile profile = MainApp.getConfigBuilder().getProfile(time); + if (profile == null) continue; + BasalData basalData = IobCobCalculatorPlugin.getPlugin().getBasalData(profile, time); double baseBasalValue = basalData.basal; double absoluteLineValue = baseBasalValue; double tempBasalValue = 0; From 35c07d1e602b4494f0db5183116300de5f5f80e4 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 24 May 2018 00:13:59 +0200 Subject: [PATCH 20/25] SW scroll to the top on activity create --- .../androidaps/setupwizard/SetupWizardActivity.java | 6 ++++++ app/src/main/res/layout/activity_setupwizard.xml | 1 + 2 files changed, 7 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java index eff723ae41..523970d6df 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java @@ -8,6 +8,7 @@ import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.LinearLayout; +import android.widget.ScrollView; import android.widget.TextView; import com.squareup.otto.Subscribe; @@ -36,6 +37,8 @@ public class SetupWizardActivity extends AppCompatActivity { //logging private static Logger log = LoggerFactory.getLogger(SetupWizardActivity.class); + ScrollView scrollView; + private SWDefinition swDefinition = new SWDefinition(); private List screens = swDefinition.getScreens(); private int currentWizardPage = 0; @@ -47,6 +50,8 @@ public class SetupWizardActivity extends AppCompatActivity { LocaleHelper.onCreate(this, "en"); setContentView(R.layout.activity_setupwizard); + scrollView = (ScrollView) findViewById(R.id.sw_scrollview); + Intent intent = getIntent(); currentWizardPage = intent.getIntExtra(SetupWizardActivity.INTENT_MESSAGE, 0); if (screens.size() > 0 && currentWizardPage < screens.size()) { @@ -126,6 +131,7 @@ public class SetupWizardActivity extends AppCompatActivity { SWItem currentItem = currentScreen.items.get(i); currentItem.generateDialog(this.findViewById(R.id.sw_content_fields), layout); } + scrollView.smoothScrollTo(0,0); } private void updateButtons() { diff --git a/app/src/main/res/layout/activity_setupwizard.xml b/app/src/main/res/layout/activity_setupwizard.xml index e47762631c..0e97ca2495 100644 --- a/app/src/main/res/layout/activity_setupwizard.xml +++ b/app/src/main/res/layout/activity_setupwizard.xml @@ -27,6 +27,7 @@ tools:text="Title" /> From 7e57c30ecfec238c0df50a6ef575a66844aba663 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 25 May 2018 13:00:08 +0200 Subject: [PATCH 21/25] SW Exit label --- .../main/res/layout/activity_setupwizard.xml | 31 ++++++++++++++----- app/src/main/res/values/strings.xml | 1 + 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/layout/activity_setupwizard.xml b/app/src/main/res/layout/activity_setupwizard.xml index 0e97ca2495..79dd6ed6f7 100644 --- a/app/src/main/res/layout/activity_setupwizard.xml +++ b/app/src/main/res/layout/activity_setupwizard.xml @@ -7,14 +7,32 @@ android:orientation="vertical" tools:context=".setupwizard.SetupWizardActivity"> - + android:orientation="horizontal"> + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b7b5930978..a10fdef639 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1087,4 +1087,5 @@ Application needs storage permission to be able store log files Request Configure Insulin plugin + Exit From de1196f34beb13e053acedd588dd81857ca6bf6b Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 29 May 2018 12:57:07 +0200 Subject: [PATCH 22/25] NSClient as source without advanced filtering --- .../androidaps/plugins/Source/SourceNSClientPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java index 3ba85e97a6..3bf5c66cca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceNSClientPlugin.java @@ -32,6 +32,6 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac @Override public boolean advancedFilteringSupported() { - return true; + return false; } } From 41503800e8d0a42ff0122b68c11b7c0cccb5b651 Mon Sep 17 00:00:00 2001 From: "Markus M. May" Date: Tue, 29 May 2018 20:57:55 +0200 Subject: [PATCH 23/25] Remove some duplicate code lines --- .../androidaps/Services/DataService.java | 34 ++++++----- .../Careportal/CareportalFragment.java | 61 +++++++------------ .../broadcasts/BroadcastStatus.java | 29 ++++----- .../java/info/nightscout/utils/NSUpload.java | 46 ++++++-------- 4 files changed, 72 insertions(+), 98 deletions(-) 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 881f2e3bac..f8437d8d36 100644 --- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java @@ -427,9 +427,7 @@ public class DataService extends IntentService { if (bundles.containsKey("sgv")) { String sgvstring = bundles.getString("sgv"); JSONObject sgvJson = new JSONObject(sgvstring); - NSSgv nsSgv = new NSSgv(sgvJson); - BgReading bgReading = new BgReading(nsSgv); - MainApp.getDbHelper().createIfNotExists(bgReading, "NS"); + storeSgv(sgvJson); } if (bundles.containsKey("sgvs")) { @@ -437,9 +435,7 @@ public class DataService extends IntentService { JSONArray jsonArray = new JSONArray(sgvstring); for (int i = 0; i < jsonArray.length(); i++) { JSONObject sgvJson = jsonArray.getJSONObject(i); - NSSgv nsSgv = new NSSgv(sgvJson); - BgReading bgReading = new BgReading(nsSgv); - MainApp.getDbHelper().createIfNotExists(bgReading, "NS"); + storeSgv(sgvJson); } } } catch (Exception e) { @@ -452,11 +448,7 @@ public class DataService extends IntentService { if (bundles.containsKey("mbg")) { String mbgstring = bundles.getString("mbg"); JSONObject mbgJson = new JSONObject(mbgstring); - NSMbg nsMbg = new NSMbg(mbgJson); - CareportalEvent careportalEvent = new CareportalEvent(nsMbg); - MainApp.getDbHelper().createOrUpdate(careportalEvent); - if (Config.logIncommingData) - log.debug("Adding/Updating new MBG: " + careportalEvent.log()); + storeMbg(mbgJson); } if (bundles.containsKey("mbgs")) { @@ -464,11 +456,7 @@ public class DataService extends IntentService { JSONArray jsonArray = new JSONArray(sgvstring); for (int i = 0; i < jsonArray.length(); i++) { JSONObject mbgJson = jsonArray.getJSONObject(i); - NSMbg nsMbg = new NSMbg(mbgJson); - CareportalEvent careportalEvent = new CareportalEvent(nsMbg); - MainApp.getDbHelper().createOrUpdate(careportalEvent); - if (Config.logIncommingData) - log.debug("Adding/Updating new MBG: " + careportalEvent.log()); + storeMbg(mbgJson); } } } catch (Exception e) { @@ -549,6 +537,20 @@ public class DataService extends IntentService { } } + private void storeMbg(JSONObject mbgJson) { + NSMbg nsMbg = new NSMbg(mbgJson); + CareportalEvent careportalEvent = new CareportalEvent(nsMbg); + MainApp.getDbHelper().createOrUpdate(careportalEvent); + if (Config.logIncommingData) + log.debug("Adding/Updating new MBG: " + careportalEvent.log()); + } + + private void storeSgv(JSONObject sgvJson) { + NSSgv nsSgv = new NSSgv(sgvJson); + BgReading bgReading = new BgReading(nsSgv); + MainApp.getDbHelper().createIfNotExists(bgReading, "NS"); + } + private void handleNewSMS(Intent intent) { Bundle bundle = intent.getExtras(); if (bundle == null) return; 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 4a4210f29e..1542239b56 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 @@ -218,50 +218,19 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli double iageUrgent = nsSettings.getExtendedWarnValue("iage", "urgent", 96); double iageWarn = nsSettings.getExtendedWarnValue("iage", "warn", 72); + handleAge(iage, CareportalEvent.INSULINCHANGE, iageWarn, iageUrgent); + double cageUrgent = nsSettings.getExtendedWarnValue("cage", "urgent", 72); double cageWarn = nsSettings.getExtendedWarnValue("cage", "warn", 48); + handleAge(sage, CareportalEvent.SITECHANGE, cageWarn, cageUrgent); + double sageUrgent = nsSettings.getExtendedWarnValue("sage", "urgent", 166); double sageWarn = nsSettings.getExtendedWarnValue("sage", "warn", 164); + handleAge(sage, CareportalEvent.SITECHANGE, sageWarn, sageUrgent); + double pbageUrgent = nsSettings.getExtendedWarnValue("pgage", "urgent", 360); double pbageWarn = nsSettings.getExtendedWarnValue("pgage", "warn", 240); - - String notavailable = OverviewFragment.shorttextmode ? "-" : MainApp.gs(R.string.notavailable); - if (sage != null) { - careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE); - if (careportalEvent != null) { - sage.setTextColor(CareportalFragment.determineTextColor(careportalEvent, sageWarn, sageUrgent)); - sage.setText(careportalEvent.age()); - } else { - sage.setText(notavailable); - } - } - if (iage != null) { - careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE); - if (careportalEvent != null) { - iage.setTextColor(CareportalFragment.determineTextColor(careportalEvent, iageWarn, iageUrgent)); - iage.setText(careportalEvent.age()); - } else { - iage.setText(notavailable); - } - } - if (cage != null) { - careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE); - if (careportalEvent != null) { - cage.setTextColor(CareportalFragment.determineTextColor(careportalEvent, cageWarn, cageUrgent)); - cage.setText(careportalEvent.age()); - } else { - cage.setText(notavailable); - } - } - if (pbage != null) { - careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.PUMPBATTERYCHANGE); - if (careportalEvent != null) { - pbage.setTextColor(CareportalFragment.determineTextColor(careportalEvent, pbageWarn, pbageUrgent)); - pbage.setText(careportalEvent.age()); - } else { - pbage.setText(notavailable); - } - } + handleAge(pbage, CareportalEvent.PUMPBATTERYCHANGE, pbageWarn, pbageUrgent); } ); } @@ -277,5 +246,21 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli } } + + private static TextView handleAge(final TextView age, String eventType, double warnThreshold, double urgentThreshold) { + String notavailable = OverviewFragment.shorttextmode ? "-" : MainApp.gs(R.string.notavailable); + + if (age != null) { + CareportalEvent careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(eventType); + if (careportalEvent != null) { + age.setTextColor(CareportalFragment.determineTextColor(careportalEvent, warnThreshold, urgentThreshold)); + age.setText(careportalEvent.age()); + } else { + age.setText(notavailable); + } + } + + return age; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java index 4ee2427af8..f9964c0704 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java @@ -26,14 +26,24 @@ public class BroadcastStatus { private static Logger log = LoggerFactory.getLogger(BroadcastStatus.class); public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) { + Intent intent = createIntent(status, isDelta); + LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent); + if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) { + context.sendBroadcast(createIntent(status, isDelta)); + } + } + + private static Intent createIntent(NSSettingsStatus status, boolean isDelta) { Bundle bundle = new Bundle(); + try { bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName); bundle.putInt("nsclientversioncode", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode); } catch (PackageManager.NameNotFoundException e) { log.error("Unhandled exception", e); } + bundle.putString("nightscoutversionname", NSClientService.nightscoutVersionName); bundle.putInt("nightscoutversioncode", NSClientService.nightscoutVersionCode); bundle.putString("status", status.getData().toString()); @@ -41,24 +51,7 @@ public class BroadcastStatus { Intent intent = new Intent(Intents.ACTION_NEW_STATUS); intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent); - if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) { - bundle = new Bundle(); - try { - bundle.putString("nsclientversionname", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionName); - bundle.putInt("nsclientversioncode", MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), 0).versionCode); - } catch (PackageManager.NameNotFoundException e) { - log.error("Unhandled exception", e); - } - bundle.putString("nightscoutversionname", NSClientService.nightscoutVersionName); - bundle.putInt("nightscoutversioncode", NSClientService.nightscoutVersionCode); - bundle.putString("status", status.getData().toString()); - bundle.putBoolean("delta", isDelta); - intent = new Intent(Intents.ACTION_NEW_STATUS); - intent.putExtras(bundle); - intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); - context.sendBroadcast(intent); - } + return intent; } } diff --git a/app/src/main/java/info/nightscout/utils/NSUpload.java b/app/src/main/java/info/nightscout/utils/NSUpload.java index 2e5506f9c6..00d5e39821 100644 --- a/app/src/main/java/info/nightscout/utils/NSUpload.java +++ b/app/src/main/java/info/nightscout/utils/NSUpload.java @@ -289,19 +289,7 @@ public class NSUpload { public static void uploadProfileSwitch(ProfileSwitch profileSwitch) { try { - JSONObject data = new JSONObject(); - data.put("eventType", CareportalEvent.PROFILESWITCH); - data.put("duration", profileSwitch.durationInMinutes); - data.put("profile", profileSwitch.getCustomizedName()); - data.put("profileJson", profileSwitch.profileJson); - data.put("profilePlugin", profileSwitch.profilePlugin); - if (profileSwitch.isCPP) { - data.put("CircadianPercentageProfile", true); - data.put("timeshift", profileSwitch.timeshift); - data.put("percentage", profileSwitch.percentage); - } - data.put("created_at", DateUtil.toISOString(profileSwitch.date)); - data.put("enteredBy", MainApp.gs(R.string.app_name)); + JSONObject data = getJson(profileSwitch); uploadCareportalEntryToNS(data); } catch (JSONException e) { log.error("Unhandled exception", e); @@ -334,19 +322,7 @@ public class NSUpload { public static void updateProfileSwitch(ProfileSwitch profileSwitch) { try { - JSONObject data = new JSONObject(); - data.put("eventType", CareportalEvent.PROFILESWITCH); - data.put("duration", profileSwitch.durationInMinutes); - data.put("profile", profileSwitch.getCustomizedName()); - data.put("profileJson", profileSwitch.profileJson); - data.put("profilePlugin", profileSwitch.profilePlugin); - if (profileSwitch.isCPP) { - data.put("CircadianPercentageProfile", true); - data.put("timeshift", profileSwitch.timeshift); - data.put("percentage", profileSwitch.percentage); - } - data.put("created_at", DateUtil.toISOString(profileSwitch.date)); - data.put("enteredBy", MainApp.gs(R.string.app_name)); + JSONObject data = getJson(profileSwitch); if (profileSwitch._id != null) { Context context = MainApp.instance().getApplicationContext(); Bundle bundle = new Bundle(); @@ -365,6 +341,24 @@ public class NSUpload { } } + private static JSONObject getJson(ProfileSwitch profileSwitch) throws JSONException { + JSONObject data = new JSONObject(); + data.put("eventType", CareportalEvent.PROFILESWITCH); + data.put("duration", profileSwitch.durationInMinutes); + data.put("profile", profileSwitch.getCustomizedName()); + data.put("profileJson", profileSwitch.profileJson); + data.put("profilePlugin", profileSwitch.profilePlugin); + if (profileSwitch.isCPP) { + data.put("CircadianPercentageProfile", true); + data.put("timeshift", profileSwitch.timeshift); + data.put("percentage", profileSwitch.percentage); + } + data.put("created_at", DateUtil.toISOString(profileSwitch.date)); + data.put("enteredBy", MainApp.gs(R.string.app_name)); + + return data; + } + public static void uploadCareportalEntryToNS(JSONObject data) { try { if (data.has("preBolus") && data.has("carbs")) { From 0fe744c3e6ff86d68a026dabb1d4ea1859cda40a Mon Sep 17 00:00:00 2001 From: "Markus M. May" Date: Tue, 29 May 2018 21:44:33 +0200 Subject: [PATCH 24/25] Remove unnecessary assignment --- .../plugins/NSClientInternal/broadcasts/BroadcastStatus.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java index f9964c0704..a2b6e64aec 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastStatus.java @@ -26,8 +26,8 @@ public class BroadcastStatus { private static Logger log = LoggerFactory.getLogger(BroadcastStatus.class); public static void handleNewStatus(NSSettingsStatus status, Context context, boolean isDelta) { - Intent intent = createIntent(status, isDelta); - LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent); + LocalBroadcastManager.getInstance(MainApp.instance()) + .sendBroadcast(createIntent(status, isDelta)); if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) { context.sendBroadcast(createIntent(status, isDelta)); From a587f72de20db8df10c77125377961f76291922b Mon Sep 17 00:00:00 2001 From: "Markus M. May" Date: Wed, 30 May 2018 18:09:41 +0200 Subject: [PATCH 25/25] Fix wrong usage of event in refactored source --- .../androidaps/plugins/Careportal/CareportalFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1542239b56..c5f1886265 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 @@ -226,7 +226,7 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli double sageUrgent = nsSettings.getExtendedWarnValue("sage", "urgent", 166); double sageWarn = nsSettings.getExtendedWarnValue("sage", "warn", 164); - handleAge(sage, CareportalEvent.SITECHANGE, sageWarn, sageUrgent); + handleAge(sage, CareportalEvent.SENSORCHANGE, sageWarn, sageUrgent); double pbageUrgent = nsSettings.getExtendedWarnValue("pgage", "urgent", 360); double pbageWarn = nsSettings.getExtendedWarnValue("pgage", "warn", 240);