From c80f1b4851f2af071edcfe2150a8ad0d70833e80 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 17 Oct 2019 19:46:45 +0200 Subject: [PATCH 01/14] New Crowdin translations (#2117) * New translations objectives.xml (Dutch) * New translations exam.xml (Dutch) * New translations objectives.xml (Dutch) * New translations exam.xml (Dutch) * New translations strings.xml (Dutch) * New translations exam.xml (Dutch) * New translations objectives.xml (Dutch) * New translations exam.xml (Polish) * New translations objectives.xml (Polish) * New translations exam.xml (Polish) * New translations exam.xml (Portuguese) * New translations strings.xml (Swedish) * New translations strings.xml (French) * New translations strings.xml (French) * New translations strings.xml (French) * New translations exam.xml (Spanish) * New translations objectives.xml (Spanish) * New translations exam.xml (Spanish) * New translations strings.xml (Spanish) --- app/src/main/res/values-es-rES/exam.xml | 44 ++++++++++ app/src/main/res/values-es-rES/objectives.xml | 8 ++ app/src/main/res/values-es-rES/strings.xml | 7 ++ app/src/main/res/values-fr-rFR/strings.xml | 2 +- app/src/main/res/values-nl-rNL/exam.xml | 33 ++++++++ app/src/main/res/values-nl-rNL/objectives.xml | 14 ++++ app/src/main/res/values-nl-rNL/strings.xml | 24 ++++++ app/src/main/res/values-pl-rPL/exam.xml | 82 +++++++++++++++++++ app/src/main/res/values-pl-rPL/objectives.xml | 30 +++++++ app/src/main/res/values-pt-rPT/exam.xml | 8 ++ app/src/main/res/values-sv-rSE/strings.xml | 2 +- 11 files changed, 252 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-es-rES/exam.xml b/app/src/main/res/values-es-rES/exam.xml index d6ab521b09..d0b8dce294 100644 --- a/app/src/main/res/values-es-rES/exam.xml +++ b/app/src/main/res/values-es-rES/exam.xml @@ -11,38 +11,58 @@ Tema: Hypo Temp-Objetivo ¿Cuál es la razón principal para establecer un hipo TT? Para evitar que BG caiga si ya hay basal temporal a cero corriendo. + Para evitar que AAPS inyecte demasiada insulina después de una subida causada por los carbohidratos de acción rápida utilizados para tratar una bajada en las lecturas de glucosa. https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html ¿Qué perfil puede ser usado y configurado estando desconectado? Tema: Perfil fuera de línea El perfil NS puede ser usado pero no configurado. https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html#profile Tema: Desconectando de la bomba + ¿Qué se debe hacer al desconectar la bomba? + Haga clic en \"Desconectar bomba\" para que AAPS sepa que no se está inyectando insulina. + Haga clic en \'Suspender lazo \' para que la AAPS deje de estar en lazo cerrado mientras la bomba está desconectada. + No cambies nada en AAPS, sólo desconecta la bomba. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#other-settings Tema: Ajustes AndroidAPS ¿Cuál es la mejor práctica para hacer copias de seguridad de tus ajustes? Exportarlos localmente desde el menú de Mantenimiento. Guardar archivo exportado a otro lugar como correo electrónico, Dropbox, Google drive… Exportarlos justo después de la instalación de AAPS. + Exportarlos después de realizar cambios en la configuración. + Exportarlos tras completar un objetivo. Exportarlos al terminar la configuración inicial. https://androidaps.readthedocs.io/en/latest/EN/Usage/ExportImportSettings.html https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#what-emergency-equipment-is-recommended-to-take-with-me Tema: Lecturas de CGM ruidosas + ¿Qué se debe hacer si los datos de CGM tienen ruido? + Nada, AAPS se ocupará de ello. + Desactivar el lazo cerrado para evitar una sobredosis. Sustituya el sensor de CGM. Apagar el movil. https://androidaps.readthedocs.io/en/latest/EN/Usage/Smoothing-Blood-Glucose-Data-in-xDrip.html#smoothing-blood-glucose-data + Verifique que la aplicación CGM suaviza los datos de glucosa. Tema: Ejercicio ¿Cómo puedes ayudar al sistema a lidiar con el ejercicio? + Utilización de la característica de objetivo temporal. Realice un cambio de perfil por debajo del 100%. Realice un cambio de perfil por encima del 100%. Detener el lazo. + Establezca un objetivo temporal de actividad antes de iniciar el ejercicio. + Establecer un objetivo temporal de actividad después de comenzar el ejercicio conduce a peores resultados que si se inicia antes de hacerlo. https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html#activity-temp-target + Tema: Lazo inhabilitado/suspendido + ¿Recibo insulina cuando el lazo está desactivado/suspendido? + Sí, la insulina basal sigue siendo entregada. No, la administración de la insulina está detenida. Tema: Basal, ISF, y IC Pruebas ¿Cuándo debo validar los valores basales, ISF y IC? Antes de empezar en uso de lazo. + Si se experimentan valores bajos de BG frecuentemente. + Si se experimentan valores altos de BG frecuentemente. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#androidaps-settings Tema: Requisitos previos ¿Qué necesito? + Información de perfil validada (Basal, IC, ISF, DIA). Un ordenador para crear un APK. Un teléfono compatible. Un Coche. @@ -50,12 +70,15 @@ Una cuenta de Tidepool. Una cuenta de Google. Una cuenta de Github. + Experiencia en desarrollo de Android. Una bomba MiniMed 670G. https://androidaps.readthedocs.io/en/latest/EN/Module/module.html Un Smartwatch. Un CGM soportado. + Tema: Actualización de AndroidAPS ¿Qué es verdad? Tienes que tener instalado Git. + Actualice tan pronto como se libere la nueva versión y prevea tener tiempo suficiente para hacerlo. Debes usar las mismas claves de firma. Nunca actualice si el sistema está funcionando bien. Pregúntale a tu amigo por el nuevo APK. @@ -63,19 +86,27 @@ Tema: Resolución de problemas Donde buscar ayuda? Únete al grupo AndroidAPS de Facebook. + Lea la documentación de AndroidAPS. Visite AndroidAPS Gitter Room. Visite el soporte de Google AndroidAPS Hable con su endocrinólogo. https://androidaps.readthedocs.io/en/latest/EN/Installing-AndroidAPS/Update-to-new-version.html#troubleshooting https://www.facebook.com/groups/AndroidAPSUsers/ https://gitter.im/MilosKozak/AndroidAPS + Tema: Plugins sobre Insulina + ¿Qué marca de insulina se puede utilizar con el plugin Ultra-Rapid-Oref? Fiasp® NovoRapid ® Humalog® Actrapid® https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html#insulin + Tema: Plugins de sensibilidad + ¿Qué algoritmo de sensibilidad tiene un rango de tiempo configurable? https://androidaps.readthedocs.io/en/latest/EN/Configuration/Sensitivity-detection-and-COB.html ¿Qué plugin de sensibilidad se debe utilizar para la funcionalidad UAM? + Tema: Errores en la entrada de carbohidratos + ¿Qué deberías hacer si has hecho una entrada incorrecta de carbohidratos? + En los Tratamientos, eliminar la entrada incorrecta de carbohidratos. Introducir los nuevos valores de carbohidratos. Cómo agregar una insulina falsa utilizando la función llenado de cánula Tema: Comida con Grasa y Proteína ¿Qué hacer si su comida contiene una gran cantidad de grasas y /o proteínas? @@ -83,6 +114,7 @@ Recalcular grasa y proteínas a los carbohidratos y añadirlo al cálculo del bolo. Utilice el bolus extendido para cubrir grasas y proteínas. https://androidaps.readthedocs.io/en/latest/EN/Usage/Extended-Carbs.html + Tema: Supervisión remota ¿Cómo puede supervisar la AAPS de su hijo de forma remota? Cómo utilizar un sitio de \"Nightscout\". App Dexcom seguidora si está usando la aplicación original Dexcom (sólo valores BG). @@ -92,10 +124,17 @@ App de Spike en el iPhone. https://androidaps.readthedocs.io/en/latest/EN/Children/Children.html Tema: Factor de sensibilidad de la insulina + Los valores más altos de ISF llevan a una menor cantidad de insulina cuando AAPS corrige los valores altos de glucemia. + Los valores más bajos de ISF llevan a una menor cantidad de insulina cuando AAPS corrige los valores altos de glucemia. + El cambio de los valores de ISF no afecta a la cantidad de insulina que se entrega cuando AAPS corrige para compensar los valores altos de glucemia. Tiene que especificar ISF en Preferencias. El cambio del valor de ISF en el perfil es suficiente para aplicar el cambio. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#insulin-sensitivity-factor-isf-mmol-l-u-or-mg-dl-u https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html + Tema: El ratio IC + Los ratios IC más altos conducen a menos insulina entregada por una cantidad determinada de carbohidratos. + Los ratios IC más bajos conducen a menos insulina entregada por una cantidad determinada de carbohidratos. + Si tiene 0 COB, cambiar la ratio IC conducirá a una cantidad distinta de insulina para corregir un valor de glucemia determinado. El IC será diferente si cuenta con una unidad de pan como 10g o 12g. IC significa: Cuántas unidades de pan están cubiertas por 1U de insulina. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#carbohydrate-to-insulin-ratio-cr-g-u @@ -112,7 +151,12 @@ El objetivo será 10% más bajo. Sólo el objetivo inferior será 10% inferior. https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html?highlight=profilewitch#profile-switch + Si se despierta 1h antes de lo habitual, ¿cómo debe notificar a AAPS el cambio en su horario? + Iniciar un cambio de perfil con un intervalo de tiempo de 1 + Iniciar un cambio de perfil con un intervalo de tiempo de -1 https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html?highlight=profile%20switch#timeshift + Iniciar un cambio de perfil con un intervalo de tiempo de 60 + Iniciar un cambio de perfil con un intervalo de tiempo de -60 https://androidaps.readthedocs.io/en/latest/EN/Module/module.html#good-individual-dosage-algorithm-for-your-diabetes-therapy Tema: Ayuda con tasas basales A donde ir para obtener ayuda con tasa basal y demás. diff --git a/app/src/main/res/values-es-rES/objectives.xml b/app/src/main/res/values-es-rES/objectives.xml index 88c8ef2f76..6252812668 100644 --- a/app/src/main/res/values-es-rES/objectives.xml +++ b/app/src/main/res/values-es-rES/objectives.xml @@ -53,8 +53,16 @@ Sin conexión a Internet Fallo tiempo de recuperación No se cumplen los requisitos de objetivo + + %1$d día + %1$d días + %1$d hora %1$d horas + + %1$d minuto + %1$d minutos + diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index b66b9b1916..d86012c422 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -7,7 +7,9 @@ Seguridad tratamientos + Máximo Bolo permitido [U] Máximos carbohidratos permitidos [g] + Preferencias Actualizar los tratamientos desde NS Restablecer las bases de datos ¿Realmente quiere restablecer las bases de datos? @@ -1364,4 +1366,9 @@ Cerrar Aumentar el valor basal máximo porque el ajuste es inferior a tu base máxima en el perfil El cuerpo del mensaje es inválido + %1$s ISF: %2$.1f + %1$.0fg IC: %2$.1f + %1$.1fg IC: %2$.1f + Asistente Bolus + min diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index 57cbe86793..8bbdbd88d4 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -59,7 +59,7 @@ Commander à distance AndroidAPS en utilisant les commandes SMS. Unités DAI - G:I (Ratio Glucides/Insuline, g/U) + G/I (g/U) SI Sensibilité Insuline Basal Cible diff --git a/app/src/main/res/values-nl-rNL/exam.xml b/app/src/main/res/values-nl-rNL/exam.xml index 44fb673ece..17975814fc 100644 --- a/app/src/main/res/values-nl-rNL/exam.xml +++ b/app/src/main/res/values-nl-rNL/exam.xml @@ -116,6 +116,7 @@ https://androidaps.readthedocs.io/en/latest/CROWDIN/nl/Usage/Extended-Carbs.html Onderwerp: volgen op afstand Hoe kun je AAPS van je kind op afstand volgen? + Met behulp van een Nightscout site. Dexcom volgapp als u de originele Dexcom app gebruikt (alleen BG). Dexcom Volg-app als u gebruik maakt van de xDrip app. xDrip app in volg-modus. @@ -130,4 +131,36 @@ Het wijzigen van de ISF-waarde in uw profiel is voldoende om de wijziging toe te passen. https://androidaps.readthedocs.io/en/latest/CROWDIN/nl/Getting-Started/FAQ.html#insuline-gevoeligheids-factor-insulin-sensitivity-factor-ISF-mmol-l-E-of-mg-dl-E https://androidaps.readthedocs.io/en/latest/CROWDIN/nl/Usage/Profielen.html + Onderwerp: De KH ratio + Hogere KH ratios leiden tot minder insuline afgifte voor een bepaalde hoeveelheid koolhydraten. + Lagere KH ratios leiden tot minder insuline afgifte voor een bepaalde hoeveelheid koolhydraten. + Als je 0 COB hebt zal het veranderen van KH ratio leiden tot een andere hoeveelheid insuline om jouw BG te corrigeren. + KH ratio zal anders zijn als je brood-eenheid telt als 10g of 12g. + KH ratio betekent: Hoeveel brood-eenheden gebruik je voor 1U insuline. + https://androidaps.readthedocs.io/en/latest/CROWDIN/nl/Getting-Started/FAQ.html#Koolhydraat-ratio-KH-g-E + Onderwerp: Profiel wissels + Bij het opgeven van 90% in je profiel wissel… + Basalen zullen 10% hoger zijn. + Basalen zullen 10% lager zijn. + De KH ratio wordt 10% hoger. + De KH ratio wordt 10% hoger. + ISF-waarde wordt 10% hoger. + ISF-waarde wordt 10% lager. + In totaal zul je ongeveer 10% minder insuline krijgen. + Doel zal 10% hoger zijn. + Doel zal 10% lager zijn. + Alleen de onderste target zal 10% lager zijn. + https://androidaps.readthedocs.io/en/latest/CROWDIN/nl/Usage/Profiles.html?highlight=profilewitch#profiel-wissel + Als u 1 uur eerder dan normaal wakker wordt, hoe moet u dan AAPS van deze wijziging in uw schema op de hoogte stellen? + Voer een profielwijziging uit met een tijdverschuiving van 1 + Voer een profiel wissel uit met een tijdverschuiving van -1 + https://androidaps.readthedocs.io/en/latest/CROWDIN/nl/Usage/Profiles.html?highlight=profilewitch#tijd-verschuiving + Voer een profiel wissel uit met een tijdverschuiving van 60 + Voer een profiel wissel uit met een tijdverschuiving van -60 + https://androidaps.readthedocs.io/en/latest/CROWDIN/nl/Module/module.html#goed-individueel-doserings-algoritme-voor-jouw-diabetesbehandeling + Onderwerp: Hulp met basaal waarden + Waar je terecht kunt voor hulp met basaal waarden etc. + Jouw behandelaars + Google + Facebook diff --git a/app/src/main/res/values-nl-rNL/objectives.xml b/app/src/main/res/values-nl-rNL/objectives.xml index cd10de8fdb..f605592027 100644 --- a/app/src/main/res/values-nl-rNL/objectives.xml +++ b/app/src/main/res/values-nl-rNL/objectives.xml @@ -51,4 +51,18 @@ https://androidaps.readthedocs.io/en/latest/CROWDIN/nl/Getting-Started/Screenshots.html#configurator https://androidaps.readthedocs.io/en/latest/CROWDIN/nl/Getting-Started/Screenshots.html#overzicht-scherm Niet verbonden met het internet + Ophalen tijd mislukt + Vereisten van doel niet behaald + + %1$d dag + %1$d dagen + + + %1$d uur + %1$d uren + + + %1$d minuut + %1$d minuten + diff --git a/app/src/main/res/values-nl-rNL/strings.xml b/app/src/main/res/values-nl-rNL/strings.xml index 42e9885cfb..dd9c1556cb 100644 --- a/app/src/main/res/values-nl-rNL/strings.xml +++ b/app/src/main/res/values-nl-rNL/strings.xml @@ -544,6 +544,8 @@ Activeer superbolus in de wizard Activeer de superbolus functie in de wizard. Activeer deze niet tot je begrijpt wat dit doet. OVERDOSIS IS MOGELIJK BIJ BLINDELINGS GEBRUIK! Toon statusindicatoren op startscherm + Toon uitgebreide statusindicatoren op overzicht scherm + Statusindicatoren inschakelen voor cage, iage, sage, reservoir en batterijniveau op het overzicht scherm. Drempel waarschuwing reservoir niveau [E] Drempel alarm reservoir niveau [E] Drempel waarschuwing batterij niveau [%%] @@ -617,6 +619,7 @@ Afbreken Niet alle profielen zijn geladen! Waarden niet opgeslagen! + Schakel broadcasts in naar andere apps (zoals xDrip). Schakel niet in als je NSClient of meer dan één installatie van AAPS hebt geïnstalleerd! Activeer locaal delen. ACTIVITEIT & FEEDBACK KOOLHYDRATEN & BOLUS @@ -1271,6 +1274,7 @@ Niet gestart RileyLink initialiseren… RileyLink fout + Tuning van RileyLink en Pomp Probleem tijdens verbinden met de pomp Verbonden @@ -1340,6 +1344,15 @@ Ophalen Tijdelijke Basaal Instellen Tijdelijke Basaal Instellen Bolus + Wijzig profiel naar + Wijzig profiel in %1$s + Laatste verbinding met pomp + Laatste verbinding met pomp [minuten geleden] + Laatste verbinding met pomp %1$s %2$s min geleden + Stuur SMS: %1$s + Stuur SMS naar alle nummers in voorkeuren + Stuur SMS met tekst + %2$+.2fU]]> Bolus limiet bereikt: %2$.2fU naar %3$.2fU]]> !!! Trage koolhydraat absorptie gedetecteerd: %2$d%% van de tijd. Controleer je berekening nogmaals. COB kan zijn overschat waardoor er misschien meer insuline wordt afgegeven!!! zijn]]> %1$.0f / %2$d E @@ -1347,4 +1360,15 @@ Bolus wizard voert de berekening uit maar alleen dit deel van berekende insuline wordt geleverd. Handig in combinatie met het SMB algoritme. Bezig met laden... Sluimeren + Tijdsinterval + Tijd ligt tussen %1$s en %2$s + Tussen + Sluiten + Verhogen van de maximale basaal waarde omdat de instelling lager is dan het maximum in het profiel + Ongeldige inhoud van het bericht + %1$s ISF: %2$.1f + %1$.0fg KH ratio: %2$.1f + %1$.1fg KH ratio: %2$.1f + Bolus wizard + min diff --git a/app/src/main/res/values-pl-rPL/exam.xml b/app/src/main/res/values-pl-rPL/exam.xml index c7f3d95422..262ad5a699 100644 --- a/app/src/main/res/values-pl-rPL/exam.xml +++ b/app/src/main/res/values-pl-rPL/exam.xml @@ -31,6 +31,56 @@ Wyeksportuj je po wprowadzeniu zmian. Wyeksportuj je po wykonaniu zadania. Wyeksportuj je po zakończeniu wstępnych ustawień. + https://androidaps.readthedocs.io/en/latest/EN/Usage/ExportImportSettings.html + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#what-emergency-equipment-is-recommended-to-take-with-me + Temat: Szumy w odczytach z CGM + Co powinno być wykonane gdy dane CGM są zaszumione? + Nic, AAPS sobie z tym poradzi. + Wyłącz pętlę, by unilknąć przedawkowania insuliny. + Wymień czujnik CGM. + Wyłącz telefon. + https://androidaps.readthedocs.io/en/latest/EN/Usage/Smoothing-Blood-Glucose-Data-in-xDrip.html#smoothing-blood-glucose-data + Sprawdź, czy Twój CGM wygładza dane poziomu cukru. + Temat: Ćwiczenia + Jak możesz pomóc aby system poradził sobie z ćwiczeniami? + Korzystanie z funkcji tymczasowego docelowego poziomu cukru. + Wykonaj zmianę profilu poniżej 100%. + Wykonaj zmianę profilu powyżej 100%. + Zatrzymaj pętlę. + Ustaw cel tymczasowy Ćwiczenia przed rozpoczęciem ćwiczeń. + Ustawienie celu tymczasowego Ćwiczenia po rozpoczęciu ćwiczeń prowadzi do gorszych wynikow poziomu niż przy jego wcześniejszym rozpoczęciu. + https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html#activity-temp-target + Temat: Wyłączona/Zawieszona pętla + Czy otrzymuję insulinę, gdy pętla jest wyłączona/zawieszona? + Tak, insulina bazowa nadal jest dostarczana. + Nie, podawanie insuliny jest zatrzymane. + Temat: Testowanie Bazy, ISF i IC + Kiedy powinienem zweryfikować wartości bazy, ISF i IC? + Zanim zacznę używać pętli. + Gdy często występują niskie poziomy cukru. + Gdy często występują wysokie poziomy cukru. + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#androidaps-settings + Temat: Wymagania wstępne + Czego potrzebuję? + Sprawdzone informacje profilowe (Basal, IC, ISF, DIA). + Komputer do utworzenia pliku APK. + Obsługiwany telefon. + Samochód. + Nightscout, aby przejść przez zadania. + Konto Tidepool. + Konto Google. + Konto Github. + Doświadczenie w rozwoju systemu Android. + Pompa MiniMed 670G. + https://androidaps.readthedocs.io/en/latest/EN/Module/module.html + Smartwatch. + Obsługiwany CGM. + Temat: Aktualizacja AndroidAPS + Co jest prawdą? + Musisz mieć zainstalowany Git. + Aktualizuj tak szybko jak nowe wersja zostanie opublikowana i znajdziesz czas do jej wprowadzenia. + Należy używać tych samych kluczy do podpisywania. + Nigdy nie aktualizuj, jeśli system działa dobrze. Poproś swojego przyjaciela o nowy plik APK. https://androidaps.readthedocs.io/en/latest/EN/Installing-AndroidAPS/Update-to-new-version.html#update-to-a-new-version-or-branch Temat: Rozwiązywanie problemów @@ -81,4 +131,36 @@ Zmiana wartości ISF w profilu wystarczy, aby zastosować zmianę. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#insulin-sensitivity-factor-isf-mmol-l-u-or-mg-dl-u https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html + Temat: Wartość przelicznika IC + Wyższe wartości ICprowadzą do mniejszej ilości insuliny dostarczonej do podanej ilości węglowodanów. + Niższe wartości IC prowadzą do mniejszej ilości insuliny podanej do wprowadzonej ilości węglowodanów. + Załóżmy, że masz 0 COB. Zmiana IC doprowadzi do podania innej ilości insuliny w celu skorygowania twojej wartości BG. + IC będzie inny, jeśli policzysz jednostkę chleba jako 10 g lub 12 g. + Znaczenie IC to: Ile jednostek chleba jest pokrytych 1U insuliny. + https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#carbohydrate-to-insulin-ratio-cr-g-u + Temat: Przełączanie profili + Jeśli podasz 90% podczas zmiany profilu… + Baza będzie o 10% wyższa. + Baza będzie o 10% niższa. + Wartość IC będzie o 10% wyższa. + Wartość IC będzie o 10% niższa. + Wartość ISF będzie o 10% wyższa. + Wartość ISF będzie o 10% niższa. + Otrzymasz w sumie około 10% mniej insuliny. + Cel będzie wyższy o 10%. + Cel będzie o 10% niższy. + Tylko dolny cel będzie o 10% niższy. + https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html?highlight=profile%20switch#profile-switch + Jeśli obudzisz się o 1h wcześniej niż zwykle, to jak należy powiadomić AAPS o zmianie w harmonogramie? + Wprowadź zmianę profilu ze zmianą czasu równą 1 + Wprowadź zmianę profilu ze zmianą czasu równą -1 + https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html?highlight=profile%20switch#timeshift + Wprowadź zmianę profilu ze zmianą czasu równą 60 + Wprowadź zmianę profilu ze zmianą czasu równą -60 + https://androidaps.readthedocs.io/en/latest/EN/Module/module.html#good-individual-dosage-algorithm-for-your-diabetes-therapy + Temat: Pomoc z dawkami podstawowymi (bazą) + Gdzie uzyskać pomoc w sprawie dawek podstawowych itp. + Twój zespół cukrzycowy + Google + Facebook diff --git a/app/src/main/res/values-pl-rPL/objectives.xml b/app/src/main/res/values-pl-rPL/objectives.xml index 49da1c2fb9..17777caf68 100644 --- a/app/src/main/res/values-pl-rPL/objectives.xml +++ b/app/src/main/res/values-pl-rPL/objectives.xml @@ -1,6 +1,24 @@ + Wstecz + Start + Zweryfikuj + %1$d. Zadanie + Zadanie %1$d nierozpoczęte + Zadanie %1$d nieukończone + Konfiguracja wizualizacji i monitorowania, analiza dawek bazowych i współczynników + Sprawdź czy BG (pomiary cukru) są dostępne w Nightscout, i czy przesyłane są dane pompy insulinowej + Rozpoczęcie w trybie otwartej pętli (open loop) + Uruchom w trybie otwartej pętli przez kilka dni i ręcznie potwierdzaj kilka zmian dawki tymczasowej. Ustaw i używaj celów tymczasowych i domyślnych celów tymczasowych (np. Ćwiczenia lub Hipo) + Zrozumienie działania otwartej pętli, wraz z jej rekomendacjami dawek tymczasowych + Na podstawie tych doświadczeń zdecyduj jaka powinna być ustawiona maksymalna baza, i wprowadź ją w pompie i w ustawieniach AAPS + Rozpoczęcie zamknięcia pętli z zawieszeniem podawania bazy przy niskim poziomie cukru + Używaj przez kilka dni zamkniętej pętli (Closed Loop) z max IOB = 0 bez zbyt wielu incydentów niedocukrzeń + Dostrajanie zamkniętej pętli, podniesienie wartości max IOB powyżej 0 i stopniowe obniżanie docelowego poziomu cukru (BG target) + Używaj pętli przez kilka dni i przynajmniej jedną noc bez żadnego alarmu niskiego poziomu, przed obniżeniem docelowego poziomu cukru + Dostosuj bazę i wartości parametrów jeśli jest to potrzebne, i wtedy uruchom funkcję autosens + 1 tydzień sukcesu w działaniu pętli w ciągu dnia z regularnym wprowadzaniem spożywanych węglowodanów Włączanie dodatkowych funkcji do użytku, jak AMA Włączanie dodatkowych funkcji do użytku, jak SMB (Super Mikro Bolusy) Musisz przeczytać wiki i zwiększyć maxIOB, aby SMB działało dobrze! Dobrym początkiem jest maxIOB = średni bolus + 3 x maks. dzienna dawka bazowa @@ -41,4 +59,16 @@ %1$d dni %1$d dni + + %1$d godzina + %1$d godziny + %1$d godzin + %1$d godziny + + + %1$d minuta + %1$d minut + %1$d minut + %1$d minuty + diff --git a/app/src/main/res/values-pt-rPT/exam.xml b/app/src/main/res/values-pt-rPT/exam.xml index 15a55316bb..d959aea994 100644 --- a/app/src/main/res/values-pt-rPT/exam.xml +++ b/app/src/main/res/values-pt-rPT/exam.xml @@ -86,6 +86,8 @@ App Spike no iPhone. https://androidaps.readthedocs.io/en/latest/EN/Children/Children.html Tópico: Factor de Sensibilidade de Insulina + É necessário inserir FSI nas Preferências. + A alteração do valor do FSI no seu perfil é suficiente para aplicar a mudança. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#insulin-sensitivity-factor-isf-mmol-l-u-or-mg-dl-u https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html Tópico: Rácio IC @@ -99,10 +101,16 @@ O valor FSI será 10% mais baixo. Alvo será 10% superior. Alvo será 10% inferior. + Só alvo inferior será 10% menor. https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html?highlight=profile%20switch#profile-switch + Iniciar uma mudança de perfil com uma alteração de turno de 1 + Iniciar uma mudança de perfil com uma alteração de turno de -1 https://androidaps.readthedocs.io/en/latest/EN/Usage/Profiles.html?highlight=profile%20switch#timeshift + Iniciar uma mudança de perfil com uma alteração de turno de 60 + Iniciar uma mudança de perfil com uma alteração de turno de -60 https://androidaps.readthedocs.io/en/latest/EN/Module/module.html#good-individual-dosage-algorithm-for-your-diabetes-therapy Tópico: Ajuda com taxas de basal + Onde ir para obter ajuda com rácios da basal, etc. A sua equipa da diabetes Google Facebook diff --git a/app/src/main/res/values-sv-rSE/strings.xml b/app/src/main/res/values-sv-rSE/strings.xml index 5cee7655ff..1bc618c36d 100644 --- a/app/src/main/res/values-sv-rSE/strings.xml +++ b/app/src/main/res/values-sv-rSE/strings.xml @@ -591,7 +591,7 @@ Eversense-appen. Akut varning efter [min] Intervall för autosens [tim] Antal timmar för beräkning av känslighet (absorptionstid för KH är exkluderad) - P + Pump OpenAPS Uppladdare Känslighetsavkänning From 6a7cb2ac7ba2a92d7a59b2474ec98d22d191fa3e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 17 Oct 2019 22:46:00 +0200 Subject: [PATCH 02/14] fix disabling automation --- .../plugins/general/automation/EventListAdapter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/EventListAdapter.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/EventListAdapter.java index ec1cac23d6..fba54aefbd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/EventListAdapter.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/EventListAdapter.java @@ -82,8 +82,8 @@ class EventListAdapter extends RecyclerView.Adapter } // enabled event - holder.enabled.setOnCheckedChangeListener((buttonView, isChecked) -> { - event.setEnabled(isChecked); + holder.enabled.setOnClickListener(v -> { + event.setEnabled((holder.enabled.isChecked())); RxBus.INSTANCE.send(new EventAutomationDataChanged()); }); From 56152fa1fa96a3fd03db13f920410a62a84cb902 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 18 Oct 2019 11:21:50 +0200 Subject: [PATCH 03/14] move wakelock to MainApp --- .../nightscout/androidaps/MainActivity.java | 43 ------------------- .../info/nightscout/androidaps/MainApp.java | 37 ++++++++++++++++ 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 9287921879..6cd926a2d5 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -6,7 +6,6 @@ import android.content.pm.PackageManager; import android.graphics.Rect; import android.os.Bundle; import android.os.PersistableBundle; -import android.os.PowerManager; import android.text.SpannableString; import android.text.method.LinkMovementMethod; import android.text.util.Linkify; @@ -15,7 +14,6 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; -import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.LinearLayout; @@ -45,7 +43,6 @@ import info.nightscout.androidaps.activities.PreferencesActivity; import info.nightscout.androidaps.activities.SingleFragmentActivity; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.events.EventAppExit; -import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRebuildTabs; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginType; @@ -70,8 +67,6 @@ public class MainActivity extends NoSplashAppCompatActivity { private static Logger log = LoggerFactory.getLogger(L.CORE); private CompositeDisposable disposable = new CompositeDisposable(); - protected PowerManager.WakeLock mWakeLock; - private ActionBarDrawerToggle actionBarDrawerToggle; private MenuItem pluginPreferencesMenuItem; @@ -94,9 +89,6 @@ public class MainActivity extends NoSplashAppCompatActivity { drawerLayout.addDrawerListener(actionBarDrawerToggle); actionBarDrawerToggle.syncState(); - // initialize screen wake lock - processPreferenceChange(new EventPreferenceChange(R.string.key_keep_screen_on)); - doMigrations(); final ViewPager viewPager = findViewById(R.id.pager); @@ -154,20 +146,8 @@ public class MainActivity extends NoSplashAppCompatActivity { setupTabs(); setupViews(); } - - boolean keepScreenOn = Config.NSCLIENT && SP.getBoolean(R.string.key_keep_screen_on, false); - if (keepScreenOn) - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - else - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }, FabricPrivacy::logException) ); - disposable.add(RxBus.INSTANCE - .toObservable(EventPreferenceChange.class) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(this::processPreferenceChange, FabricPrivacy::logException) - ); - if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) { Intent intent = new Intent(this, SetupWizardActivity.class); startActivity(intent); @@ -183,35 +163,12 @@ public class MainActivity extends NoSplashAppCompatActivity { } } - @Override - public void onDestroy() { - if (mWakeLock != null) - if (mWakeLock.isHeld()) - mWakeLock.release(); - super.onDestroy(); - } - @Override public void onPause() { super.onPause(); disposable.clear(); } - public void processPreferenceChange(final EventPreferenceChange ev) { - if (ev.isChanged(R.string.key_keep_screen_on)) { - boolean keepScreenOn = SP.getBoolean(R.string.key_keep_screen_on, false); - final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); - if (keepScreenOn) { - mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "AndroidAPS:MainActivity_onEventPreferenceChange"); - if (!mWakeLock.isHeld()) - mWakeLock.acquire(); - } else { - if (mWakeLock != null && mWakeLock.isHeld()) - mWakeLock.release(); - } - } - } - private void setupViews() { TabPageAdapter pageAdapter = new TabPageAdapter(getSupportFragmentManager(), this); NavigationView navigationView = findViewById(R.id.navigation_view); diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index a1300f59bc..cfd93a01f9 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -2,8 +2,10 @@ package info.nightscout.androidaps; import android.app.Application; import android.content.BroadcastReceiver; +import android.content.Context; import android.content.IntentFilter; import android.content.res.Resources; +import android.os.PowerManager; import android.os.SystemClock; import androidx.annotation.Nullable; @@ -24,6 +26,7 @@ import java.util.ArrayList; import info.nightscout.androidaps.data.ConstraintChecker; import info.nightscout.androidaps.db.DatabaseHelper; +import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpInterface; @@ -32,6 +35,7 @@ import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin; import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin; +import info.nightscout.androidaps.plugins.bus.RxBus; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.constraints.dstHelper.DstHelperPlugin; import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin; @@ -89,13 +93,20 @@ import info.nightscout.androidaps.receivers.NSAlarmReceiver; import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver; import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.utils.FabricPrivacy; +import info.nightscout.androidaps.utils.SP; import io.fabric.sdk.android.Fabric; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.CompositeDisposable; import static info.nightscout.androidaps.plugins.general.versionChecker.VersionCheckerUtilsKt.triggerCheckVersion; public class MainApp extends Application { private static Logger log = LoggerFactory.getLogger(L.CORE); + private CompositeDisposable disposable = new CompositeDisposable(); + + private PowerManager.WakeLock mWakeLock; + private static KeepAliveReceiver keepAliveReceiver; private static MainApp sInstance; @@ -233,6 +244,15 @@ public class MainApp extends Application { startKeepAliveService(); }).start(); } + + // initialize screen wake lock + processPreferenceChange(new EventPreferenceChange(R.string.key_keep_screen_on)); + + disposable.add(RxBus.INSTANCE + .toObservable(EventPreferenceChange.class) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(this::processPreferenceChange, FabricPrivacy::logException) + ); } private void registerLocalBroadcastReceiver() { @@ -318,6 +338,21 @@ public class MainApp extends Application { return sConstraintsChecker; } + public void processPreferenceChange(final EventPreferenceChange ev) { + if (ev.isChanged(R.string.key_keep_screen_on)) { + boolean keepScreenOn = SP.getBoolean(R.string.key_keep_screen_on, false); + final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); + if (keepScreenOn) { + mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "AndroidAPS:MainApp_processPreferenceChange"); + if (!mWakeLock.isHeld()) + mWakeLock.acquire(); + } else { + if (mWakeLock != null && mWakeLock.isHeld()) + mWakeLock.release(); + } + } + } + public static ArrayList getPluginsList() { return pluginsList; } @@ -439,6 +474,8 @@ public class MainApp extends Application { unregisterReceiver(timeDateOrTZChangeReceiver); } + if (mWakeLock != null && mWakeLock.isHeld()) + mWakeLock.release(); } public static int dpToPx(int dp) { From d2a4aea9e2792a58f4a2cda6ed30f9916542bd0e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 18 Oct 2019 13:12:45 +0200 Subject: [PATCH 04/14] remove MainApp::getSpecificPlugin --- .../info/nightscout/androidaps/MainApp.java | 13 -------- .../activities/TDDStatsActivity.java | 10 +++---- .../plugins/general/food/FoodFragment.java | 7 ++--- .../nsclient/receivers/AckAlarmReceiver.java | 2 +- .../nsclient/receivers/DBAccessReceiver.java | 2 +- .../nsclient/services/NSClientService.java | 6 ++-- .../general/overview/OverviewFragment.java | 2 +- .../SmsCommunicatorPlugin.java | 28 ++++++++--------- .../general/wear/ActionStringHandler.java | 10 +++---- .../activities/DanaRUserOptionsActivity.java | 6 ++-- .../pump/danaR/comm/MsgCheckValue.java | 2 +- .../danaR/comm/MsgInitConnStatusTime.java | 16 +++++----- .../comm/MsgInitConnStatusTime_k.java | 14 ++++----- .../pump/danaRS/services/DanaRSService.java | 2 +- .../pump/danaRv2/comm/MsgCheckValue_v2.java | 30 +++++++++---------- .../services/DanaRv2ExecutionService.java | 2 +- .../queue/commands/CommandSetProfile.java | 4 +-- app/src/test/java/info/AAPSMocker.java | 12 +------- .../SmsCommunicatorPluginTest.java | 5 ++-- .../danaR/comm/MsgInitConnStatusTimeTest.java | 17 ++++++----- .../danaRv2/comm/MsgCheckValue_v2Test.java | 19 +++++++----- .../comm/MsgSetHistoryEntry_v2Test.java | 15 ++++++---- .../comm/MsgStatusTempBasal_v2Test.java | 17 ++++++----- 23 files changed, 114 insertions(+), 127 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index cfd93a01f9..74d61a4c3a 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -415,19 +415,6 @@ public class MainApp extends Application { return newList; } - @Nullable - public static T getSpecificPlugin(Class pluginClass) { - if (pluginsList != null) { - for (PluginBase p : pluginsList) { - if (pluginClass.isAssignableFrom(p.getClass())) - return (T) p; - } - } else { - log.error("pluginsList=null"); - } - return null; - } - public static boolean isEngineeringModeOrRelease() { if (!Config.APS) return true; diff --git a/app/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java b/app/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java index eed8c697e0..24cdceada6 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java @@ -536,11 +536,11 @@ public class TDDStatsActivity extends NoSplashActivity { public static boolean isOldData(List historyList) { Object activePump = ConfigBuilderPlugin.getPlugin().getActivePump(); - PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class); - PumpInterface danaRS = MainApp.getSpecificPlugin(DanaRSPlugin.class); - PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class); - PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class); - PumpInterface insight = MainApp.getSpecificPlugin(LocalInsightPlugin.class); + PumpInterface dana = DanaRPlugin.getPlugin(); + PumpInterface danaRS = DanaRSPlugin.getPlugin(); + PumpInterface danaV2 = DanaRv2Plugin.getPlugin(); + PumpInterface danaKorean = DanaRKoreanPlugin.getPlugin(); + PumpInterface insight = LocalInsightPlugin.getPlugin(); boolean startsYesterday = activePump == dana || activePump == danaRS || activePump == danaV2 || activePump == danaKorean || activePump == insight; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.java index 5e21b6efd7..997c6b0ba9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.java @@ -122,8 +122,7 @@ public class FoodFragment extends Fragment { } }); - RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp - .getSpecificPlugin(FoodPlugin.class).getService().getFoodData()); + RecyclerViewAdapter adapter = new RecyclerViewAdapter(FoodPlugin.getPlugin().getService().getFoodData()); recyclerView.setAdapter(adapter); loadData(); @@ -151,7 +150,7 @@ public class FoodFragment extends Fragment { } void loadData() { - unfiltered = MainApp.getSpecificPlugin(FoodPlugin.class).getService().getFoodData(); + unfiltered = FoodPlugin.getPlugin().getService().getFoodData(); } void fillCategories() { @@ -297,7 +296,7 @@ public class FoodFragment extends Fragment { if (_id != null && !_id.equals("")) { NSUpload.removeFoodFromNS(_id); } - MainApp.getSpecificPlugin(FoodPlugin.class).getService().delete(food); + FoodPlugin.getPlugin().getService().delete(food); } }); builder.setNegativeButton(MainApp.gs(R.string.cancel), null); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/receivers/AckAlarmReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/receivers/AckAlarmReceiver.java index 7185072692..1c46716d69 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/receivers/AckAlarmReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/receivers/AckAlarmReceiver.java @@ -27,7 +27,7 @@ public class AckAlarmReceiver extends BroadcastReceiver { PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, AckAlarmReceiver.class.getSimpleName()); - NSClientPlugin nsClientPlugin = MainApp.getSpecificPlugin(NSClientPlugin.class); + NSClientPlugin nsClientPlugin = NSClientPlugin.getPlugin(); if (!nsClientPlugin.isEnabled(PluginType.GENERAL)) { return; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/receivers/DBAccessReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/receivers/DBAccessReceiver.java index 4d8b7eba2a..4838c178ef 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/receivers/DBAccessReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/receivers/DBAccessReceiver.java @@ -118,7 +118,7 @@ public class DBAccessReceiver extends BroadcastReceiver { } public boolean shouldUpload() { - NSClientPlugin nsClientPlugin = MainApp.getSpecificPlugin(NSClientPlugin.class); + NSClientPlugin nsClientPlugin = NSClientPlugin.getPlugin(); return nsClientPlugin.isEnabled(PluginType.GENERAL) && !SP.getBoolean(R.string.key_ns_noupload, false); } 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 785fb1361b..e1c57cc7c2 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 @@ -265,10 +265,10 @@ public class NSClientService extends Service { nsAPIhashCode = Hashing.sha1().hashString(nsAPISecret, Charsets.UTF_8).toString(); RxBus.INSTANCE.send(new EventNSClientStatus("Initializing")); - if (!MainApp.getSpecificPlugin(NSClientPlugin.class).isAllowed()) { + if (!NSClientPlugin.getPlugin().isAllowed()) { RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "not allowed")); RxBus.INSTANCE.send(new EventNSClientStatus("Not allowed")); - } else if (MainApp.getSpecificPlugin(NSClientPlugin.class).paused) { + } else if (NSClientPlugin.getPlugin().paused) { RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "paused")); RxBus.INSTANCE.send(new EventNSClientStatus("Paused")); } else if (!nsEnabled) { @@ -386,7 +386,7 @@ public class NSClientService extends Service { } public void readPreferences() { - nsEnabled = MainApp.getSpecificPlugin(NSClientPlugin.class).isEnabled(PluginType.GENERAL); + nsEnabled = NSClientPlugin.getPlugin().isEnabled(PluginType.GENERAL); nsURL = SP.getString(R.string.key_nsclientinternal_url, ""); nsAPISecret = SP.getString(R.string.key_nsclientinternal_api_secret, ""); nsDevice = SP.getString("careportal_enteredby", ""); 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 bcb8a61ddd..5c2a7cac84 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 @@ -1146,7 +1146,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } // **** Calibration & CGM buttons **** - boolean xDripIsBgSource = MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginType.BGSOURCE); + boolean xDripIsBgSource = SourceXdripPlugin.getPlugin().isEnabled(PluginType.BGSOURCE); boolean dexcomIsSource = SourceDexcomPlugin.INSTANCE.isEnabled(PluginType.BGSOURCE); boolean bgAvailable = DatabaseHelper.actualBg() != null; if (calibrationButton != null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.java index b10a0b5ed0..264d7c3e52 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.java @@ -310,8 +310,8 @@ public class SmsCommunicatorPlugin extends PluginBase { switch (splitted[1].toUpperCase()) { case "DISABLE": case "STOP": - LoopPlugin loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class); - if (loopPlugin != null && loopPlugin.isEnabled(PluginType.LOOP)) { + LoopPlugin loopPlugin = LoopPlugin.getPlugin(); + if (loopPlugin.isEnabled(PluginType.LOOP)) { loopPlugin.setPluginEnabled(PluginType.LOOP, false); ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() { @Override @@ -329,8 +329,8 @@ public class SmsCommunicatorPlugin extends PluginBase { break; case "ENABLE": case "START": - loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class); - if (loopPlugin != null && !loopPlugin.isEnabled(PluginType.LOOP)) { + loopPlugin = LoopPlugin.getPlugin(); + if (!loopPlugin.isEnabled(PluginType.LOOP)) { loopPlugin.setPluginEnabled(PluginType.LOOP, true); sendSMS(new Sms(receivedSms.phoneNumber, R.string.smscommunicator_loophasbeenenabled)); RxBus.INSTANCE.send(new EventRefreshOverview("SMS_LOOP_START")); @@ -340,18 +340,16 @@ public class SmsCommunicatorPlugin extends PluginBase { receivedSms.processed = true; break; case "STATUS": - loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class); - if (loopPlugin != null) { - if (loopPlugin.isEnabled(PluginType.LOOP)) { - if (loopPlugin.isSuspended()) - reply = String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend()); - else - reply = MainApp.gs(R.string.smscommunicator_loopisenabled); - } else { - reply = MainApp.gs(R.string.smscommunicator_loopisdisabled); - } - sendSMS(new Sms(receivedSms.phoneNumber, reply)); + loopPlugin = LoopPlugin.getPlugin(); + if (loopPlugin.isEnabled(PluginType.LOOP)) { + if (loopPlugin.isSuspended()) + reply = String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend()); + else + reply = MainApp.gs(R.string.smscommunicator_loopisenabled); + } else { + reply = MainApp.gs(R.string.smscommunicator_loopisdisabled); } + sendSMS(new Sms(receivedSms.phoneNumber, reply)); receivedSms.processed = true; break; case "RESUME": diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.java index 25a6540dbd..1cf4dd7539 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.java @@ -437,11 +437,11 @@ public class ActionStringHandler { public static boolean isOldData(List historyList) { Object activePump = ConfigBuilderPlugin.getPlugin().getActivePump(); - PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class); - PumpInterface danaRS = MainApp.getSpecificPlugin(DanaRSPlugin.class); - PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class); - PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class); - PumpInterface insight = MainApp.getSpecificPlugin(LocalInsightPlugin.class); + PumpInterface dana = DanaRPlugin.getPlugin(); + PumpInterface danaRS = DanaRSPlugin.getPlugin(); + PumpInterface danaV2 = DanaRv2Plugin.getPlugin(); + PumpInterface danaKorean = DanaRKoreanPlugin.getPlugin(); + PumpInterface insight = LocalInsightPlugin.getPlugin(); boolean startsYesterday = activePump == dana || activePump == danaRS || activePump == danaV2 || activePump == danaKorean || activePump == insight; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRUserOptionsActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRUserOptionsActivity.java index 23520f3491..f1181bb7cb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRUserOptionsActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/activities/DanaRUserOptionsActivity.java @@ -51,9 +51,9 @@ public class DanaRUserOptionsActivity extends NoSplashActivity { NumberPicker lowReservoir; Button saveToPumpButton; // This is for Dana pumps only - boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class) != null && MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginType.PUMP); - boolean isDanaR = MainApp.getSpecificPlugin(DanaRPlugin.class) != null && MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PUMP); - boolean isDanaRv2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class) != null && MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginType.PUMP); + boolean isRS = DanaRSPlugin.getPlugin().isEnabled(PluginType.PUMP); + boolean isDanaR = DanaRPlugin.getPlugin().isEnabled(PluginType.PUMP); + boolean isDanaRv2 = DanaRv2Plugin.getPlugin().isEnabled(PluginType.PUMP); @Override protected synchronized void onResume() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.java index d40f8f0cd6..317fe9db81 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.java @@ -32,7 +32,7 @@ public class MsgCheckValue extends MessageBase { pump.protocol = intFromBuff(bytes, 1, 1); pump.productCode = intFromBuff(bytes, 2, 1); if (pump.model != DanaRPump.EXPORT_MODEL) { - MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model"); + DanaRPlugin.getPlugin().disconnect("Wrong Model"); log.debug("Wrong model selected"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTime.java index 516f1f0ff8..974e63fe80 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTime.java @@ -31,19 +31,19 @@ public class MsgInitConnStatusTime extends MessageBase { if (bytes.length - 10 > 7) { Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); RxBus.INSTANCE.send(new EventNewNotification(notification)); - MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model"); + DanaRPlugin.getPlugin().disconnect("Wrong Model"); log.error("Wrong model selected. Switching to Korean DanaR"); - MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, true); - MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true); - MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false); - MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginType.PUMP, false); + DanaRKoreanPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, true); + DanaRKoreanPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, true); + DanaRPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, false); + DanaRPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, false); DanaRPump.reset(); // mark not initialized //If profile coming from pump, switch it as well - if (MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PROFILE)) { - (MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, false); - (MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true); + if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)) { + (DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, false); + (DanaRKoreanPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, true); } ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaDriver"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgInitConnStatusTime_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgInitConnStatusTime_k.java index f3243b827a..8a642a89f8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgInitConnStatusTime_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgInitConnStatusTime_k.java @@ -35,17 +35,17 @@ public class MsgInitConnStatusTime_k extends MessageBase { RxBus.INSTANCE.send(new EventNewNotification(notification)); DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model"); log.error("Wrong model selected. Switching to export DanaR"); - MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, false); - MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, false); - MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, true); - MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginType.PUMP, true); + DanaRKoreanPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, false); + DanaRKoreanPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, false); + DanaRPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, true); + DanaRPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, true); DanaRPump.reset(); // mark not initialized //If profile coming from pump, switch it as well - if (MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PROFILE)) { - (MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, false); - (MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, true); + if (DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PROFILE)) { + (DanaRKoreanPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, false); + (DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, true); } ConfigBuilderPlugin.getPlugin().storeSettings("ChangingKoreanDanaDriver"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java index e7696836ac..2850f08c8d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/services/DanaRSService.java @@ -249,7 +249,7 @@ public class DanaRSService extends Service { public PumpEnactResult loadEvents() { - if (!MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()) { + if (!DanaRSPlugin.getPlugin().isInitialized()) { PumpEnactResult result = new PumpEnactResult().success(false); result.comment = "pump not initialized"; return result; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.java index ad82f41cfe..3070c52b64 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.java @@ -45,19 +45,19 @@ public class MsgCheckValue_v2 extends MessageBase { pump.lastConnection = 0; Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); RxBus.INSTANCE.send(new EventNewNotification(notification)); - MainApp.getSpecificPlugin(DanaRPlugin.class).disconnect("Wrong Model"); + DanaRPlugin.getPlugin().disconnect("Wrong Model"); log.error("Wrong model selected. Switching to Korean DanaR"); - MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setPluginEnabled(PluginType.PUMP, true); - MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginType.PUMP, true); - MainApp.getSpecificPlugin(DanaRPlugin.class).setPluginEnabled(PluginType.PUMP, false); - MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginType.PUMP, false); + DanaRKoreanPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, true); + DanaRKoreanPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, true); + DanaRPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, false); + DanaRPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, false); DanaRPump.reset(); // mark not initialized //If profile coming from pump, switch it as well - if (MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PROFILE)) { - (MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, false); - (MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).setPluginEnabled(PluginType.PROFILE, true); + if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)) { + (DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, false); + (DanaRKoreanPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, true); } ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaRv2Driver"); @@ -72,15 +72,15 @@ public class MsgCheckValue_v2 extends MessageBase { RxBus.INSTANCE.send(new EventNewNotification(notification)); DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model"); log.error("Wrong model selected. Switching to non APS DanaR"); - (MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setPluginEnabled(PluginType.PUMP, false); - (MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setFragmentVisible(PluginType.PUMP, false); - (MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PUMP, true); - (MainApp.getSpecificPlugin(DanaRPlugin.class)).setFragmentVisible(PluginType.PUMP, true); + (DanaRv2Plugin.getPlugin()).setPluginEnabled(PluginType.PUMP, false); + (DanaRv2Plugin.getPlugin()).setFragmentVisible(PluginType.PUMP, false); + (DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PUMP, true); + (DanaRPlugin.getPlugin()).setFragmentVisible(PluginType.PUMP, true); //If profile coming from pump, switch it as well - if (MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginType.PROFILE)) { - (MainApp.getSpecificPlugin(DanaRv2Plugin.class)).setPluginEnabled(PluginType.PROFILE, false); - (MainApp.getSpecificPlugin(DanaRPlugin.class)).setPluginEnabled(PluginType.PROFILE, true); + if (DanaRv2Plugin.getPlugin().isEnabled(PluginType.PROFILE)) { + (DanaRv2Plugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, false); + (DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, true); } ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaRv2Driver"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java index 7c2cc7ede5..e528a67fae 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/services/DanaRv2ExecutionService.java @@ -471,7 +471,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { public PumpEnactResult loadEvents() { DanaRPump danaRPump = DanaRPump.getInstance(); - if (!MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()) { + if (!DanaRv2Plugin.getPlugin().isInitialized()) { PumpEnactResult result = new PumpEnactResult().success(false); result.comment = "pump not initialized"; return result; diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java index 6b8a610fa6..62e14285eb 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java @@ -50,8 +50,8 @@ public class CommandSetProfile extends Command { // Send SMS notification if ProfileSwitch is comming from NS ProfileSwitch profileSwitch = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(System.currentTimeMillis()); if (profileSwitch != null && r.enacted && profileSwitch.source == Source.NIGHTSCOUT) { - SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class); - if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) { + SmsCommunicatorPlugin smsCommunicatorPlugin = SmsCommunicatorPlugin.getPlugin(); + if (smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) { smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.gs(R.string.profile_set_ok)); } } diff --git a/app/src/test/java/info/AAPSMocker.java b/app/src/test/java/info/AAPSMocker.java index 304c84ea45..a36c989b11 100644 --- a/app/src/test/java/info/AAPSMocker.java +++ b/app/src/test/java/info/AAPSMocker.java @@ -37,6 +37,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -234,17 +235,6 @@ public class AAPSMocker { } - public static DanaRPlugin mockDanaRPlugin() { - PowerMockito.mockStatic(DanaRPlugin.class); - DanaRPlugin danaRPlugin = mock(DanaRPlugin.class); - DanaRv2Plugin danaRv2Plugin = mock(DanaRv2Plugin.class); - DanaRKoreanPlugin danaRKoreanPlugin = mock(DanaRKoreanPlugin.class); - when(MainApp.getSpecificPlugin(DanaRPlugin.class)).thenReturn(danaRPlugin); - when(MainApp.getSpecificPlugin(DanaRv2Plugin.class)).thenReturn(danaRv2Plugin); - when(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).thenReturn(danaRKoreanPlugin); - return danaRPlugin; - } - public static Profile getValidProfile() { try { if (profile == null) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.java index f97a397e32..bc928ded85 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.java @@ -57,7 +57,7 @@ import static org.powermock.api.mockito.PowerMockito.when; L.class, SP.class, MainApp.class, DateUtil.class, ProfileFunctions.class, TreatmentsPlugin.class, SmsManager.class, IobCobCalculatorPlugin.class, CommandQueue.class, ConfigBuilderPlugin.class, NSUpload.class, ProfileInterface.class, - SimpleProfilePlugin.class, XdripCalibrations.class, VirtualPumpPlugin.class + SimpleProfilePlugin.class, XdripCalibrations.class, VirtualPumpPlugin.class, LoopPlugin.class }) public class SmsCommunicatorPluginTest { @@ -744,8 +744,9 @@ public class SmsCommunicatorPluginTest { smsCommunicatorPlugin = SmsCommunicatorPlugin.getPlugin(); smsCommunicatorPlugin.setPluginEnabled(PluginType.GENERAL, true); + mockStatic(LoopPlugin.class); loopPlugin = mock(LoopPlugin.class); - when(MainApp.getSpecificPlugin(LoopPlugin.class)).thenReturn(loopPlugin); + when(LoopPlugin.getPlugin()).thenReturn(loopPlugin); Mockito.doAnswer(invocation -> { Callback callback = invocation.getArgument(1); diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.java index 486a98524d..b5ef46e9b2 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -22,13 +23,6 @@ import static org.junit.Assert.assertEquals; public class MsgInitConnStatusTimeTest { @Test public void runTest() { - AAPSMocker.mockMainApp(); - AAPSMocker.mockApplicationContext(); - AAPSMocker.mockSP(); - AAPSMocker.mockL(); - AAPSMocker.mockConfigBuilder(); - AAPSMocker.mockCommandQueue(); - AAPSMocker.mockDanaRPlugin(); MsgInitConnStatusTime packet = new MsgInitConnStatusTime(); // test message decoding @@ -56,4 +50,13 @@ public class MsgInitConnStatusTimeTest { return ret; } + @Before + public void mock() { + AAPSMocker.mockMainApp(); + AAPSMocker.mockApplicationContext(); + AAPSMocker.mockSP(); + AAPSMocker.mockL(); + AAPSMocker.mockConfigBuilder(); + AAPSMocker.mockCommandQueue(); + } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.java b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.java index e81c5416f1..d7910d313d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRv2.comm; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -20,17 +21,10 @@ import static org.junit.Assert.*; import static org.powermock.api.mockito.PowerMockito.when; @RunWith(PowerMockRunner.class) -@PrepareForTest({MainApp.class, SP.class, L.class, DanaRv2Plugin.class, DanaRPlugin.class, ConfigBuilderPlugin.class, CommandQueue.class}) +@PrepareForTest({MainApp.class, SP.class, L.class, ConfigBuilderPlugin.class, CommandQueue.class}) public class MsgCheckValue_v2Test { @Test public void runTest() { - AAPSMocker.mockMainApp(); - AAPSMocker.mockApplicationContext(); - AAPSMocker.mockSP(); - AAPSMocker.mockL(); - AAPSMocker.mockDanaRPlugin(); - AAPSMocker.mockConfigBuilder(); - AAPSMocker.mockCommandQueue(); Treatment t = new Treatment(); MsgCheckValue_v2 packet = new MsgCheckValue_v2(); // test message decoding @@ -55,4 +49,13 @@ public class MsgCheckValue_v2Test { return ret; } + @Before + public void mock() { + AAPSMocker.mockMainApp(); + AAPSMocker.mockApplicationContext(); + AAPSMocker.mockSP(); + AAPSMocker.mockL(); + AAPSMocker.mockConfigBuilder(); + AAPSMocker.mockCommandQueue(); + } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetHistoryEntry_v2Test.java b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetHistoryEntry_v2Test.java index 8413f296e1..d554c33e8d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetHistoryEntry_v2Test.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetHistoryEntry_v2Test.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRv2.comm; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -18,15 +19,10 @@ import static org.junit.Assert.*; */ @RunWith(PowerMockRunner.class) -@PrepareForTest({MainApp.class, SP.class, L.class, DanaRv2Plugin.class, DanaRPlugin.class}) +@PrepareForTest({MainApp.class, SP.class, L.class}) public class MsgSetHistoryEntry_v2Test { @Test public void runTest() { - AAPSMocker.mockMainApp(); - AAPSMocker.mockApplicationContext(); - AAPSMocker.mockSP(); - AAPSMocker.mockL(); - AAPSMocker.mockDanaRPlugin(); MsgSetHistoryEntry_v2 initializerTest = new MsgSetHistoryEntry_v2((byte) 1, System.currentTimeMillis(), 1, 0); MsgSetHistoryEntry_v2 packet = new MsgSetHistoryEntry_v2(); @@ -56,4 +52,11 @@ public class MsgSetHistoryEntry_v2Test { return ret; } + @Before + public void mock() { + AAPSMocker.mockMainApp(); + AAPSMocker.mockApplicationContext(); + AAPSMocker.mockSP(); + AAPSMocker.mockL(); + } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2Test.java b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2Test.java index b354fe6d49..8cb45dc5ee 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2Test.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2Test.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.pump.danaRv2.comm; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PrepareForTest; @@ -19,16 +20,10 @@ import static org.junit.Assert.*; */ @RunWith(PowerMockRunner.class) -@PrepareForTest({MainApp.class, SP.class, L.class, DanaRv2Plugin.class, DanaRPlugin.class}) +@PrepareForTest({MainApp.class, SP.class, L.class}) public class MsgStatusTempBasal_v2Test { @Test public void runTest() { - AAPSMocker.mockMainApp(); - AAPSMocker.mockApplicationContext(); - AAPSMocker.mockSP(); - AAPSMocker.mockL(); - AAPSMocker.mockDanaRPlugin(); - MsgStatusTempBasal_v2 packet = new MsgStatusTempBasal_v2(); DanaRPump pump = DanaRPump.getInstance(); // test message decoding @@ -57,4 +52,12 @@ public class MsgStatusTempBasal_v2Test { return ret; } + @Before + public void mock() { + AAPSMocker.mockMainApp(); + AAPSMocker.mockApplicationContext(); + AAPSMocker.mockSP(); + AAPSMocker.mockL(); + } + } \ No newline at end of file From 2417a57531399609c8269d24b434265598275746 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Fri, 18 Oct 2019 18:18:54 +0200 Subject: [PATCH 05/14] Recalculate IOB on insulin peak time pref change. --- .../plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java index 0cd725b5f5..67d46df22d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java @@ -164,7 +164,8 @@ public class IobCobCalculatorPlugin extends PluginBase { event.isChanged(R.string.key_openapsama_min_5m_carbimpact) || event.isChanged(R.string.key_absorption_cutoff) || event.isChanged(R.string.key_openapsama_autosens_max) || - event.isChanged(R.string.key_openapsama_autosens_min) + event.isChanged(R.string.key_openapsama_autosens_min) || + event.isChanged(R.string.key_insulin_oref_peak) ) { stopCalculation("onEventPreferenceChange"); synchronized (dataLock) { From 4eed8f7397d05054f8b8df321af1473e28c7aed3 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 21 Oct 2019 13:20:42 +0200 Subject: [PATCH 06/14] New Crowdin translations (#2125) * New translations strings.xml (French) * New translations strings.xml (French) * New translations objectives.xml (Portuguese) * New translations strings.xml (French) * New translations exam.xml (Portuguese) --- app/src/main/res/values-fr-rFR/strings.xml | 6 +++--- app/src/main/res/values-pt-rPT/exam.xml | 10 ++++++++++ app/src/main/res/values-pt-rPT/objectives.xml | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index 8bbdbd88d4..8811098fbd 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -271,7 +271,7 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Doigt Capteur Manuel - Cible temporaire + Cible temp. Annulation Cible Temporaire Paramètres du profil DanaR Durée d\'Action [h] @@ -772,13 +772,13 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S L\'administration de bolus et la vérification de l\'historique de la pompe ont échoué. Vérifiez la pompe manuellement. Si un bolus a été administré, il sera ajouté aux traitements au cours de la prochaine connexion avec la pompe. Pas assez d\'insuline dans le réservoir pour le bolus Erreur administration bolus étendu - Vue + AC-I passé(e)s %1$.2f h Activer en permanence les SMB Activer toujours SMB de manière autonome pour les bolus. Ceci est possible uniquement avec une source de glycémie ayant un très bon filtrage de données comme le G5 Activer SMB après ingestion de glucides - Activer SMB pendant 6h après ingestion de glucides, même s’il y a 0 GI (Glucides Actifs). Ceci est possible uniquement avec une source de glycémie ayant un très bon filtrage de données comme le G5 + Activer SMB pendant 6h après ingestion de glucides, même s’il y a 0 GA (Glucides Actifs). Ceci est possible uniquement avec une source de glycémie ayant un très bon filtrage de données comme le G5 Activer SMB avec les glucides Activer SMB tant que des Glucides sont actifs. Activer SMB avec les cibles temporaires diff --git a/app/src/main/res/values-pt-rPT/exam.xml b/app/src/main/res/values-pt-rPT/exam.xml index d959aea994..8e944c54a6 100644 --- a/app/src/main/res/values-pt-rPT/exam.xml +++ b/app/src/main/res/values-pt-rPT/exam.xml @@ -6,6 +6,7 @@ O valor mínimo é de 3 horas. O valor mínimo é de 5 horas. https://androidaps.readthedocs.io/en/latest/EN/Configuration/Config-Builder.html?#insulin + O significado é igual ao parâmetro DIA usado na bomba. Tópico: Alvo-Temp. Hipo O que é a razão principal para definir TT hipoglicemia? https://androidaps.readthedocs.io/en/latest/EN/Usage/temptarget.html @@ -16,14 +17,23 @@ Clique em \'Desligar bomba\' para que o AAPS saiba que nenhuma insulina está a ser entregue. https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#other-settings Tópico: Definições do AndroidAPS + Quais são as práticas recomendadas para fazer cópia de segurança das configurações? + Exportá-las localmente a partir do menu Manutenção. + Armazenar ficheiro exportado para outro local como e-mail, Dropbox, Google drive… + Exportá-los logo após a instalação do AAPS. + Exportá-los depois de fazer alterações de configuração. + Exportá-los depois de completar um objectivo. + Exportá-los quando terminar as configurações iniciais. https://androidaps.readthedocs.io/en/latest/EN/Usage/ExportImportSettings.html https://androidaps.readthedocs.io/en/latest/EN/Getting-Started/FAQ.html#what-emergency-equipment-is-recommended-to-take-with-me Tópico: Leituras Irregulares CGM O que deve ser feito se os dados do CGM são irregulares? Nada, AAPS vai lidar com isso. + Desactivar o loop para evitar sobredosagem. Substituir o sensor CGM. Desligue o telefone. https://androidaps.readthedocs.io/en/latest/EN/Usage/Smoothing-Blood-Glucose-Data-in-xDrip.html#smoothing-blood-glucose-data + Verifique que a app do CGM suaviza os dados da Glicose. Tópico: Exercício Usando o recurso de alvo-temp. Fazer uma mudança de perfil inferior a 100%. diff --git a/app/src/main/res/values-pt-rPT/objectives.xml b/app/src/main/res/values-pt-rPT/objectives.xml index 1e689ce9e0..b08cb82a54 100644 --- a/app/src/main/res/values-pt-rPT/objectives.xml +++ b/app/src/main/res/values-pt-rPT/objectives.xml @@ -17,7 +17,9 @@ Definir perfil de 90% por 10 min (pressione longo no nome de perfil na Visão Geral) Simular chuveiro. Desligar a bomba de 1h (Pressione longo em Open Loop) Mostrar conteúdo do plugin Loop + Utilizar a função de escala premindo longamente gráfico Glic Inserir + Insira o código obtido dos programadores para ignorar o resto dos objectivos Código aceite Código inválido Prove seu conhecimento From b0e180ef8aad118d56a875038c1e251eb5159a39 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 21 Oct 2019 18:03:32 +0200 Subject: [PATCH 07/14] fix automation layout --- app/src/main/res/layout/automation_fragment.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/automation_fragment.xml b/app/src/main/res/layout/automation_fragment.xml index 96cbe8862b..2f24e1b70c 100644 --- a/app/src/main/res/layout/automation_fragment.xml +++ b/app/src/main/res/layout/automation_fragment.xml @@ -12,7 +12,7 @@ android:layout_above="@+id/automation_logView" android:layout_alignParentStart="true" android:layout_alignParentTop="true" - android:layout_marginBottom="-100dp" /> + android:layout_marginBottom="15dp" /> Date: Mon, 21 Oct 2019 19:04:55 +0200 Subject: [PATCH 08/14] Confirmation on automation task delete --- .../general/automation/AutomationFragment.kt | 2 +- .../general/automation/EventListAdapter.java | 32 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt index 8b6ffb1720..728480323c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt @@ -29,7 +29,7 @@ class AutomationFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - eventListAdapter = EventListAdapter(AutomationPlugin.automationEvents, fragmentManager) + eventListAdapter = EventListAdapter(AutomationPlugin.automationEvents, fragmentManager, activity) automation_eventListView.layoutManager = LinearLayoutManager(context) automation_eventListView.adapter = eventListAdapter diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/EventListAdapter.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/EventListAdapter.java index fba54aefbd..08079a9110 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/EventListAdapter.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/EventListAdapter.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.general.automation; +import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; @@ -26,14 +27,17 @@ import info.nightscout.androidaps.plugins.general.automation.actions.Action; import info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog; import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationDataChanged; import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnector; +import info.nightscout.androidaps.utils.OKDialog; class EventListAdapter extends RecyclerView.Adapter { - private final List mEventList; - private final FragmentManager mFragmentManager; + private final List eventList; + private final FragmentManager fragmentManager; + private final Activity activity; - EventListAdapter(List events, FragmentManager fragmentManager) { - this.mEventList = events; - this.mFragmentManager = fragmentManager; + EventListAdapter(List events, FragmentManager fragmentManager, Activity activity) { + this.eventList = events; + this.fragmentManager = fragmentManager; + this.activity = activity; } @NonNull @@ -52,7 +56,7 @@ class EventListAdapter extends RecyclerView.Adapter @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { - final AutomationEvent event = mEventList.get(position); + final AutomationEvent event = eventList.get(position); holder.eventTitle.setText(event.getTitle()); holder.enabled.setChecked(event.isEnabled()); holder.iconLayout.removeAllViews(); @@ -88,10 +92,12 @@ class EventListAdapter extends RecyclerView.Adapter }); // remove event - holder.iconTrash.setOnClickListener(v -> { - mEventList.remove(event); - RxBus.INSTANCE.send(new EventAutomationDataChanged()); - }); + holder.iconTrash.setOnClickListener(v -> + OKDialog.showConfirmation(activity, MainApp.gs(R.string.removerecord) + " " + event.getTitle(), () -> { + eventList.remove(event); + RxBus.INSTANCE.send(new EventAutomationDataChanged()); + }) + ); // edit event holder.rootLayout.setOnClickListener(v -> { @@ -101,14 +107,14 @@ class EventListAdapter extends RecyclerView.Adapter args.putString("event", event.toJSON()); args.putInt("position", position); dialog.setArguments(args); - if (mFragmentManager != null) - dialog.show(mFragmentManager, "EditEventDialog"); + if (fragmentManager != null) + dialog.show(fragmentManager, "EditEventDialog"); }); } @Override public int getItemCount() { - return mEventList.size(); + return eventList.size(); } static class ViewHolder extends RecyclerView.ViewHolder { From 81e621b249d896805b4bf45c7532ef5e5f98adca Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 21 Oct 2019 21:39:19 +0200 Subject: [PATCH 09/14] 2.4-dev-j --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 06c13ce5bd..6273548f91 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,7 +109,7 @@ android { targetSdkVersion 28 multiDexEnabled true versionCode 1500 - version "2.4-dev-i" + version "2.4-dev-j" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' From 43f0fe1df983244d750e226270636630b269029d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 22 Oct 2019 08:02:28 +0200 Subject: [PATCH 10/14] MDT driver without eng mode --- .../info/nightscout/androidaps/Config.java | 9 ------- .../info/nightscout/androidaps/MainApp.java | 26 +++++++++---------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index ae0e14c9b6..bb967cdeb6 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -12,13 +12,4 @@ public class Config { public static final boolean PUMPCONTROL = BuildConfig.FLAVOR.equals("pumpcontrol"); public static final boolean PUMPDRIVERS = BuildConfig.FLAVOR.equals("full") || BuildConfig.FLAVOR.equals("pumpcontrol"); - - public static final boolean ACTION = !NSCLIENT; - public static final boolean MDI = !NSCLIENT; - public static final boolean OTHERPROFILES = !NSCLIENT; - public static final boolean SAFETY = !NSCLIENT; - - public static final boolean SMSCOMMUNICATORENABLED = !NSCLIENT; - - } diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 74d61a4c3a..0076ebc2eb 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -8,7 +8,6 @@ import android.content.res.Resources; import android.os.PowerManager; import android.os.SystemClock; -import androidx.annotation.Nullable; import androidx.annotation.PluralsRes; import androidx.localbroadcastmanager.content.LocalBroadcastManager; @@ -175,7 +174,7 @@ public class MainApp extends Application { // Register all tabs in app here pluginsList.add(OverviewPlugin.INSTANCE); pluginsList.add(IobCobCalculatorPlugin.getPlugin()); - if (Config.ACTION) pluginsList.add(ActionsPlugin.INSTANCE); + if (!Config.NSCLIENT) pluginsList.add(ActionsPlugin.INSTANCE); pluginsList.add(InsulinOrefRapidActingPlugin.getPlugin()); pluginsList.add(InsulinOrefUltraRapidActingPlugin.getPlugin()); pluginsList.add(InsulinOrefFreePeakPlugin.getPlugin()); @@ -188,25 +187,24 @@ public class MainApp extends Application { if (Config.PUMPDRIVERS) pluginsList.add(DanaRv2Plugin.getPlugin()); if (Config.PUMPDRIVERS) pluginsList.add(DanaRSPlugin.getPlugin()); if (Config.PUMPDRIVERS) pluginsList.add(LocalInsightPlugin.getPlugin()); - pluginsList.add(CareportalPlugin.getPlugin()); if (Config.PUMPDRIVERS) pluginsList.add(ComboPlugin.getPlugin()); - if (Config.PUMPDRIVERS && engineeringMode) - pluginsList.add(MedtronicPumpPlugin.getPlugin()); - if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin()); + if (Config.PUMPDRIVERS) pluginsList.add(MedtronicPumpPlugin.getPlugin()); + if (!Config.NSCLIENT) pluginsList.add(MDIPlugin.getPlugin()); pluginsList.add(VirtualPumpPlugin.getPlugin()); + pluginsList.add(CareportalPlugin.getPlugin()); if (Config.APS) pluginsList.add(LoopPlugin.getPlugin()); if (Config.APS) pluginsList.add(OpenAPSMAPlugin.getPlugin()); if (Config.APS) pluginsList.add(OpenAPSAMAPlugin.getPlugin()); if (Config.APS) pluginsList.add(OpenAPSSMBPlugin.getPlugin()); pluginsList.add(NSProfilePlugin.getPlugin()); - if (Config.OTHERPROFILES) pluginsList.add(SimpleProfilePlugin.getPlugin()); - if (Config.OTHERPROFILES) pluginsList.add(LocalProfilePlugin.getPlugin()); + if (!Config.NSCLIENT) pluginsList.add(SimpleProfilePlugin.getPlugin()); + if (!Config.NSCLIENT) pluginsList.add(LocalProfilePlugin.getPlugin()); pluginsList.add(TreatmentsPlugin.getPlugin()); - if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin()); - if (Config.SAFETY) pluginsList.add(VersionCheckerPlugin.INSTANCE); - if (Config.SAFETY) pluginsList.add(StorageConstraintPlugin.getPlugin()); - if (Config.SAFETY) pluginsList.add(SignatureVerifier.getPlugin()); - if (Config.APS) pluginsList.add(ObjectivesPlugin.INSTANCE); + if (!Config.NSCLIENT) pluginsList.add(SafetyPlugin.getPlugin()); + if (!Config.NSCLIENT) pluginsList.add(VersionCheckerPlugin.INSTANCE); + if (!Config.NSCLIENT) pluginsList.add(StorageConstraintPlugin.getPlugin()); + if (!Config.NSCLIENT) pluginsList.add(SignatureVerifier.getPlugin()); + if (!Config.APS) pluginsList.add(ObjectivesPlugin.INSTANCE); pluginsList.add(SourceXdripPlugin.getPlugin()); pluginsList.add(SourceNSClientPlugin.getPlugin()); pluginsList.add(SourceMM640gPlugin.getPlugin()); @@ -215,7 +213,7 @@ public class MainApp extends Application { pluginsList.add(SourcePoctechPlugin.getPlugin()); pluginsList.add(SourceTomatoPlugin.getPlugin()); pluginsList.add(SourceEversensePlugin.getPlugin()); - if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin()); + if (!Config.NSCLIENT) pluginsList.add(SmsCommunicatorPlugin.getPlugin()); pluginsList.add(FoodPlugin.getPlugin()); pluginsList.add(WearPlugin.initPlugin(this)); From ecbfd294a8d2fb3b2b6461ef225ec0d0e6652505 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 22 Oct 2019 15:24:37 +0200 Subject: [PATCH 11/14] send hash to firebase --- .../nightscout/androidaps/MainActivity.java | 2 +- .../info/nightscout/androidaps/MainApp.java | 6 +-- .../signatureVerifier/SignatureVerifier.java | 45 +++++++++++++++++-- .../versionChecker/VersionCheckerPlugin.kt | 2 +- .../versionChecker/VersionCheckerUtils.kt | 2 +- .../androidaps/utils/FabricPrivacy.java | 14 ++++-- .../VersionCheckerUtilsKtTest.kt | 2 +- 7 files changed, 58 insertions(+), 15 deletions(-) rename app/src/main/java/info/nightscout/androidaps/plugins/{general => constraints}/signatureVerifier/SignatureVerifier.java (78%) rename app/src/main/java/info/nightscout/androidaps/plugins/{general => constraints}/versionChecker/VersionCheckerPlugin.kt (97%) rename app/src/main/java/info/nightscout/androidaps/plugins/{general => constraints}/versionChecker/VersionCheckerUtils.kt (98%) rename app/src/test/java/info/nightscout/androidaps/plugins/{general => constraints}/versionChecker/VersionCheckerUtilsKtTest.kt (99%) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 9287921879..fdbb5569b1 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -54,7 +54,7 @@ import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; import info.nightscout.androidaps.plugins.bus.RxBus; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus; -import info.nightscout.androidaps.plugins.general.versionChecker.VersionCheckerUtilsKt; +import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtilsKt; import info.nightscout.androidaps.setupwizard.SetupWizardActivity; import info.nightscout.androidaps.tabs.TabPageAdapter; import info.nightscout.androidaps.utils.AndroidPermission; diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index a1300f59bc..037e7c86a4 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -49,9 +49,9 @@ import info.nightscout.androidaps.plugins.general.nsclient.receivers.AckAlarmRec import info.nightscout.androidaps.plugins.general.nsclient.receivers.DBAccessReceiver; import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin; import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin; -import info.nightscout.androidaps.plugins.general.signatureVerifier.SignatureVerifier; +import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifier; import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin; -import info.nightscout.androidaps.plugins.general.versionChecker.VersionCheckerPlugin; +import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerPlugin; import info.nightscout.androidaps.plugins.general.wear.WearPlugin; import info.nightscout.androidaps.plugins.general.xdripStatusline.StatuslinePlugin; import info.nightscout.androidaps.plugins.insulin.InsulinOrefFreePeakPlugin; @@ -91,7 +91,7 @@ import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.utils.FabricPrivacy; import io.fabric.sdk.android.Fabric; -import static info.nightscout.androidaps.plugins.general.versionChecker.VersionCheckerUtilsKt.triggerCheckVersion; +import static info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtilsKt.triggerCheckVersion; public class MainApp extends Application { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/signatureVerifier/SignatureVerifier.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifier.java similarity index 78% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/signatureVerifier/SignatureVerifier.java rename to app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifier.java index b0616ec35e..b5fc3d10f7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/signatureVerifier/SignatureVerifier.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifier.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.signatureVerifier; +package info.nightscout.androidaps.plugins.constraints.signatureVerifier; import android.content.pm.PackageManager; import android.content.pm.Signature; @@ -124,14 +124,51 @@ public class SignatureVerifier extends PluginBase implements ConstraintsInterfac } } } - } catch (PackageManager.NameNotFoundException e) { - log.error("Error in SignatureVerifier", e); - } catch (NoSuchAlgorithmException e) { + } catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) { log.error("Error in SignatureVerifier", e); } return false; } + public List shortHashes() { + List hashes = new ArrayList<>(); + try { + Signature[] signatures = MainApp.instance().getPackageManager().getPackageInfo(MainApp.instance().getPackageName(), PackageManager.GET_SIGNATURES).signatures; + if (signatures != null) { + for (Signature signature : signatures) { + MessageDigest digest = MessageDigest.getInstance("SHA256"); + byte[] fingerprint = digest.digest(signature.toByteArray()); + String hash = Hex.toHexString(fingerprint); + log.debug("Found signature: " + hash); + log.debug("Found signature (short): " + singleCharMap(fingerprint)); + hashes.add(singleCharMap(fingerprint)); + } + } + } catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) { + log.error("Error in SignatureVerifier", e); + } + return hashes; + } + + String map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"§$%&/()=?,.-;:_<>|°^`´\\@€*'#+~{}[]¿¡áéíóúàèìòùöäü`ÁÉÍÓÚÀÈÌÒÙÖÄÜßÆÇÊËÎÏԌ۟æçêëîïôœûÿĆČĐŠŽćđšžñΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡ\u03A2ΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϨϩϪϫϬϭϮϯϰϱϲϳϴϵ϶ϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗ"; + + private String singleCharMap(byte[] array) { + StringBuilder sb = new StringBuilder(); + for (byte b : array) { + sb.append(map.charAt(b & 0xFF)); + } + return sb.toString(); + } + + private String singleCharUnMap(String shortHash) { + byte[] array = new byte[shortHash.length()]; + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < array.length; i++) { + sb.append(String.format("%02x",(int) map.charAt(map.indexOf(shortHash.charAt(i))))); + } + return sb.toString(); + } + private boolean shouldDownloadCerts() { return System.currentTimeMillis() - SP.getLong(R.string.key_last_revoked_certs_check, 0L) >= UPDATE_INTERVAL; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerPlugin.kt similarity index 97% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt rename to app/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerPlugin.kt index bf67426787..ee267c689e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerPlugin.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.versionChecker +package info.nightscout.androidaps.plugins.constraints.versionChecker import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerUtils.kt similarity index 98% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt rename to app/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerUtils.kt index 7961b19e83..4b19e33540 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtils.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerUtils.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.versionChecker +package info.nightscout.androidaps.plugins.constraints.versionChecker import android.content.Context import android.net.ConnectivityManager diff --git a/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java b/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java index 3dd7fe4fd9..056fa1131f 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java @@ -8,10 +8,13 @@ import com.google.firebase.analytics.FirebaseAnalytics; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.List; + import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; +import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifier; /** * Created by jamorham on 21/02/2018. @@ -112,9 +115,9 @@ public class FabricPrivacy { String closedLoopEnabled = MainApp.getConstraintChecker().isClosedLoopAllowed().value() ? "CLOSED_LOOP_ENABLED" : "CLOSED_LOOP_DISABLED"; // Size is limited to 36 chars - String remote = BuildConfig.REMOTE - .replace("https://","") - .replace("http://","") + String remote = BuildConfig.REMOTE.toLowerCase() + .replace("https://", "") + .replace("http://", "") .replace(".git", "") .replace(".com/", ":") .replace(".org/", ":") @@ -125,6 +128,10 @@ public class FabricPrivacy { MainApp.getFirebaseAnalytics().setUserProperty("Version", BuildConfig.VERSION); MainApp.getFirebaseAnalytics().setUserProperty("HEAD", BuildConfig.HEAD); MainApp.getFirebaseAnalytics().setUserProperty("Remote", remote); + List hashes = SignatureVerifier.getPlugin().shortHashes(); + if (hashes.size() > 1) + MainApp.getFirebaseAnalytics().setUserProperty("Hash", hashes.get(0)); + if (ConfigBuilderPlugin.getPlugin().getActivePump() != null) MainApp.getFirebaseAnalytics().setUserProperty("Pump", ConfigBuilderPlugin.getPlugin().getActivePump().getClass().getSimpleName()); if (ConfigBuilderPlugin.getPlugin().getActiveAPS() != null) @@ -137,7 +144,6 @@ public class FabricPrivacy { MainApp.getFirebaseAnalytics().setUserProperty("Sensitivity", ConfigBuilderPlugin.getPlugin().getActiveSensitivity().getClass().getSimpleName()); if (ConfigBuilderPlugin.getPlugin().getActiveInsulin() != null) MainApp.getFirebaseAnalytics().setUserProperty("Insulin", ConfigBuilderPlugin.getPlugin().getActiveInsulin().getClass().getSimpleName()); - } } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerUtilsKtTest.kt similarity index 99% rename from app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt rename to app/src/test/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerUtilsKtTest.kt index 1b9c937c24..581f51c6d9 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/versionChecker/VersionCheckerUtilsKtTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/versionChecker/VersionCheckerUtilsKtTest.kt @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.plugins.general.versionChecker +package info.nightscout.androidaps.plugins.constraints.versionChecker import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R From 7ec0665dbf3987b07189003e84c7485a9e654f66 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 22 Oct 2019 15:51:03 +0200 Subject: [PATCH 12/14] compare fix --- .../java/info/nightscout/androidaps/utils/FabricPrivacy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java b/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java index 056fa1131f..c6d4676af7 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java @@ -129,7 +129,7 @@ public class FabricPrivacy { MainApp.getFirebaseAnalytics().setUserProperty("HEAD", BuildConfig.HEAD); MainApp.getFirebaseAnalytics().setUserProperty("Remote", remote); List hashes = SignatureVerifier.getPlugin().shortHashes(); - if (hashes.size() > 1) + if (hashes.size() >= 1) MainApp.getFirebaseAnalytics().setUserProperty("Hash", hashes.get(0)); if (ConfigBuilderPlugin.getPlugin().getActivePump() != null) From ba94d09fb4c6ca81cc73bd09deaf759d41682d52 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 22 Oct 2019 20:21:18 +0200 Subject: [PATCH 13/14] SignatureVerifier -> SignatureVerifierPlugin --- .../java/info/nightscout/androidaps/MainApp.java | 4 ++-- ...eVerifier.java => SignatureVerifierPlugin.java} | 14 +++++++------- .../nightscout/androidaps/utils/FabricPrivacy.java | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) rename app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/{SignatureVerifier.java => SignatureVerifierPlugin.java} (95%) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 27c9bcfbc3..4654c478b0 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -52,7 +52,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.receivers.AckAlarmRec import info.nightscout.androidaps.plugins.general.nsclient.receivers.DBAccessReceiver; import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin; import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin; -import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifier; +import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin; import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin; import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerPlugin; import info.nightscout.androidaps.plugins.general.wear.WearPlugin; @@ -203,7 +203,7 @@ public class MainApp extends Application { if (!Config.NSCLIENT) pluginsList.add(SafetyPlugin.getPlugin()); if (!Config.NSCLIENT) pluginsList.add(VersionCheckerPlugin.INSTANCE); if (!Config.NSCLIENT) pluginsList.add(StorageConstraintPlugin.getPlugin()); - if (!Config.NSCLIENT) pluginsList.add(SignatureVerifier.getPlugin()); + if (!Config.NSCLIENT) pluginsList.add(SignatureVerifierPlugin.getPlugin()); if (!Config.APS) pluginsList.add(ObjectivesPlugin.INSTANCE); pluginsList.add(SourceXdripPlugin.getPlugin()); pluginsList.add(SourceNSClientPlugin.getPlugin()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifier.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifierPlugin.java similarity index 95% rename from app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifier.java rename to app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifierPlugin.java index b5fc3d10f7..89dbb56ca5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifier.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/signatureVerifier/SignatureVerifierPlugin.java @@ -42,23 +42,23 @@ import info.nightscout.androidaps.utils.SP; * In case someone decides to leak a ready-to-use APK nonetheless, we can still disable it. * Self-compiled APKs with privately held certificates cannot and will not be disabled. */ -public class SignatureVerifier extends PluginBase implements ConstraintsInterface { +public class SignatureVerifierPlugin extends PluginBase implements ConstraintsInterface { private static final String REVOKED_CERTS_URL = "https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/src/main/assets/revoked_certs.txt"; private static final long UPDATE_INTERVAL = TimeUnit.DAYS.toMillis(1); - private static SignatureVerifier plugin = new SignatureVerifier(); + private static SignatureVerifierPlugin plugin = new SignatureVerifierPlugin(); private Logger log = LoggerFactory.getLogger(L.CORE); private final Object $lock = new Object[0]; private File revokedCertsFile; private List revokedCerts; - public static SignatureVerifier getPlugin() { + public static SignatureVerifierPlugin getPlugin() { return plugin; } - private SignatureVerifier() { + private SignatureVerifierPlugin() { super(new PluginDescription() .mainType(PluginType.CONSTRAINTS) .neverVisible(true) @@ -125,7 +125,7 @@ public class SignatureVerifier extends PluginBase implements ConstraintsInterfac } } } catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) { - log.error("Error in SignatureVerifier", e); + log.error("Error in SignatureVerifierPlugin", e); } return false; } @@ -145,7 +145,7 @@ public class SignatureVerifier extends PluginBase implements ConstraintsInterfac } } } catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) { - log.error("Error in SignatureVerifier", e); + log.error("Error in SignatureVerifierPlugin", e); } return hashes; } @@ -190,7 +190,7 @@ public class SignatureVerifier extends PluginBase implements ConstraintsInterfac this.revokedCerts = parseRevokedCertsFile(revokedCerts); } } catch (IOException e) { - log.error("Error in SignatureVerifier", e); + log.error("Error in SignatureVerifierPlugin", e); } } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java b/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java index c6d4676af7..07a31a3b05 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/FabricPrivacy.java @@ -14,7 +14,7 @@ import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; -import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifier; +import info.nightscout.androidaps.plugins.constraints.signatureVerifier.SignatureVerifierPlugin; /** * Created by jamorham on 21/02/2018. @@ -128,7 +128,7 @@ public class FabricPrivacy { MainApp.getFirebaseAnalytics().setUserProperty("Version", BuildConfig.VERSION); MainApp.getFirebaseAnalytics().setUserProperty("HEAD", BuildConfig.HEAD); MainApp.getFirebaseAnalytics().setUserProperty("Remote", remote); - List hashes = SignatureVerifier.getPlugin().shortHashes(); + List hashes = SignatureVerifierPlugin.getPlugin().shortHashes(); if (hashes.size() >= 1) MainApp.getFirebaseAnalytics().setUserProperty("Hash", hashes.get(0)); From 688218fa40eb833bb9073b732b437c1015bb8109 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 22 Oct 2019 23:01:38 +0200 Subject: [PATCH 14/14] Revert move wakelock to MainApp --- .../nightscout/androidaps/MainActivity.java | 27 +++++++++++++- .../info/nightscout/androidaps/MainApp.java | 37 ------------------- 2 files changed, 26 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 0401a25c86..f250df0580 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -14,6 +14,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; +import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.LinearLayout; @@ -43,6 +44,7 @@ import info.nightscout.androidaps.activities.PreferencesActivity; import info.nightscout.androidaps.activities.SingleFragmentActivity; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.events.EventAppExit; +import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRebuildTabs; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginType; @@ -50,8 +52,8 @@ import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; import info.nightscout.androidaps.plugins.bus.RxBus; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; -import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus; import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtilsKt; +import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus; import info.nightscout.androidaps.setupwizard.SetupWizardActivity; import info.nightscout.androidaps.tabs.TabPageAdapter; import info.nightscout.androidaps.utils.AndroidPermission; @@ -89,6 +91,9 @@ public class MainActivity extends NoSplashAppCompatActivity { drawerLayout.addDrawerListener(actionBarDrawerToggle); actionBarDrawerToggle.syncState(); + // initialize screen wake lock + processPreferenceChange(new EventPreferenceChange(R.string.key_keep_screen_on)); + doMigrations(); final ViewPager viewPager = findViewById(R.id.pager); @@ -146,8 +151,15 @@ public class MainActivity extends NoSplashAppCompatActivity { setupTabs(); setupViews(); } + setWakeLock(); }, FabricPrivacy::logException) ); + disposable.add(RxBus.INSTANCE + .toObservable(EventPreferenceChange.class) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(this::processPreferenceChange, FabricPrivacy::logException) + ); + if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) { Intent intent = new Intent(this, SetupWizardActivity.class); startActivity(intent); @@ -169,6 +181,19 @@ public class MainActivity extends NoSplashAppCompatActivity { disposable.clear(); } + private void setWakeLock() { + boolean keepScreenOn = SP.getBoolean(R.string.key_keep_screen_on, false); + if (keepScreenOn) + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + else + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } + + public void processPreferenceChange(final EventPreferenceChange ev) { + if (ev.isChanged(R.string.key_keep_screen_on)) + setWakeLock(); + } + private void setupViews() { TabPageAdapter pageAdapter = new TabPageAdapter(getSupportFragmentManager(), this); NavigationView navigationView = findViewById(R.id.navigation_view); diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 4654c478b0..049f07dccb 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -2,10 +2,8 @@ package info.nightscout.androidaps; import android.app.Application; import android.content.BroadcastReceiver; -import android.content.Context; import android.content.IntentFilter; import android.content.res.Resources; -import android.os.PowerManager; import android.os.SystemClock; import androidx.annotation.PluralsRes; @@ -25,7 +23,6 @@ import java.util.ArrayList; import info.nightscout.androidaps.data.ConstraintChecker; import info.nightscout.androidaps.db.DatabaseHelper; -import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PumpInterface; @@ -34,7 +31,6 @@ import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin; import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin; -import info.nightscout.androidaps.plugins.bus.RxBus; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.constraints.dstHelper.DstHelperPlugin; import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin; @@ -92,20 +88,13 @@ import info.nightscout.androidaps.receivers.NSAlarmReceiver; import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver; import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.utils.FabricPrivacy; -import info.nightscout.androidaps.utils.SP; import io.fabric.sdk.android.Fabric; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.CompositeDisposable; import static info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtilsKt.triggerCheckVersion; public class MainApp extends Application { private static Logger log = LoggerFactory.getLogger(L.CORE); - private CompositeDisposable disposable = new CompositeDisposable(); - - private PowerManager.WakeLock mWakeLock; - private static KeepAliveReceiver keepAliveReceiver; private static MainApp sInstance; @@ -242,15 +231,6 @@ public class MainApp extends Application { startKeepAliveService(); }).start(); } - - // initialize screen wake lock - processPreferenceChange(new EventPreferenceChange(R.string.key_keep_screen_on)); - - disposable.add(RxBus.INSTANCE - .toObservable(EventPreferenceChange.class) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(this::processPreferenceChange, FabricPrivacy::logException) - ); } private void registerLocalBroadcastReceiver() { @@ -336,21 +316,6 @@ public class MainApp extends Application { return sConstraintsChecker; } - public void processPreferenceChange(final EventPreferenceChange ev) { - if (ev.isChanged(R.string.key_keep_screen_on)) { - boolean keepScreenOn = SP.getBoolean(R.string.key_keep_screen_on, false); - final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); - if (keepScreenOn) { - mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "AndroidAPS:MainApp_processPreferenceChange"); - if (!mWakeLock.isHeld()) - mWakeLock.acquire(); - } else { - if (mWakeLock != null && mWakeLock.isHeld()) - mWakeLock.release(); - } - } - } - public static ArrayList getPluginsList() { return pluginsList; } @@ -459,8 +424,6 @@ public class MainApp extends Application { unregisterReceiver(timeDateOrTZChangeReceiver); } - if (mWakeLock != null && mWakeLock.isHeld()) - mWakeLock.release(); } public static int dpToPx(int dp) {