From 738c3585d5c0fa489f682ebd3c995b76388fc6f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Feb 2021 10:34:35 +0000 Subject: [PATCH 01/36] Bump wearableVersion from 2.4.0 to 2.8.1 Bumps `wearableVersion` from 2.4.0 to 2.8.1. Updates `wearable` from 2.4.0 to 2.8.1 Updates `wearable` from 2.4.0 to 2.8.1 Signed-off-by: dependabot[bot] --- wear/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wear/build.gradle b/wear/build.gradle index a5a93a3530..88bfa0bf24 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -19,7 +19,7 @@ jacoco { } ext { - wearableVersion = "2.4.0" + wearableVersion = "2.8.1" playServicesWearable = "17.0.0" } From 9673a3cc90c5c4d951de004c10efe7151a36ffa7 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 11 Feb 2021 22:27:22 +0100 Subject: [PATCH 02/36] dagger update --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8c16ccbc80..31ed55f757 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { rxkotlin_version = '2.4.0' room_version = '2.2.6' lifecycle_version = '2.3.0' - dagger_version = '2.31.2' + dagger_version = '2.32' coroutinesVersion = '1.4.1' activityVersion = '1.2.0' fragmentktx_version = '1.3.0-rc01' From 2eb84e7471ab3c922ddbe5f5f02abb97991803d3 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 11 Feb 2021 22:31:18 +0100 Subject: [PATCH 03/36] fragment & nav lib update --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 31ed55f757..8b20509a2f 100644 --- a/build.gradle +++ b/build.gradle @@ -12,9 +12,9 @@ buildscript { dagger_version = '2.32' coroutinesVersion = '1.4.1' activityVersion = '1.2.0' - fragmentktx_version = '1.3.0-rc01' + fragmentktx_version = '1.3.0-rc02' ormLiteVersion = '4.46' - nav_version = '2.3.2' + nav_version = '2.3.3' appcompat_version = '1.2.0' material_version = '1.2.1' constraintlayout_version = '2.0.4' From 4bdc67cac711eccc147fe0779232254ffe548e4e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 11 Feb 2021 22:40:55 +0100 Subject: [PATCH 04/36] material lib update --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8b20509a2f..fa16a53f76 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ buildscript { ormLiteVersion = '4.46' nav_version = '2.3.3' appcompat_version = '1.2.0' - material_version = '1.2.1' + material_version = '1.3.0' constraintlayout_version = '2.0.4' preferencektx_version = '1.1.1' commonslang3_version = '3.11' From 7a8de9221b77a68f2d98d6c1d2e5e4cc445440bf Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 11 Feb 2021 23:17:22 +0100 Subject: [PATCH 05/36] fix tests --- .../androidaps/interfaces/ConstraintsCheckerTest.kt | 4 +++- .../plugins/configBuilder/ConfigBuilderPluginTest.kt | 4 +++- .../plugins/constraints/objectives/ObjectivesPluginTest.kt | 4 +++- .../general/smsCommunicator/SmsCommunicatorPluginTest.kt | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt index a1a9fa796e..48ebe49bc8 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt @@ -22,6 +22,7 @@ import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.danar.DanaRPlugin import info.nightscout.androidaps.danars.DanaRSPlugin +import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin @@ -61,6 +62,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { @Mock lateinit var profiler: Profiler @Mock lateinit var nsUpload: NSUpload @Mock lateinit var uploadQueue: UploadQueue + @Mock lateinit var uel: UserEntryLogger private var buildHelper = BuildHelper(Config()) lateinit var danaPump: DanaPump @@ -115,7 +117,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { danaPump = DanaPump(aapsLogger, sp, injector) hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context, nsUpload) - objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, Config()) + objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, Config(), uel) comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, resourceHelper, profileFunction, treatmentsPlugin, sp, commandQueue, context) danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy) danaRSPlugin = DanaRSPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPluginTest.kt index 4e7fc5e9cc..aa21e0a2bf 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPluginTest.kt @@ -6,6 +6,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider +import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin @@ -27,6 +28,7 @@ class ConfigBuilderPluginTest : TestBase() { @Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var commandQueue: CommandQueueProvider @Mock lateinit var activePlugin: ActivePluginProvider + @Mock lateinit var uel: UserEntryLogger private lateinit var configBuilderPlugin: ConfigBuilderPlugin @@ -43,6 +45,6 @@ class ConfigBuilderPluginTest : TestBase() { @Before fun prepareMock() { - configBuilderPlugin = ConfigBuilderPlugin(injector, aapsLogger, resourceHelper, sp, RxBusWrapper(aapsSchedulers), activePlugin) + configBuilderPlugin = ConfigBuilderPlugin(injector, aapsLogger, resourceHelper, sp, RxBusWrapper(aapsSchedulers), activePlugin, uel) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt index a0cd07823e..bf0075e992 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt @@ -7,6 +7,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.Constraint +import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -25,6 +26,7 @@ class ObjectivesPluginTest : TestBase() { @Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var activePlugin: ActivePluginProvider @Mock lateinit var sp: SP + @Mock lateinit var uel: UserEntryLogger private lateinit var objectivesPlugin: ObjectivesPlugin @@ -38,7 +40,7 @@ class ObjectivesPluginTest : TestBase() { } @Before fun prepareMock() { - objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, Config()) + objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, Config(), uel) objectivesPlugin.onStart() `when`(resourceHelper.gs(R.string.objectivenotstarted)).thenReturn("Objective %1\$d not started") } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index 6c8339a650..e650f9ff71 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt @@ -16,6 +16,7 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PumpDescription +import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePassword @@ -65,6 +66,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { @Mock lateinit var treatmentService: TreatmentService @Mock lateinit var otp: OneTimePassword @Mock lateinit var xdripCalibrations: XdripCalibrations + @Mock lateinit var uel: UserEntryLogger var injector: HasAndroidInjector = HasAndroidInjector { AndroidInjector { @@ -104,7 +106,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { `when`(SmsManager.getDefault()).thenReturn(smsManager) `when`(sp.getString(R.string.key_smscommunicator_allowednumbers, "")).thenReturn("1234;5678") - smsCommunicatorPlugin = SmsCommunicatorPlugin(injector, aapsLogger, resourceHelper, aapsSchedulers, sp, constraintChecker, rxBus, profileFunction, fabricPrivacy, activePlugin, commandQueue, loopPlugin, iobCobCalculatorPlugin, xdripCalibrations, otp, Config(), DateUtil(context)) + smsCommunicatorPlugin = SmsCommunicatorPlugin(injector, aapsLogger, resourceHelper, aapsSchedulers, sp, constraintChecker, rxBus, profileFunction, fabricPrivacy, activePlugin, commandQueue, loopPlugin, iobCobCalculatorPlugin, xdripCalibrations, otp, Config(), DateUtil(context), uel) smsCommunicatorPlugin.setPluginEnabled(PluginType.GENERAL, true) Mockito.doAnswer { invocation: InvocationOnMock -> val callback = invocation.getArgument(1) From d1a647830f72d63052822122a5f53370eb6efe62 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 11 Feb 2021 23:33:22 +0100 Subject: [PATCH 06/36] update mockito --- app/build.gradle | 2 +- app/jacoco.exec | Bin 0 -> 82546 bytes .../interfaces/ConstraintsCheckerTest.kt | 8 ++++---- .../configBuilder/ConfigBuilderPluginTest.kt | 2 ++ .../objectives/ObjectivesPluginTest.kt | 2 ++ .../maintenance/ClassicPrefsFormatTest.kt | 5 +++-- .../maintenance/EncryptedPrefsFormatTest.kt | 4 +++- .../SmsCommunicatorPluginTest.kt | 2 +- build.gradle | 2 +- 9 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 app/jacoco.exec diff --git a/app/build.gradle b/app/build.gradle index 7f2c67e5d3..f95f2ddc9b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -258,7 +258,7 @@ dependencies { testImplementation "org.skyscreamer:jsonassert:1.5.0" testImplementation "org.hamcrest:hamcrest-all:1.3" - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0-alpha03' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0-alpha04' androidTestImplementation "androidx.test.ext:junit:$androidx_junit" androidTestImplementation "androidx.test:rules:$androidx_rules" diff --git a/app/jacoco.exec b/app/jacoco.exec new file mode 100644 index 0000000000000000000000000000000000000000..1622861d3aaa3e9d1c3d9a04de71580b928cc274 GIT binary patch literal 82546 zcmeHQ349aP_MS9_7AS3pMG$GrQe_j;4GK~zr3FDKOIsE}3DacSM$#lqlG3u+f*{NL z`&fJ^;_^@w5fH>GJGQcjAXxCBphc((4^*HCCiY5rv)R%hi?9aaTu{S0sE-gHtbA0PM zqLaatVb+)onOQcg&TO}7D3hKs8}yXLsxg`~GYzIp&9F2ovy;Q&D0zrHL!`BOal@E? zM5M&OqjPAJ&8iuQUcwX2*%r!VFq?eTO{Q(y6gtO1Pt`sFZ%5j*E!renr%j=326NEXndGv(kPB-!g{~qZB+hLx*=Qz% z($Q8;qS<7%F%*2#dy$$TDnkhJJhQTEQQwG5M4ZGa*vsRtF4>wnz-+WzQ*9Ju8*8v- zrCMlO-_#LC9`M_<_?^{`RYWg|Gl?!{q|pvfdH`jm!{KB$+E-1U+SK65PcCH5sq6hz zpCXH>KH621ADA0Hsb2S5h~$uo?~1lssZ1JO%+N46Q(N|IWL0ka$`6_IlO%6RJn|`Y z218r3M&!^88n#9!RAg-H=FQI!n)v!~lu2iAHIN$!a$m zOhbf86wZH;mS>?!$3}v@+H#D&N9Ko}>imqj`JHFdp;5P6eFMm=0oVMR>JA)|Tp|{B zx>z-tw25XYqsGiXV~xpdGh`TaXib=`n&G0~0w{uf>)O(XUpSYxgou*3Uo;cgb%&Oi z%j!MYFYTur4@Zt7#<=xQfGsmsmqqLCMw+qu<&vu}^bLRd#EwUa*t%UCXTg(btBx^P z(1IXO=M&^RgWmOhb;(5&F+$=j!qm9KAczg}aC)lPB7m`Zd~IsF{(I_C4>ml0Z6#3# zV;*n*e1piaVOyU1zsGi$6CETjl6zWd!Jqk%XY*R+>z8yIO*}5~|JOF~F5~o6;hEee zukLN*_Dqa(&mLkj*kJcJaW;1Z`>31dhmn^iCV&0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R^Vl}pQ;W(-*>bHIlu5=@+hnRK65)z_z zFdmTicoWP?Vgs=dV@U=6FaRqnh#1?OY;|DQ=3Rfz)Ohf~z+R#vF)OR`*BV28M!!xf zGJeagE^cy1Vw=qmTB_Y@p-p-iHRUxPm?|??omg~p%h1#lZawvCQb5frt(>TVT!ogy z5vI_GhU_T@?OJ3OWfpj#e@YYw1zZr<(e@{57I;c z$FKNTu%s@Bs}I7@XO>hr81%1UM#mivZuZ{bz1`gsc<=CJ5_C3buEorbtU z()gk|JIDncms_4$d9+Zn5o)bqMH19upk5ZKhG}%T_!rhBs#N6H7Y7_`Q2I?rNs9bk zX8^0945P1*0nIG}e5_?0Wi(F}p2=PE>fSaUOla3)GY-aR3MG^{D{^q^`oLq)C9#zF z;K{I~xy~LXi$ciP78LGY9}wEogZRVs`LodoTg8a2!M7l`z+R-#;Jbd*4at}CMUw!7 zln%JFN*e>A!Y&-?blCil{+fMwL%>zL{Mm!5&459R4%nb4R9;%-SpTBRgW|A}iAX#J z)hjoQ!`XSfOj!$}Xt*ICvRSLkk6(LZ$1%5lU-fqFy1Gy)En7Q;RjM+8E#Db>{kJmp zo8wJxan$OI123QTMtC=ZBq~)HYR7O?eko=SU@6eTgUG|w0j%Kd;it578uj~yctnDo z$fd7R%yyGL5Sk9jK=IMabAR-&@xPFMd(UkArOg;0Vvxku3BHoSoUVaCiSQp~)Y*-c z&CF;L>^AV2Ox6_I3XNQv0KF2IzEF(WL4V9RnN@!Jg9|gL>>>u IC}pGmf7L!hlK=n! literal 0 HcmV?d00001 diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt index 48ebe49bc8..7af1bb33b2 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt @@ -8,6 +8,9 @@ import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.dana.DanaPump +import info.nightscout.androidaps.danar.DanaRPlugin +import info.nightscout.androidaps.danars.DanaRSPlugin +import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin @@ -20,9 +23,6 @@ import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.pump.combo.ComboPlugin import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage -import info.nightscout.androidaps.danar.DanaRPlugin -import info.nightscout.androidaps.danars.DanaRSPlugin -import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin @@ -47,7 +47,7 @@ import java.util.* * Created by mike on 18.03.2018. */ @RunWith(PowerMockRunner::class) -@PrepareForTest(MainApp::class, ConfigBuilderPlugin::class, ConstraintChecker::class, SP::class, Context::class, OpenAPSAMAPlugin::class, OpenAPSSMBPlugin::class, TreatmentsPlugin::class, TreatmentService::class, VirtualPumpPlugin::class, DetailedBolusInfoStorage::class, GlimpPlugin::class, Profiler::class) +@PrepareForTest(MainApp::class, ConfigBuilderPlugin::class, ConstraintChecker::class, SP::class, Context::class, OpenAPSAMAPlugin::class, OpenAPSSMBPlugin::class, TreatmentsPlugin::class, TreatmentService::class, VirtualPumpPlugin::class, DetailedBolusInfoStorage::class, GlimpPlugin::class, Profiler::class, UserEntryLogger::class) class ConstraintsCheckerTest : TestBaseWithProfile() { @Mock lateinit var activePlugin: ActivePluginProvider diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPluginTest.kt index aa21e0a2bf..7a85c0284e 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPluginTest.kt @@ -16,9 +16,11 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock +import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) +@PrepareForTest(UserEntryLogger::class) class ConfigBuilderPluginTest : TestBase() { @Mock lateinit var virtualPumpPlugin: Lazy diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt index bf0075e992..8c4f0bac87 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt @@ -18,8 +18,10 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.Mockito.`when` +import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner +@PrepareForTest(UserEntryLogger::class) @RunWith(PowerMockRunner::class) class ObjectivesPluginTest : TestBase() { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/ClassicPrefsFormatTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/ClassicPrefsFormatTest.kt index f0a5c07491..2e27046f5b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/ClassicPrefsFormatTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/ClassicPrefsFormatTest.kt @@ -11,7 +11,6 @@ import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock -import org.mockito.Mockito import org.mockito.Mockito.`when` import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @@ -24,6 +23,7 @@ class ClassicPrefsFormatTest : TestBase() { @Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var sp: SP + @Mock lateinit var file: MockedFile @Test fun preferenceLoadingTest() { @@ -53,8 +53,9 @@ class ClassicPrefsFormatTest : TestBase() { classicFormat.savePreferences(getMockedFile(), prefs) } + class MockedFile(s: String) : File(s) + private fun getMockedFile(): File { - val file = Mockito.mock(File::class.java) `when`(file.exists()).thenReturn(true) `when`(file.canRead()).thenReturn(true) `when`(file.canWrite()).thenReturn(true) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/EncryptedPrefsFormatTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/EncryptedPrefsFormatTest.kt index fa52651e50..5438f15eac 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/EncryptedPrefsFormatTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/maintenance/EncryptedPrefsFormatTest.kt @@ -28,6 +28,7 @@ class EncryptedPrefsFormatTest : TestBase() { @Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var sp: SP + @Mock lateinit var file: MockedFile private var cryptoUtil: CryptoUtil = CryptoUtil(aapsLogger) @@ -228,8 +229,9 @@ class EncryptedPrefsFormatTest : TestBase() { encryptedFormat.loadPreferences(getMockedFile(), "sikret") } + class MockedFile(s: String) : File(s) + private fun getMockedFile(): File { - val file = Mockito.mock(File::class.java) Mockito.`when`(file.exists()).thenReturn(true) Mockito.`when`(file.canRead()).thenReturn(true) Mockito.`when`(file.canWrite()).thenReturn(true) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index e650f9ff71..ab55ab89c5 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt @@ -51,7 +51,7 @@ import org.powermock.modules.junit4.PowerMockRunner import java.util.* @RunWith(PowerMockRunner::class) -@PrepareForTest(ConstraintChecker::class, FabricPrivacy::class, VirtualPumpPlugin::class, XdripCalibrations::class, SmsManager::class, CommandQueue::class, LocalProfilePlugin::class, DateUtil::class, IobCobCalculatorPlugin::class, OneTimePassword::class) +@PrepareForTest(ConstraintChecker::class, FabricPrivacy::class, VirtualPumpPlugin::class, XdripCalibrations::class, SmsManager::class, CommandQueue::class, LocalProfilePlugin::class, DateUtil::class, IobCobCalculatorPlugin::class, OneTimePassword::class, UserEntryLogger::class) class SmsCommunicatorPluginTest : TestBaseWithProfile() { @Mock lateinit var context: Context diff --git a/build.gradle b/build.gradle index fa16a53f76..61aeae6ce4 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ buildscript { work_version = '2.5.0' junit_version = '4.13.1' - mockitoVersion = '2.8.47' + mockitoVersion = '3.7.7' powermockVersion = '2.0.9' dexmakerVersion = "1.2" retrofit2Version = '2.9.0' From 7acaf8a7e67fab5df8139f5be52c55080f3eae49 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 11 Feb 2021 23:42:40 +0100 Subject: [PATCH 07/36] accept NSProfile as bundle --- .../androidaps/plugins/profile/ns/NSProfilePlugin.kt | 7 ++++++- .../info/nightscout/androidaps/receivers/DataReceiver.kt | 4 +--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt index a47e53afe1..5109f6811c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt @@ -17,6 +17,8 @@ import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart import info.nightscout.androidaps.plugins.profile.ns.events.EventNSProfileUpdateGUI +import info.nightscout.androidaps.receivers.BundleStore +import info.nightscout.androidaps.receivers.DataReceiver import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import org.json.JSONObject @@ -87,13 +89,16 @@ class NSProfilePlugin @Inject constructor( @Inject lateinit var nsProfilePlugin: NSProfilePlugin @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var bundleStore: BundleStore init { (context.applicationContext as HasAndroidInjector).androidInjector().inject(this) } override fun doWork(): Result { - inputData.getString("profile")?.let { profileString -> + val bundle = bundleStore.pickup(inputData.getLong(DataReceiver.STORE_KEY, -1)) + ?: return Result.failure() + bundle.getString("profile")?.let { profileString -> nsProfilePlugin.profile = ProfileStore(injector, JSONObject(profileString)) nsProfilePlugin.storeNSProfile() if (nsProfilePlugin.isEnabled()) { diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.kt b/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.kt index e764f35b2d..3d4d04dbf7 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/DataReceiver.kt @@ -61,9 +61,7 @@ open class DataReceiver : DaggerBroadcastReceiver() { }.build()).build() Intents.ACTION_NEW_PROFILE -> OneTimeWorkRequest.Builder(NSProfilePlugin.NSProfileWorker::class.java) - .setInputData(Data.Builder().also { - it.copyString("profile", bundle, null) - }.build()).build() + .setInputData(bundleInputData(bundle, intent)).build() Intents.ACTION_NEW_SGV -> OneTimeWorkRequest.Builder(NSClientSourcePlugin.NSClientSourceWorker::class.java) .setInputData(Data.Builder().also { From d1ba6dda7322711b1ffc809296fd6197e3dea695 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 11 Feb 2021 23:57:11 +0100 Subject: [PATCH 08/36] 2.8.2.1-dev-a --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index f95f2ddc9b..5df54d7711 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -117,7 +117,7 @@ android { targetSdkVersion 28 multiDexEnabled true versionCode 1500 - version "2.8.2.1-dev" + version "2.8.2.1-dev-a" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' From ab9c533ff3e367f507433b36616485c92997b7d5 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 01:38:43 +0100 Subject: [PATCH 09/36] Fix crash of charts if no bg data exists in mg/dl --- .../androidaps/plugins/general/overview/graphData/GraphData.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt index d99334b74b..ae0d64e5b0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt @@ -66,7 +66,7 @@ class GraphData( bgReadingsArray = iobCobCalculatorPlugin.bgReadings if (bgReadingsArray?.isEmpty() != false) { aapsLogger.debug("No BG data.") - maxY = 10.0 + maxY = if (units == Constants.MGDL) 180.0 else 10.0 minY = 0.0 return } From 6203e214d228c041c1af796e08eed98c7d96f3ef Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 16:01:47 +0100 Subject: [PATCH 10/36] db migration quick fix: rather lose data than crash-loop --- .../info/nightscout/androidaps/database/AppDatabase.kt | 9 ++++----- .../nightscout/androidaps/database/DatabaseModule.kt | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/database/src/main/java/info/nightscout/androidaps/database/AppDatabase.kt b/database/src/main/java/info/nightscout/androidaps/database/AppDatabase.kt index 5a943b6310..f2cf4c1f7e 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/AppDatabase.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/AppDatabase.kt @@ -6,14 +6,13 @@ import androidx.room.TypeConverters import info.nightscout.androidaps.database.daos.* import info.nightscout.androidaps.database.entities.* -const val DATABASE_VERSION = 2 +const val DATABASE_VERSION = 3 @Database(version = DATABASE_VERSION, - entities = arrayOf(APSResult::class, Bolus::class, BolusCalculatorResult::class, Carbs::class, + entities = [APSResult::class, Bolus::class, BolusCalculatorResult::class, Carbs::class, EffectiveProfileSwitch::class, ExtendedBolus::class, GlucoseValue::class, ProfileSwitch::class, - TemporaryBasal::class, TemporaryTarget::class, TherapyEvent::class, TotalDailyDose::class, - APSResultLink::class, MealLink::class, MultiwaveBolusLink::class, PreferenceChange::class, - VersionChange::class, UserEntry::class), + TemporaryBasal::class, TemporaryTarget::class, TherapyEvent::class, TotalDailyDose::class, APSResultLink::class, + MealLink::class, MultiwaveBolusLink::class, PreferenceChange::class, VersionChange::class, UserEntry::class], exportSchema = true) @TypeConverters(Converters::class) internal abstract class AppDatabase : RoomDatabase() { diff --git a/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt b/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt index 9ef0b9e0ab..b36e16ff5d 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt @@ -22,6 +22,7 @@ open class DatabaseModule { Room .databaseBuilder(context, AppDatabase::class.java, fileName) .addMigrations(migration1to2) + .fallbackToDestructiveMigration() .build() @Qualifier From c7e261d0e6686c0e7e431d254c2081973e7e88f2 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 18:30:35 +0100 Subject: [PATCH 11/36] weekday picker working without view --- .../automation/elements/InputWeekDay.kt | 21 +++--- .../androidaps/utils/ui/WeekdayPicker.kt | 68 +++++++++++++++++ .../src/main/res/color/weekday_background.xml | 5 ++ .../src/main/res/color/weekend_background.xml | 5 ++ .../drawable/weekday_circle_brackground.xml | 7 ++ core/src/main/res/layout/weekday_picker.xml | 74 +++++++++++++++++++ core/src/main/res/values/colors.xml | 5 ++ core/src/main/res/values/strings.xml | 9 +++ 8 files changed, 182 insertions(+), 12 deletions(-) create mode 100644 core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt create mode 100644 core/src/main/res/color/weekday_background.xml create mode 100644 core/src/main/res/color/weekend_background.xml create mode 100644 core/src/main/res/drawable/weekday_circle_brackground.xml create mode 100644 core/src/main/res/layout/weekday_picker.xml diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt index 1f2531d95b..dda616de14 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt @@ -1,12 +1,10 @@ package info.nightscout.androidaps.plugins.general.automation.elements -import android.view.View -import android.view.ViewGroup import android.widget.LinearLayout import androidx.annotation.StringRes -import com.dpro.widgets.WeekdaysPicker import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R +import info.nightscout.androidaps.utils.ui.WeekdayPicker import java.util.* class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { @@ -22,6 +20,7 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { get() = shortNames[ordinal] companion object { + private val calendarInts = intArrayOf( Calendar.MONDAY, Calendar.TUESDAY, @@ -56,7 +55,7 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { for (day in DayOfWeek.values()) set(day, false) } - fun setAll(value:Boolean) { + fun setAll(value: Boolean) { for (day in DayOfWeek.values()) set(day, value) } @@ -78,13 +77,11 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { } override fun addToLayout(root: LinearLayout) { - val weekdaysPicker = WeekdaysPicker(root.context) - weekdaysPicker.setEditable(true) - weekdaysPicker.selectedDays = getSelectedDays() - weekdaysPicker.setOnWeekdaysChangeListener { _: View?, i: Int, list: List -> set(DayOfWeek.fromCalendarInt(i), list.contains(i)) } - weekdaysPicker.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) - weekdaysPicker.sundayFirstDay = Calendar.getInstance().firstDayOfWeek == Calendar.SUNDAY - weekdaysPicker.redrawDays() - root.addView(weekdaysPicker) + WeekdayPicker(root.context).apply { + setSelectedDays(getSelectedDays()) + setOnWeekdaysChangeListener { i: Int, selected: Boolean -> set(DayOfWeek.fromCalendarInt(i), selected) } + root.addView(this) + } + // TODO: remove library and dependency statement } } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt new file mode 100644 index 0000000000..0ac104a070 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt @@ -0,0 +1,68 @@ +package info.nightscout.androidaps.utils.ui + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.Checkable +import android.widget.LinearLayout +import androidx.appcompat.widget.AppCompatCheckedTextView +import info.nightscout.androidaps.core.databinding.WeekdayPickerBinding +import info.nightscout.androidaps.utils.extensions.toVisibility +import java.util.* + +class WeekdayPicker @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 +) : LinearLayout(context, attrs, defStyleAttr) { + + private var changeListener: ((Int, Boolean) -> Unit)? = null + + private var binding: WeekdayPickerBinding + + init { + val inflater = LayoutInflater.from(context) + binding = WeekdayPickerBinding.inflate(inflater, this, true) + determineBeginOfWeek() + setupClickListeners() + } + + private fun determineBeginOfWeek() { + (Calendar.getInstance().firstDayOfWeek == Calendar.SUNDAY).let { + binding.weekdayPickerSundayStart.visibility = it.toVisibility() + binding.weekdayPickerSundayEnd.visibility = it.not().toVisibility() + } + } + + fun setSelectedDays(list: List) { + binding.weekdayPickerSundayStart.isChecked = list.contains(Calendar.SUNDAY) + binding.weekdayPickerSundayEnd.isChecked = list.contains(Calendar.SUNDAY) + binding.weekdayPickerMonday.isChecked = list.contains(Calendar.MONDAY) + binding.weekdayPickerTuesday.isChecked = list.contains(Calendar.TUESDAY) + binding.weekdayPickerWednesday.isChecked = list.contains(Calendar.WEDNESDAY) + binding.weekdayPickerThursday.isChecked = list.contains(Calendar.THURSDAY) + binding.weekdayPickerFriday.isChecked = list.contains(Calendar.FRIDAY) + binding.weekdayPickerSaturday.isChecked = list.contains(Calendar.SATURDAY) + } + + private fun setupClickListeners() { + binding.weekdayPickerSundayStart.setupCallbackFor(Calendar.SUNDAY) + binding.weekdayPickerSundayEnd.setupCallbackFor(Calendar.SUNDAY) + binding.weekdayPickerMonday.setupCallbackFor(Calendar.MONDAY) + binding.weekdayPickerTuesday.setupCallbackFor(Calendar.TUESDAY) + binding.weekdayPickerWednesday.setupCallbackFor(Calendar.WEDNESDAY) + binding.weekdayPickerThursday.setupCallbackFor(Calendar.THURSDAY) + binding.weekdayPickerFriday.setupCallbackFor(Calendar.FRIDAY) + binding.weekdayPickerSaturday.setupCallbackFor(Calendar.SATURDAY) + } + + fun setOnWeekdaysChangeListener(changeListener: (Int, Boolean) -> Unit) { + this.changeListener = changeListener + } + + private fun AppCompatCheckedTextView.setupCallbackFor(day: Int) = setOnClickListener{ + val checkable = it as Checkable + val checked = checkable.isChecked + checkable.isChecked = !checked + changeListener?.invoke(day, !checked) + } + +} \ No newline at end of file diff --git a/core/src/main/res/color/weekday_background.xml b/core/src/main/res/color/weekday_background.xml new file mode 100644 index 0000000000..b345f818d2 --- /dev/null +++ b/core/src/main/res/color/weekday_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/src/main/res/color/weekend_background.xml b/core/src/main/res/color/weekend_background.xml new file mode 100644 index 0000000000..1de73d0e17 --- /dev/null +++ b/core/src/main/res/color/weekend_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/src/main/res/drawable/weekday_circle_brackground.xml b/core/src/main/res/drawable/weekday_circle_brackground.xml new file mode 100644 index 0000000000..861dda73c2 --- /dev/null +++ b/core/src/main/res/drawable/weekday_circle_brackground.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/core/src/main/res/layout/weekday_picker.xml b/core/src/main/res/layout/weekday_picker.xml new file mode 100644 index 0000000000..82acbb829b --- /dev/null +++ b/core/src/main/res/layout/weekday_picker.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 7842897b59..6bd15fb852 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -41,6 +41,11 @@ #00d2d2 #ffffff + #8000FF00 + #1000FF00 + #800000FF + #100000FF + #FF8C00 diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index e42bd8e553..06a686a867 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -315,6 +315,15 @@ Please reboot your phone or restart AndroidAPS from the System Settings \notherwise Android APS will not have logging (important to track and verify that the algorithms are working correctly)! + + M + T + W + T + F + S + S + %1$d day %1$d days From ff6a8f30c1c05cac3bde17dbf9df961102f35f51 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 19:10:12 +0100 Subject: [PATCH 12/36] weekday component working --- .../androidaps/utils/ui/WeekdayPicker.kt | 3 +- .../res/color/day_selection_background.xml | 5 + .../src/main/res/color/weekday_background.xml | 5 - .../src/main/res/color/weekend_background.xml | 5 - .../drawable/weekday_circle_brackground.xml | 6 +- .../drawable/weekend_circle_brackground.xml | 7 + core/src/main/res/layout/weekday_picker.xml | 124 +++++++++++++----- core/src/main/res/values/colors.xml | 7 +- 8 files changed, 114 insertions(+), 48 deletions(-) create mode 100644 core/src/main/res/color/day_selection_background.xml delete mode 100644 core/src/main/res/color/weekday_background.xml delete mode 100644 core/src/main/res/color/weekend_background.xml create mode 100644 core/src/main/res/drawable/weekend_circle_brackground.xml diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt index 0ac104a070..07af86879f 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt @@ -6,13 +6,14 @@ import android.view.LayoutInflater import android.widget.Checkable import android.widget.LinearLayout import androidx.appcompat.widget.AppCompatCheckedTextView +import androidx.constraintlayout.widget.ConstraintLayout import info.nightscout.androidaps.core.databinding.WeekdayPickerBinding import info.nightscout.androidaps.utils.extensions.toVisibility import java.util.* class WeekdayPicker @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : LinearLayout(context, attrs, defStyleAttr) { +) : ConstraintLayout(context, attrs, defStyleAttr) { private var changeListener: ((Int, Boolean) -> Unit)? = null diff --git a/core/src/main/res/color/day_selection_background.xml b/core/src/main/res/color/day_selection_background.xml new file mode 100644 index 0000000000..6dd68ef826 --- /dev/null +++ b/core/src/main/res/color/day_selection_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/src/main/res/color/weekday_background.xml b/core/src/main/res/color/weekday_background.xml deleted file mode 100644 index b345f818d2..0000000000 --- a/core/src/main/res/color/weekday_background.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/core/src/main/res/color/weekend_background.xml b/core/src/main/res/color/weekend_background.xml deleted file mode 100644 index 1de73d0e17..0000000000 --- a/core/src/main/res/color/weekend_background.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/core/src/main/res/drawable/weekday_circle_brackground.xml b/core/src/main/res/drawable/weekday_circle_brackground.xml index 861dda73c2..df71b0310e 100644 --- a/core/src/main/res/drawable/weekday_circle_brackground.xml +++ b/core/src/main/res/drawable/weekday_circle_brackground.xml @@ -1,7 +1,7 @@ - + + android:width="4dp" + android:color="@color/weekdayOutline"/> \ No newline at end of file diff --git a/core/src/main/res/drawable/weekend_circle_brackground.xml b/core/src/main/res/drawable/weekend_circle_brackground.xml new file mode 100644 index 0000000000..658780df37 --- /dev/null +++ b/core/src/main/res/drawable/weekend_circle_brackground.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/core/src/main/res/layout/weekday_picker.xml b/core/src/main/res/layout/weekday_picker.xml index 82acbb829b..db8219f583 100644 --- a/core/src/main/res/layout/weekday_picker.xml +++ b/core/src/main/res/layout/weekday_picker.xml @@ -1,74 +1,138 @@ - + android:layout_height="wrap_content"> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerMonday" + app:layout_constraintStart_toStartOf="parent" /> + android:gravity="center" + android:textAlignment="gravity" + android:padding="8dp" + android:layout_margin="2dp" + app:layout_constraintDimensionRatio="H,1:1" + app:autoSizeTextType="uniform" + android:text="@string/monday_short" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerTuesday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerSundayStart" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintBaseline_toBaselineOf="@+id/weekdayPickerWednesday" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerWednesday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerMonday" /> + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerThursday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerTuesday" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerFriday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerWednesday" /> + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerSaturday" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerThursday" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toStartOf="@+id/weekdayPickerSundayEnd" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerFriday" /> + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@+id/weekdayPickerSaturday" + app:layout_constraintTop_toTopOf="parent" /> - \ No newline at end of file + \ No newline at end of file diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 6bd15fb852..a533a5c3aa 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -41,10 +41,9 @@ #00d2d2 #ffffff - #8000FF00 - #1000FF00 - #800000FF - #100000FF + #D000FF00 + #1ea3e5 + #1e88e5 #FF8C00 From 7c8caa659b4662b676524a216eadd56fcdbae96e Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 19:19:14 +0100 Subject: [PATCH 13/36] remove crashing library --- app/build.gradle | 3 --- app/libs/weekdaysselector-1.1.1.aar | Bin 17376 -> 0 bytes 2 files changed, 3 deletions(-) delete mode 100644 app/libs/weekdaysselector-1.1.1.aar diff --git a/app/build.gradle b/app/build.gradle index 5df54d7711..45e91a54d6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -241,9 +241,6 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - // https://github.com/DavidProdinger/Weekdays-Selector (used outdated 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1') - implementation(name: 'weekdaysselector-1.1.1', ext: 'aar') - testImplementation "junit:junit:$junit_version" testImplementation 'org.json:json:20201115' testImplementation "org.mockito:mockito-core:${mockitoVersion}" diff --git a/app/libs/weekdaysselector-1.1.1.aar b/app/libs/weekdaysselector-1.1.1.aar deleted file mode 100644 index 214a429e3ab71fb2118cfd13579ed882ad6ef9a5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17376 zcmZ^~V~j3Lur)fy9^1BU+qP}nwr$(CXP&WbduES~J-F}5cmJH+?{-r4qqC}$>Xr0L zI<*vKK*9b10YO0l0RagCNmO@FPeK3z0h0m&f&aIoOz-OHny0;MpUa8bzh99FIWfv; zwRK~LV^<@2S=|%WUZ+ko4T|3gVQVUzd}+P!m%wyD0Gp|63NpSQk>K|e3uopW5jL2S zM`%R@W<<4lWAHklxJp>Iao9}XNW*>foC~wp3|rQF0@Rl>7%$^Jh-qD4Ijb+ny@kIV>NWWwxE zvjvf|F_2V^q#pnk?hTSUs7n5X&p+;iTv?D`i^xb9WQMIm%RWcNY4az_%8WTQbUZ3VGfMypPPqbb|7^@630x`QIF{#F3$88`xTJw0 zu}%+eR!AM6(cSj01*<S(M>=|Q^F)*x|}5(nfH0yTW+ymC5QH_ zBzXi-xXfe>+2lee@uLXKpaN=LLSW@*a6R4FsbzZ_?P*M`C$Ge$F$!SS@e_&GBdEK% zk=b^!w*+5eR?DgwQ5o~>Wg#vnlSIqV0CD;4V)8z*k6;U0Rfxcsa%K5{i_{EMgBf0e zNFBwu&EdgT<yCf7<4q$1=6euR}X$S{+f(llHX)y7|t*~H^6F#Vc(!RL83(|P%}p#>*7Q(LCeOB)Hp zg8o8s!-XBhYKV46Z@~!pZIfYRxE=-bb`i6A{qQOGEAlA2AIW;Fw(ceAO&80NuG!ITn% ztsNO+kw(R#lQ7y?R$Pp5R`;2Kn`8C5R=-95D504jv>9V*FF|~g0Ga~t*8ct+ zKoK(ZyfwRmtDA)i6hB|+d25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From 0d601634e00445ad2b9191c8e3b3c29d50434f01 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 13 Feb 2021 19:40:27 +0100 Subject: [PATCH 14/36] cleanups of new weekday selector --- .../automation/elements/InputWeekDay.kt | 2 - .../androidaps/utils/ui/WeekdayPicker.kt | 39 +++++---- core/src/main/res/layout/weekday_picker.xml | 81 +++++++++---------- 3 files changed, 59 insertions(+), 63 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt index dda616de14..53733acfc8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputWeekDay.kt @@ -20,7 +20,6 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { get() = shortNames[ordinal] companion object { - private val calendarInts = intArrayOf( Calendar.MONDAY, Calendar.TUESDAY, @@ -82,6 +81,5 @@ class InputWeekDay(injector: HasAndroidInjector) : Element(injector) { setOnWeekdaysChangeListener { i: Int, selected: Boolean -> set(DayOfWeek.fromCalendarInt(i), selected) } root.addView(this) } - // TODO: remove library and dependency statement } } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt index 07af86879f..e3352ec94d 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/ui/WeekdayPicker.kt @@ -4,7 +4,6 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.widget.Checkable -import android.widget.LinearLayout import androidx.appcompat.widget.AppCompatCheckedTextView import androidx.constraintlayout.widget.ConstraintLayout import info.nightscout.androidaps.core.databinding.WeekdayPickerBinding @@ -33,33 +32,33 @@ class WeekdayPicker @JvmOverloads constructor( } } - fun setSelectedDays(list: List) { - binding.weekdayPickerSundayStart.isChecked = list.contains(Calendar.SUNDAY) - binding.weekdayPickerSundayEnd.isChecked = list.contains(Calendar.SUNDAY) - binding.weekdayPickerMonday.isChecked = list.contains(Calendar.MONDAY) - binding.weekdayPickerTuesday.isChecked = list.contains(Calendar.TUESDAY) - binding.weekdayPickerWednesday.isChecked = list.contains(Calendar.WEDNESDAY) - binding.weekdayPickerThursday.isChecked = list.contains(Calendar.THURSDAY) - binding.weekdayPickerFriday.isChecked = list.contains(Calendar.FRIDAY) - binding.weekdayPickerSaturday.isChecked = list.contains(Calendar.SATURDAY) + fun setSelectedDays(list: List) = with(binding) { + weekdayPickerSundayStart.isChecked = list.contains(Calendar.SUNDAY) + weekdayPickerSundayEnd.isChecked = list.contains(Calendar.SUNDAY) + weekdayPickerMonday.isChecked = list.contains(Calendar.MONDAY) + weekdayPickerTuesday.isChecked = list.contains(Calendar.TUESDAY) + weekdayPickerWednesday.isChecked = list.contains(Calendar.WEDNESDAY) + weekdayPickerThursday.isChecked = list.contains(Calendar.THURSDAY) + weekdayPickerFriday.isChecked = list.contains(Calendar.FRIDAY) + weekdayPickerSaturday.isChecked = list.contains(Calendar.SATURDAY) } - private fun setupClickListeners() { - binding.weekdayPickerSundayStart.setupCallbackFor(Calendar.SUNDAY) - binding.weekdayPickerSundayEnd.setupCallbackFor(Calendar.SUNDAY) - binding.weekdayPickerMonday.setupCallbackFor(Calendar.MONDAY) - binding.weekdayPickerTuesday.setupCallbackFor(Calendar.TUESDAY) - binding.weekdayPickerWednesday.setupCallbackFor(Calendar.WEDNESDAY) - binding.weekdayPickerThursday.setupCallbackFor(Calendar.THURSDAY) - binding.weekdayPickerFriday.setupCallbackFor(Calendar.FRIDAY) - binding.weekdayPickerSaturday.setupCallbackFor(Calendar.SATURDAY) + private fun setupClickListeners() = with(binding) { + weekdayPickerSundayStart.setupCallbackFor(Calendar.SUNDAY) + weekdayPickerSundayEnd.setupCallbackFor(Calendar.SUNDAY) + weekdayPickerMonday.setupCallbackFor(Calendar.MONDAY) + weekdayPickerTuesday.setupCallbackFor(Calendar.TUESDAY) + weekdayPickerWednesday.setupCallbackFor(Calendar.WEDNESDAY) + weekdayPickerThursday.setupCallbackFor(Calendar.THURSDAY) + weekdayPickerFriday.setupCallbackFor(Calendar.FRIDAY) + weekdayPickerSaturday.setupCallbackFor(Calendar.SATURDAY) } fun setOnWeekdaysChangeListener(changeListener: (Int, Boolean) -> Unit) { this.changeListener = changeListener } - private fun AppCompatCheckedTextView.setupCallbackFor(day: Int) = setOnClickListener{ + private fun AppCompatCheckedTextView.setupCallbackFor(day: Int) = setOnClickListener { val checkable = it as Checkable val checked = checkable.isChecked checkable.isChecked = !checked diff --git a/core/src/main/res/layout/weekday_picker.xml b/core/src/main/res/layout/weekday_picker.xml index db8219f583..f20fec423d 100644 --- a/core/src/main/res/layout/weekday_picker.xml +++ b/core/src/main/res/layout/weekday_picker.xml @@ -1,40 +1,39 @@ + android:layout_height="wrap_content" + android:padding="2dp"> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> @@ -43,15 +42,15 @@ android:id="@+id/weekdayPickerTuesday" android:layout_width="0dp" android:layout_height="0dp" + android:layout_margin="2dp" android:background="@drawable/weekday_circle_brackground" android:gravity="center" - android:textAlignment="gravity" android:padding="8dp" - android:layout_margin="2dp" - app:layout_constraintDimensionRatio="H,1:1" - app:autoSizeTextType="uniform" android:text="@string/tuesday_short" + android:textAlignment="gravity" + app:autoSizeTextType="uniform" app:layout_constraintBaseline_toBaselineOf="@+id/weekdayPickerWednesday" + app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintEnd_toStartOf="@+id/weekdayPickerWednesday" app:layout_constraintStart_toEndOf="@+id/weekdayPickerMonday" /> @@ -59,14 +58,14 @@ android:id="@+id/weekdayPickerWednesday" android:layout_width="0dp" android:layout_height="0dp" + android:layout_margin="2dp" android:background="@drawable/weekday_circle_brackground" android:gravity="center" - android:textAlignment="gravity" android:padding="8dp" - android:layout_margin="2dp" - app:layout_constraintDimensionRatio="H,1:1" - app:autoSizeTextType="uniform" android:text="@string/wednesday_short" + android:textAlignment="gravity" + app:autoSizeTextType="uniform" + app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintEnd_toStartOf="@+id/weekdayPickerThursday" app:layout_constraintStart_toEndOf="@+id/weekdayPickerTuesday" app:layout_constraintTop_toTopOf="parent" /> @@ -75,30 +74,30 @@ android:id="@+id/weekdayPickerThursday" android:layout_width="0dp" android:layout_height="0dp" + android:layout_margin="2dp" android:background="@drawable/weekday_circle_brackground" android:gravity="center" - android:textAlignment="gravity" android:padding="8dp" - android:layout_margin="2dp" - app:layout_constraintDimensionRatio="H,1:1" - app:autoSizeTextType="uniform" android:text="@string/thursday_short" - app:layout_constraintTop_toTopOf="parent" + android:textAlignment="gravity" + app:autoSizeTextType="uniform" + app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintEnd_toStartOf="@+id/weekdayPickerFriday" - app:layout_constraintStart_toEndOf="@+id/weekdayPickerWednesday" /> + app:layout_constraintStart_toEndOf="@+id/weekdayPickerWednesday" + app:layout_constraintTop_toTopOf="parent" /> @@ -107,30 +106,30 @@ android:id="@+id/weekdayPickerSaturday" android:layout_width="0dp" android:layout_height="0dp" + android:layout_margin="2dp" android:background="@drawable/weekend_circle_brackground" android:gravity="center" - android:textAlignment="gravity" android:padding="8dp" - android:layout_margin="2dp" - app:layout_constraintDimensionRatio="H,1:1" - app:autoSizeTextType="uniform" android:text="@string/saturday_short" - app:layout_constraintTop_toTopOf="parent" + android:textAlignment="gravity" + app:autoSizeTextType="uniform" + app:layout_constraintDimensionRatio="H,1:1" app:layout_constraintEnd_toStartOf="@+id/weekdayPickerSundayEnd" - app:layout_constraintStart_toEndOf="@+id/weekdayPickerFriday" /> + app:layout_constraintStart_toEndOf="@+id/weekdayPickerFriday" + app:layout_constraintTop_toTopOf="parent" /> From 0ce35c6439d02c849081f20e3fbac269007ca89d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 13 Feb 2021 22:14:06 +0100 Subject: [PATCH 15/36] TDDStatsActivity ->kt --- .../activities/TDDStatsActivity.java | 528 ------------------ .../androidaps/activities/TDDStatsActivity.kt | 429 ++++++++++++++ ...atsactivity.xml => activity_tdd_stats.xml} | 165 +++--- 3 files changed, 509 insertions(+), 613 deletions(-) delete mode 100644 core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java create mode 100644 core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt rename core/src/main/res/layout/{danar_statsactivity.xml => activity_tdd_stats.xml} (58%) diff --git a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java deleted file mode 100644 index b9cc88fc28..0000000000 --- a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java +++ /dev/null @@ -1,528 +0,0 @@ -package info.nightscout.androidaps.activities; - -import android.graphics.Color; -import android.graphics.Rect; -import android.os.Bundle; -import android.text.TextUtils; -import android.view.MotionEvent; -import android.view.View; -import android.view.WindowManager; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodManager; -import android.widget.Button; -import android.widget.EditText; -import android.widget.TableLayout; -import android.widget.TableRow; -import android.widget.TextView; - -import androidx.recyclerview.widget.LinearLayoutManager; - -import java.text.DateFormat; -import java.text.DecimalFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; - -import javax.inject.Inject; - -import info.nightscout.androidaps.core.R; -import info.nightscout.androidaps.data.Profile; -import info.nightscout.androidaps.db.TDD; -import info.nightscout.androidaps.events.EventDanaRSyncStatus; -import info.nightscout.androidaps.events.EventPumpStatusChanged; -import info.nightscout.androidaps.interfaces.ActivePluginProvider; -import info.nightscout.androidaps.interfaces.CommandQueueProvider; -import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; -import info.nightscout.androidaps.interfaces.ProfileFunction; -import info.nightscout.androidaps.logging.AAPSLogger; -import info.nightscout.androidaps.plugins.bus.RxBusWrapper; -import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; -import info.nightscout.androidaps.queue.Callback; -import info.nightscout.androidaps.utils.FabricPrivacy; -import info.nightscout.androidaps.utils.SafeParse; -import info.nightscout.androidaps.utils.resources.ResourceHelper; -import info.nightscout.androidaps.utils.rx.AapsSchedulers; -import info.nightscout.androidaps.utils.sharedPreferences.SP; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.CompositeDisposable; - -public class TDDStatsActivity extends NoSplashAppCompatActivity { - @Inject AAPSLogger aapsLogger; - @Inject ResourceHelper resourceHelper; - @Inject RxBusWrapper rxBus; - @Inject SP sp; - @Inject ProfileFunction profileFunction; - @Inject ActivePluginProvider activePlugin; - @Inject CommandQueueProvider commandQueue; - @Inject DatabaseHelperInterface databaseHelper; - @Inject FabricPrivacy fabricPrivacy; - @Inject AapsSchedulers aapsSchedulers; - - private final CompositeDisposable disposable = new CompositeDisposable(); - - TextView statusView, statsMessage, totalBaseBasal2; - EditText totalBaseBasal; - Button reloadButton; - LinearLayoutManager llm; - TableLayout tl, ctl, etl; - String TBB; - double magicNumber; - DecimalFormat decimalFormat; - - List historyList = new ArrayList<>(); - List dummies; - - public TDDStatsActivity() { - super(); - } - - @Override - protected void onResume() { - super.onResume(); - disposable.add(rxBus - .toObservable(EventPumpStatusChanged.class) - .observeOn(aapsSchedulers.getMain()) - .subscribe(event -> statusView.setText(event.getStatus(resourceHelper)), exception -> fabricPrivacy.logException(exception)) - ); - disposable.add(rxBus - .toObservable(EventDanaRSyncStatus.class) - .observeOn(aapsSchedulers.getMain()) - .subscribe(event -> { - aapsLogger.debug("EventDanaRSyncStatus: " + event.getMessage()); - statusView.setText(event.getMessage()); - }, exception -> fabricPrivacy.logException(exception)) - ); - } - - @Override - protected void onPause() { - super.onPause(); - disposable.clear(); - } - - @Override - public boolean dispatchTouchEvent(MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { - View myView = getCurrentFocus(); - if (myView instanceof EditText) { - Rect rect = new Rect(); - myView.getGlobalVisibleRect(rect); - if (!rect.contains((int) event.getRawX(), (int) event.getRawY())) { - myView.clearFocus(); - } - } - } - return super.dispatchTouchEvent(event); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.danar_statsactivity); - getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); - statusView = findViewById(R.id.danar_stats_connection_status); - reloadButton = findViewById(R.id.danar_statsreload); - totalBaseBasal = findViewById(R.id.danar_stats_editTotalBaseBasal); - totalBaseBasal2 = findViewById(R.id.danar_stats_editTotalBaseBasal2); - statsMessage = findViewById(R.id.danar_stats_Message); - - statusView.setVisibility(View.GONE); - statsMessage.setVisibility(View.GONE); - - totalBaseBasal2.setEnabled(false); - totalBaseBasal2.setClickable(false); - totalBaseBasal2.setFocusable(false); - totalBaseBasal2.setInputType(0); - - decimalFormat = new DecimalFormat("0.000"); - llm = new LinearLayoutManager(this); - - TBB = sp.getString("TBB", "10.00"); - - Profile profile = profileFunction.getProfile(); - if (profile != null) { - double cppTBB = profile.baseBasalSum(); - TBB = decimalFormat.format(cppTBB); - sp.putString("TBB", TBB); - } - totalBaseBasal.setText(TBB); - - if (!activePlugin.getActivePump().getPumpDescription().needsManualTDDLoad) - reloadButton.setVisibility(View.GONE); - - // stats table - tl = findViewById(R.id.main_table); - TableRow tr_head = new TableRow(this); - tr_head.setBackgroundColor(Color.DKGRAY); - tr_head.setLayoutParams(new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - TextView label_date = new TextView(this); - label_date.setText(resourceHelper.gs(R.string.date)); - label_date.setTextColor(Color.WHITE); - tr_head.addView(label_date); - - TextView label_basalrate = new TextView(this); - label_basalrate.setText(resourceHelper.gs(R.string.basalrate)); - label_basalrate.setTextColor(Color.WHITE); - tr_head.addView(label_basalrate); - - TextView label_bolus = new TextView(this); - label_bolus.setText(resourceHelper.gs(R.string.bolus)); - label_bolus.setTextColor(Color.WHITE); - tr_head.addView(label_bolus); - - TextView label_tdd = new TextView(this); - label_tdd.setText(resourceHelper.gs(R.string.tdd)); - label_tdd.setTextColor(Color.WHITE); - tr_head.addView(label_tdd); - - TextView label_ratio = new TextView(this); - label_ratio.setText(resourceHelper.gs(R.string.ratio)); - label_ratio.setTextColor(Color.WHITE); - tr_head.addView(label_ratio); - - // add stats headers to tables - tl.addView(tr_head, new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - // cumulative table - ctl = findViewById(R.id.cumulative_table); - TableRow ctr_head = new TableRow(this); - ctr_head.setBackgroundColor(Color.DKGRAY); - ctr_head.setLayoutParams(new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - TextView label_cum_amount_days = new TextView(this); - label_cum_amount_days.setText(resourceHelper.gs(R.string.amount_days)); - label_cum_amount_days.setTextColor(Color.WHITE); - ctr_head.addView(label_cum_amount_days); - - TextView label_cum_tdd = new TextView(this); - label_cum_tdd.setText(resourceHelper.gs(R.string.tdd)); - label_cum_tdd.setTextColor(Color.WHITE); - ctr_head.addView(label_cum_tdd); - - TextView label_cum_ratio = new TextView(this); - label_cum_ratio.setText(resourceHelper.gs(R.string.ratio)); - label_cum_ratio.setTextColor(Color.WHITE); - ctr_head.addView(label_cum_ratio); - - // add cummulative headers to tables - ctl.addView(ctr_head, new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - // expontial table - etl = findViewById(R.id.expweight_table); - TableRow etr_head = new TableRow(this); - etr_head.setBackgroundColor(Color.DKGRAY); - etr_head.setLayoutParams(new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - TextView label_exp_weight = new TextView(this); - label_exp_weight.setText(resourceHelper.gs(R.string.weight)); - label_exp_weight.setTextColor(Color.WHITE); - etr_head.addView(label_exp_weight); - - TextView label_exp_tdd = new TextView(this); - label_exp_tdd.setText(resourceHelper.gs(R.string.tdd)); - label_exp_tdd.setTextColor(Color.WHITE); - etr_head.addView(label_exp_tdd); - - TextView label_exp_ratio = new TextView(this); - label_exp_ratio.setText(resourceHelper.gs(R.string.ratio)); - label_exp_ratio.setTextColor(Color.WHITE); - etr_head.addView(label_exp_ratio); - - // add expontial headers to tables - etl.addView(etr_head, new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - reloadButton.setOnClickListener(v -> { - runOnUiThread(() -> { - reloadButton.setVisibility(View.GONE); - statusView.setVisibility(View.VISIBLE); - statsMessage.setVisibility(View.VISIBLE); - statsMessage.setText(resourceHelper.gs(R.string.warning_Message)); - }); - commandQueue.loadTDDs(new Callback() { - @Override - public void run() { - loadDataFromDB(); - runOnUiThread(() -> { - reloadButton.setVisibility(View.VISIBLE); - statusView.setVisibility(View.GONE); - statsMessage.setVisibility(View.GONE); - }); - } - }); - }); - - totalBaseBasal.setOnEditorActionListener((v, actionId, event) -> { - if (actionId == EditorInfo.IME_ACTION_DONE) { - totalBaseBasal.clearFocus(); - return true; - } - return false; - }); - - totalBaseBasal.setOnFocusChangeListener((v, hasFocus) -> { - if (hasFocus) { - totalBaseBasal.getText().clear(); - } else { - sp.putString("TBB", totalBaseBasal.getText().toString()); - TBB = sp.getString("TBB", ""); - loadDataFromDB(); - InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(totalBaseBasal.getWindowToken(), 0); - } - }); - - loadDataFromDB(); - } - - private void loadDataFromDB() { - historyList = databaseHelper.getTDDs(); - - //only use newest 10 - historyList = historyList.subList(0, Math.min(10, historyList.size())); - - //fill single gaps - dummies = new LinkedList<>(); - DateFormat df = new SimpleDateFormat("dd.MM.", Locale.getDefault()); - for (int i = 0; i < historyList.size() - 1; i++) { - TDD elem1 = historyList.get(i); - TDD elem2 = historyList.get(i + 1); - - if (!df.format(new Date(elem1.date)).equals(df.format(new Date(elem2.date + 25 * 60 * 60 * 1000)))) { - TDD dummy = new TDD(); - dummy.date = elem1.date - 24 * 60 * 60 * 1000; - dummy.basal = elem1.basal / 2; - dummy.bolus = elem1.bolus / 2; - dummies.add(dummy); - elem1.basal /= 2; - elem1.bolus /= 2; - } - } - historyList.addAll(dummies); - Collections.sort(historyList, (lhs, rhs) -> (int) (rhs.date - lhs.date)); - - runOnUiThread(() -> { - cleanTable(tl); - cleanTable(ctl); - cleanTable(etl); - DateFormat df1 = new SimpleDateFormat("dd.MM.", Locale.getDefault()); - - if (TextUtils.isEmpty(TBB)) { - totalBaseBasal.setError("Please Enter Total Base Basal"); - return; - } else { - magicNumber = SafeParse.stringToDouble(TBB); - } - - magicNumber *= 2; - totalBaseBasal2.setText(decimalFormat.format(magicNumber)); - - int i = 0; - double sum = 0d; - double weighted03 = 0d; - double weighted05 = 0d; - double weighted07 = 0d; - - - //TDD table - for (TDD record : historyList) { - double tdd = record.getTotal(); - - // Create the table row - TableRow tr = new TableRow(TDDStatsActivity.this); - if (i % 2 != 0) tr.setBackgroundColor(Color.DKGRAY); - if (dummies.contains(record)) { - tr.setBackgroundColor(Color.argb(125, 255, 0, 0)); - } - tr.setId(100 + i); - tr.setLayoutParams(new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - // Here create the TextView dynamically - TextView labelDATE = new TextView(TDDStatsActivity.this); - labelDATE.setId(200 + i); - labelDATE.setText(df1.format(new Date(record.date))); - labelDATE.setTextColor(Color.WHITE); - tr.addView(labelDATE); - - TextView labelBASAL = new TextView(TDDStatsActivity.this); - labelBASAL.setId(300 + i); - labelBASAL.setText(resourceHelper.gs(R.string.formatinsulinunits, record.basal)); - labelBASAL.setTextColor(Color.WHITE); - tr.addView(labelBASAL); - - TextView labelBOLUS = new TextView(TDDStatsActivity.this); - labelBOLUS.setId(400 + i); - labelBOLUS.setText(resourceHelper.gs(R.string.formatinsulinunits, record.bolus)); - labelBOLUS.setTextColor(Color.WHITE); - tr.addView(labelBOLUS); - - TextView labelTDD = new TextView(TDDStatsActivity.this); - labelTDD.setId(500 + i); - labelTDD.setText(resourceHelper.gs(R.string.formatinsulinunits, tdd)); - labelTDD.setTextColor(Color.WHITE); - tr.addView(labelTDD); - - TextView labelRATIO = new TextView(TDDStatsActivity.this); - labelRATIO.setId(600 + i); - labelRATIO.setText(Math.round(100 * tdd / magicNumber) + "%"); - labelRATIO.setTextColor(Color.WHITE); - tr.addView(labelRATIO); - - // add stats rows to tables - tl.addView(tr, new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - i++; - } - - i = 0; - - //cumulative TDDs - for (TDD record : historyList) { - if (!historyList.isEmpty() && df1.format(new Date(record.date)).equals(df1.format(new Date()))) { - //Today should not be included - continue; - } - i++; - - sum = sum + record.getTotal(); - - // Create the cumtable row - TableRow ctr = new TableRow(TDDStatsActivity.this); - if (i % 2 == 0) ctr.setBackgroundColor(Color.DKGRAY); - ctr.setId(700 + i); - ctr.setLayoutParams(new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - // Here create the TextView dynamically - TextView labelDAYS = new TextView(TDDStatsActivity.this); - labelDAYS.setId(800 + i); - labelDAYS.setText("" + i); - labelDAYS.setTextColor(Color.WHITE); - ctr.addView(labelDAYS); - - TextView labelCUMTDD = new TextView(TDDStatsActivity.this); - labelCUMTDD.setId(900 + i); - labelCUMTDD.setText(resourceHelper.gs(R.string.formatinsulinunits, sum / i)); - labelCUMTDD.setTextColor(Color.WHITE); - ctr.addView(labelCUMTDD); - - TextView labelCUMRATIO = new TextView(TDDStatsActivity.this); - labelCUMRATIO.setId(1000 + i); - labelCUMRATIO.setText(Math.round(100 * sum / i / magicNumber) + "%"); - labelCUMRATIO.setTextColor(Color.WHITE); - ctr.addView(labelCUMRATIO); - - // add cummulative rows to tables - ctl.addView(ctr, new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - } - - if (isOldData(historyList) && activePlugin.getActivePump().getPumpDescription().needsManualTDDLoad) { - statsMessage.setVisibility(View.VISIBLE); - statsMessage.setText(resourceHelper.gs(R.string.olddata_Message)); - - } else { - tl.setBackgroundColor(Color.TRANSPARENT); - } - - if (!historyList.isEmpty() && df1.format(new Date(historyList.get(0).date)).equals(df1.format(new Date()))) { - //Today should not be included - historyList.remove(0); - } - - Collections.reverse(historyList); - - i = 0; - - for (TDD record : historyList) { - double tdd = record.getTotal(); - if (i == 0) { - weighted03 = tdd; - weighted05 = tdd; - weighted07 = tdd; - - } else { - weighted07 = (weighted07 * 0.3 + tdd * 0.7); - weighted05 = (weighted05 * 0.5 + tdd * 0.5); - weighted03 = (weighted03 * 0.7 + tdd * 0.3); - } - i++; - } - - // Create the exptable row - TableRow etr = new TableRow(TDDStatsActivity.this); - if (i % 2 != 0) etr.setBackgroundColor(Color.DKGRAY); - etr.setId(1100 + i); - etr.setLayoutParams(new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - - // Here create the TextView dynamically - TextView labelWEIGHT = new TextView(TDDStatsActivity.this); - labelWEIGHT.setId(1200 + i); - labelWEIGHT.setText("0.3\n" + "0.5\n" + "0.7"); - labelWEIGHT.setTextColor(Color.WHITE); - etr.addView(labelWEIGHT); - - TextView labelEXPTDD = new TextView(TDDStatsActivity.this); - labelEXPTDD.setId(1300 + i); - labelEXPTDD.setText(resourceHelper.gs(R.string.formatinsulinunits, weighted03) + "\n" + - resourceHelper.gs(R.string.formatinsulinunits, weighted05) + "\n" + - resourceHelper.gs(R.string.formatinsulinunits, weighted07)); - labelEXPTDD.setTextColor(Color.WHITE); - etr.addView(labelEXPTDD); - - TextView labelEXPRATIO = new TextView(TDDStatsActivity.this); - labelEXPRATIO.setId(1400 + i); - labelEXPRATIO.setText(Math.round(100 * weighted03 / magicNumber) + "%\n" - + Math.round(100 * weighted05 / magicNumber) + "%\n" - + Math.round(100 * weighted07 / magicNumber) + "%"); - labelEXPRATIO.setTextColor(Color.WHITE); - etr.addView(labelEXPRATIO); - - // add exponentail rows to tables - etl.addView(etr, new TableLayout.LayoutParams( - TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT)); - }); - } - - private void cleanTable(TableLayout table) { - int childCount = table.getChildCount(); - // Remove all rows except the first one - if (childCount > 1) { - table.removeViews(1, childCount - 1); - } - } - - public boolean isOldData(List historyList) { - - PumpType type = activePlugin.getActivePump().getPumpDescription().pumpType; - boolean startsYesterday = type == PumpType.DanaR || type == PumpType.DanaRS || type == PumpType.DanaRv2 || type == PumpType.DanaRKorean || type == PumpType.AccuChekInsight; - - DateFormat df = new SimpleDateFormat("dd.MM.", Locale.getDefault()); - return (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).date)).equals(df.format(new Date(System.currentTimeMillis() - (startsYesterday ? 1000 * 60 * 60 * 24 : 0)))))); - } -} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt new file mode 100644 index 0000000000..ba650bace7 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt @@ -0,0 +1,429 @@ +package info.nightscout.androidaps.activities + +import android.annotation.SuppressLint +import android.graphics.Color +import android.graphics.Rect +import android.os.Bundle +import android.text.TextUtils +import android.view.KeyEvent +import android.view.MotionEvent +import android.view.View +import android.view.WindowManager +import android.view.inputmethod.EditorInfo +import android.view.inputmethod.InputMethodManager +import android.widget.EditText +import android.widget.TableLayout +import android.widget.TableRow +import android.widget.TextView +import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.core.databinding.ActivityTddStatsBinding +import info.nightscout.androidaps.db.TDD +import info.nightscout.androidaps.events.EventDanaRSyncStatus +import info.nightscout.androidaps.events.EventPumpStatusChanged +import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.interfaces.CommandQueueProvider +import info.nightscout.androidaps.interfaces.DatabaseHelperInterface +import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.pump.common.defs.PumpType +import info.nightscout.androidaps.queue.Callback +import info.nightscout.androidaps.utils.FabricPrivacy +import info.nightscout.androidaps.utils.SafeParse +import info.nightscout.androidaps.utils.rx.AapsSchedulers +import info.nightscout.androidaps.utils.sharedPreferences.SP +import io.reactivex.disposables.CompositeDisposable +import java.text.DateFormat +import java.text.DecimalFormat +import java.text.SimpleDateFormat +import java.util.* +import javax.inject.Inject +import kotlin.math.min +import kotlin.math.roundToInt + +class TDDStatsActivity : NoSplashAppCompatActivity() { + + @Inject lateinit var aapsLogger: AAPSLogger + @Inject lateinit var rxBus: RxBusWrapper + @Inject lateinit var sp: SP + @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var activePlugin: ActivePluginProvider + @Inject lateinit var commandQueue: CommandQueueProvider + @Inject lateinit var databaseHelper: DatabaseHelperInterface + @Inject lateinit var fabricPrivacy: FabricPrivacy + @Inject lateinit var aapsSchedulers: AapsSchedulers + + private lateinit var binding: ActivityTddStatsBinding + private val disposable = CompositeDisposable() + + lateinit var tbb: String + private var magicNumber = 0.0 + private var decimalFormat: DecimalFormat = DecimalFormat("0.000") + private var historyList: MutableList = mutableListOf() + private var dummies: MutableList = mutableListOf() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityTddStatsBinding.inflate(layoutInflater) + setContentView(binding.root) + + window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN) + binding.connectionStatus.visibility = View.GONE + binding.message.visibility = View.GONE + binding.totalBaseBasal2.isEnabled = false + binding.totalBaseBasal2.isClickable = false + binding.totalBaseBasal2.isFocusable = false + binding.totalBaseBasal2.inputType = 0 + tbb = sp.getString("TBB", "10.00") + val profile = profileFunction.getProfile() + if (profile != null) { + val cppTBB = profile.baseBasalSum() + tbb = decimalFormat.format(cppTBB) + sp.putString("TBB", tbb) + } + binding.totalBaseBasal.setText(tbb) + if (!activePlugin.activePump.pumpDescription.needsManualTDDLoad) binding.reload.visibility = View.GONE + + // stats table + + // add stats headers to tables + binding.mainTable.addView( + TableRow(this).also { trHead -> + trHead.setBackgroundColor(Color.DKGRAY) + trHead.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + trHead.addView(TextView(this).also { labelDate -> + labelDate.text = resourceHelper.gs(R.string.date) + labelDate.setTextColor(Color.WHITE) + }) + trHead.addView(TextView(this).also { labelBasalRate -> + labelBasalRate.text = resourceHelper.gs(R.string.basalrate) + labelBasalRate.setTextColor(Color.WHITE) + }) + trHead.addView(TextView(this).also { labelBolus -> + labelBolus.text = resourceHelper.gs(R.string.bolus) + labelBolus.setTextColor(Color.WHITE) + }) + trHead.addView(TextView(this).also { labelTdd -> + labelTdd.text = resourceHelper.gs(R.string.tdd) + labelTdd.setTextColor(Color.WHITE) + }) + trHead.addView(TextView(this).also { labelRatio -> + labelRatio.text = resourceHelper.gs(R.string.ratio) + labelRatio.setTextColor(Color.WHITE) + }) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ) + + // cumulative table + binding.cumulativeTable.addView( + TableRow(this).also { ctrHead -> + ctrHead.setBackgroundColor(Color.DKGRAY) + ctrHead.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ctrHead.addView(TextView(this).also { labelCumAmountDays -> + labelCumAmountDays.text = resourceHelper.gs(R.string.amount_days) + labelCumAmountDays.setTextColor(Color.WHITE) + }) + ctrHead.addView(TextView(this).also { labelCumTdd -> + labelCumTdd.text = resourceHelper.gs(R.string.tdd) + labelCumTdd.setTextColor(Color.WHITE) + }) + ctrHead.addView(TextView(this).also { labelCumRatio -> + labelCumRatio.text = resourceHelper.gs(R.string.ratio) + labelCumRatio.setTextColor(Color.WHITE) + }) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ) + + // exponential table + binding.expweightTable.addView( + TableRow(this).also { etrHead -> + etrHead.setBackgroundColor(Color.DKGRAY) + etrHead.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + etrHead.addView(TextView(this).also { labelExpWeight -> + labelExpWeight.text = resourceHelper.gs(R.string.weight) + labelExpWeight.setTextColor(Color.WHITE) + }) + etrHead.addView(TextView(this).also { labelExpTdd -> + labelExpTdd.text = resourceHelper.gs(R.string.tdd) + labelExpTdd.setTextColor(Color.WHITE) + }) + etrHead.addView(TextView(this).also { labelExpRatio -> + labelExpRatio.text = resourceHelper.gs(R.string.ratio) + labelExpRatio.setTextColor(Color.WHITE) + }) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ) + + binding.reload.setOnClickListener { + binding.reload.visibility = View.GONE + binding.connectionStatus.visibility = View.VISIBLE + binding.message.visibility = View.VISIBLE + binding.message.text = resourceHelper.gs(R.string.warning_Message) + commandQueue.loadTDDs(object : Callback() { + override fun run() { + loadDataFromDB() + runOnUiThread { + binding.reload.visibility = View.VISIBLE + binding.connectionStatus.visibility = View.GONE + binding.message.visibility = View.GONE + } + } + }) + } + binding.totalBaseBasal.setOnEditorActionListener { _: TextView?, actionId: Int, _: KeyEvent? -> + if (actionId == EditorInfo.IME_ACTION_DONE) { + binding.totalBaseBasal.clearFocus() + return@setOnEditorActionListener true + } + false + } + binding.totalBaseBasal.setOnFocusChangeListener { _: View?, hasFocus: Boolean -> + if (hasFocus) { + binding.totalBaseBasal.text.clear() + } else { + sp.putString("TBB", binding.totalBaseBasal.text.toString()) + tbb = sp.getString("TBB", "") + loadDataFromDB() + val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(binding.totalBaseBasal.windowToken, 0) + } + } + loadDataFromDB() + } + + override fun onResume() { + super.onResume() + disposable.add(rxBus + .toObservable(EventPumpStatusChanged::class.java) + .observeOn(aapsSchedulers.main) + .subscribe({ event -> binding.connectionStatus.text = event.getStatus(resourceHelper) }, fabricPrivacy::logException) + ) + disposable.add(rxBus + .toObservable(EventDanaRSyncStatus::class.java) + .observeOn(aapsSchedulers.main) + .subscribe({ event -> + aapsLogger.debug("EventDanaRSyncStatus: " + event.message) + binding.connectionStatus.text = event.message + }, fabricPrivacy::logException) + ) + } + + override fun onPause() { + super.onPause() + disposable.clear() + } + + override fun dispatchTouchEvent(event: MotionEvent): Boolean { + if (event.action == MotionEvent.ACTION_DOWN) { + val myView = currentFocus + if (myView is EditText) { + val rect = Rect() + myView.getGlobalVisibleRect(rect) + if (!rect.contains(event.rawX.toInt(), event.rawY.toInt())) { + myView.clearFocus() + } + } + } + return super.dispatchTouchEvent(event) + } + + @SuppressLint("SetTextI18n") + private fun loadDataFromDB() { + historyList.clear() + historyList.addAll(databaseHelper.getTDDs()) + + //only use newest 10 + historyList = historyList.subList(0, min(10, historyList.size)) + + //fill single gaps + val df: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault()) + for (i in 0 until historyList.size - 1) { + val elem1 = historyList[i] + val elem2 = historyList[i + 1] + if (df.format(Date(elem1.date)) != df.format(Date(elem2.date + 25 * 60 * 60 * 1000))) { + val dummy = TDD() + dummy.date = elem1.date - 24 * 60 * 60 * 1000 + dummy.basal = elem1.basal / 2 + dummy.bolus = elem1.bolus / 2 + dummies.add(dummy) + elem1.basal /= 2.0 + elem1.bolus /= 2.0 + } + } + historyList.addAll(dummies) + historyList.sortWith { lhs: TDD, rhs: TDD -> (rhs.date - lhs.date).toInt() } + runOnUiThread { + cleanTable(binding.mainTable) + cleanTable(binding.cumulativeTable) + cleanTable(binding.expweightTable) + val df1: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault()) + if (TextUtils.isEmpty(tbb)) { + binding.totalBaseBasal.error = "Please Enter Total Base Basal" + return@runOnUiThread + } else { + magicNumber = SafeParse.stringToDouble(tbb) + } + magicNumber *= 2.0 + binding.totalBaseBasal2.text = decimalFormat.format(magicNumber) + var i = 0 + var sum = 0.0 + var weighted03 = 0.0 + var weighted05 = 0.0 + var weighted07 = 0.0 + + //TDD table + for (record in historyList) { + val tdd = record.getTotal() + + // Create the table row + binding.mainTable.addView( + TableRow(this@TDDStatsActivity).also { tr -> + if (i % 2 != 0) tr.setBackgroundColor(Color.DKGRAY) + if (dummies.contains(record)) + tr.setBackgroundColor(Color.argb(125, 255, 0, 0)) + + tr.id = 100 + i + tr.layoutParams = TableLayout.LayoutParams( + TableLayout.LayoutParams.MATCH_PARENT, + TableLayout.LayoutParams.WRAP_CONTENT) + + // Here create the TextView dynamically + tr.addView(TextView(this@TDDStatsActivity).also { labelDATE -> + labelDATE.id = 200 + i + labelDATE.text = df1.format(Date(record.date)) + labelDATE.setTextColor(Color.WHITE) + }) + tr.addView(TextView(this@TDDStatsActivity).also { labelBASAL -> + labelBASAL.id = 300 + i + labelBASAL.text = resourceHelper.gs(R.string.formatinsulinunits, record.basal) + labelBASAL.setTextColor(Color.WHITE) + }) + tr.addView(TextView(this@TDDStatsActivity).also { labelBOLUS -> + labelBOLUS.id = 400 + i + labelBOLUS.text = resourceHelper.gs(R.string.formatinsulinunits, record.bolus) + labelBOLUS.setTextColor(Color.WHITE) + }) + tr.addView(TextView(this@TDDStatsActivity).also { labelTDD -> + labelTDD.id = 500 + i + labelTDD.text = resourceHelper.gs(R.string.formatinsulinunits, tdd) + labelTDD.setTextColor(Color.WHITE) + }) + tr.addView(TextView(this@TDDStatsActivity).also { labelRATIO -> + labelRATIO.id = 600 + i + labelRATIO.text = (100 * tdd / magicNumber).roundToInt().toString() + "%" + labelRATIO.setTextColor(Color.WHITE) + }) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)) + i++ + } + i = 0 + + //cumulative TDDs + for (record in historyList) { + if (historyList.isNotEmpty() && df1.format(Date(record.date)) == df1.format(Date())) + //Today should not be included + continue + i++ + sum += record.getTotal() + + // Create the cumulative table row + binding.cumulativeTable.addView( + TableRow(this@TDDStatsActivity).also { ctr -> + if (i % 2 == 0) ctr.setBackgroundColor(Color.DKGRAY) + ctr.id = 700 + i + ctr.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + + // Here create the TextView dynamically + ctr.addView(TextView(this@TDDStatsActivity).also { labelDAYS -> + labelDAYS.id = 800 + i + labelDAYS.text = i.toString() + labelDAYS.setTextColor(Color.WHITE) + }) + + ctr.addView(TextView(this@TDDStatsActivity).also { labelCUMTDD -> + labelCUMTDD.id = 900 + i + labelCUMTDD.text = resourceHelper.gs(R.string.formatinsulinunits, sum / i) + labelCUMTDD.setTextColor(Color.WHITE) + }) + + ctr.addView(TextView(this@TDDStatsActivity).also { labelCUMRATIO -> + labelCUMRATIO.id = 1000 + i + labelCUMRATIO.text = (100 * sum / i / magicNumber).roundToInt().toString() + "%" + labelCUMRATIO.setTextColor(Color.WHITE) + }) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ) + } + if (isOldData(historyList) && activePlugin.activePump.pumpDescription.needsManualTDDLoad) { + binding.message.visibility = View.VISIBLE + binding.message.text = resourceHelper.gs(R.string.olddata_Message) + } else binding.mainTable.setBackgroundColor(Color.TRANSPARENT) + if (historyList.isNotEmpty() && df1.format(Date(historyList[0].date)) == df1.format(Date())) { + //Today should not be included + historyList.removeAt(0) + } + historyList.reverse() + i = 0 + for (record in historyList) { + val tdd = record.getTotal() + if (i == 0) { + weighted03 = tdd + weighted05 = tdd + weighted07 = tdd + } else { + weighted07 = weighted07 * 0.3 + tdd * 0.7 + weighted05 = weighted05 * 0.5 + tdd * 0.5 + weighted03 = weighted03 * 0.7 + tdd * 0.3 + } + i++ + } + + // Create the exponential table row + binding.expweightTable.addView( + TableRow(this@TDDStatsActivity).also { etr -> + if (i % 2 != 0) etr.setBackgroundColor(Color.DKGRAY) + etr.id = 1100 + i + etr.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + + // Here create the TextView dynamically + etr.addView(TextView(this@TDDStatsActivity).also { labelWEIGHT -> + labelWEIGHT.id = 1200 + i + labelWEIGHT.text = "0.3\n0.5\n0.7" + labelWEIGHT.setTextColor(Color.WHITE) + }) + etr.addView(TextView(this@TDDStatsActivity).also { labelEXPTDD -> + labelEXPTDD.id = 1300 + i + labelEXPTDD.text = """ + ${resourceHelper.gs(R.string.formatinsulinunits, weighted03)} + ${resourceHelper.gs(R.string.formatinsulinunits, weighted05)} + ${resourceHelper.gs(R.string.formatinsulinunits, weighted07)} + """.trimIndent() + labelEXPTDD.setTextColor(Color.WHITE) + }) + etr.addView(TextView(this@TDDStatsActivity).also { labelEXPRATIO -> + labelEXPRATIO.id = 1400 + i + labelEXPRATIO.text = """ + ${(100 * weighted03 / magicNumber).roundToInt()}% + ${(100 * weighted05 / magicNumber).roundToInt()}% + ${(100 * weighted07 / magicNumber).roundToInt()}% + """.trimIndent() + labelEXPRATIO.setTextColor(Color.WHITE) + }) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ) + } + } + + private fun cleanTable(table: TableLayout) { + val childCount = table.childCount + // Remove all rows except the first one + if (childCount > 1) table.removeViews(1, childCount - 1) + } + + private fun isOldData(historyList: List): Boolean { + val type = activePlugin.activePump.pumpDescription.pumpType + val startsYesterday = type == PumpType.DanaR || type == PumpType.DanaRS || type == PumpType.DanaRv2 || type == PumpType.DanaRKorean || type == PumpType.AccuChekInsight + val df: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault()) + return historyList.size < 3 || df.format(Date(historyList[0].date)) != df.format(Date(System.currentTimeMillis() - if (startsYesterday) 1000 * 60 * 60 * 24 else 0)) + } +} \ No newline at end of file diff --git a/core/src/main/res/layout/danar_statsactivity.xml b/core/src/main/res/layout/activity_tdd_stats.xml similarity index 58% rename from core/src/main/res/layout/danar_statsactivity.xml rename to core/src/main/res/layout/activity_tdd_stats.xml index 3b19dcc30d..f7967bfebf 100644 --- a/core/src/main/res/layout/danar_statsactivity.xml +++ b/core/src/main/res/layout/activity_tdd_stats.xml @@ -3,14 +3,15 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" - android:paddingBottom="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin" + android:paddingBottom="@dimen/activity_vertical_margin" tools:context="info.nightscout.androidaps.activities.TDDStatsActivity"> + + android:gravity="center_horizontal" + android:text="@string/tdd" + android:textColor="@color/mdtp_white" /> - + android:layout_weight="1" + android:stretchColumns="0,1,2,3,4" /> + android:layout_weight="1" + android:orientation="horizontal"> + android:layout_height="wrap_content" + android:orientation="vertical"> + android:text="@string/cumulative_tdd" + android:textColor="@color/mdtp_white" /> + android:layout_height="0dp" + android:layout_weight="1" + android:stretchColumns="0,1,2"> @@ -71,78 +71,78 @@ android:layout_height="10dp" /> + android:focusableInTouchMode="true" + android:orientation="vertical"> + android:gravity="center_horizontal" + android:text="@string/expweight" + android:textColor="@color/mdtp_white" /> - + android:layout_height="0dp" + android:layout_weight="1" + android:stretchColumns="0,1,2" /> + android:layout_height="match_parent" + android:orientation="horizontal"> + android:labelFor="@+id/total_base_basal" + android:text="@string/tbb" /> + android:gravity="center_vertical|center_horizontal" + android:inputType="numberDecimal" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="@color/mdtp_white" /> + android:layout_height="match_parent" + android:orientation="horizontal"> + android:labelFor="@+id/total_base_basal_2" + android:text="@string/tbb2" /> + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="@color/mdtp_white" /> @@ -150,52 +150,47 @@ + + android:gravity="center_horizontal" + android:orientation="vertical"> - + + + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:background="@drawable/pillborder" + android:paddingLeft="10dp" + android:paddingRight="10dp" + android:text="@string/warning_Message" + android:textColor="#ff0000" + android:textSize="15sp" + android:textStyle="bold" /> - + - + - - -