diff --git a/.gitignore b/.gitignore index affd38763c..74eb164a98 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ .gradle /local.properties .DS_Store -app/jacoco.exec +*/jacoco.exec /build /captures *.apk diff --git a/app/build.gradle b/app/build.gradle index 45e91a54d6..959dd342da 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,23 +1,18 @@ -buildscript { - repositories { - maven { url "https://plugins.gradle.org/m2/" } // jacoco 0.2 - } - - dependencies { - //classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4' - classpath 'com.hiya:jacoco-android:0.2' - } -} apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: 'com.google.gms.google-services' -//apply plugin: 'jacoco-android' apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.google.firebase.crashlytics' +apply from: "${project.rootDir}/gradle/android_dependencies.gradle" + jacoco { - toolVersion = "0.8.3" + toolVersion = "0.8.6" +} + +tasks.withType(Test) { + jacoco.includeNoLocationClasses = true } repositories { @@ -109,51 +104,20 @@ tasks.matching { it instanceof Test }.all { } android { - compileSdkVersion 28 ndkVersion "21.1.6352462" defaultConfig { - minSdkVersion 26 - targetSdkVersion 28 multiDexEnabled true versionCode 1500 - version "2.8.2.1-dev-a" + version "2.8.2.1-dev-b" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"' buildConfigField "String", "COMMITTED", '"' + allCommitted() + '"' - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - // if you change minSdkVersion to less than 11, you need to change executeTask for wear - ndk { - moduleName "BleCommandUtil" - } - } - kotlinOptions { - jvmTarget = '1.8' - } - buildFeatures { - viewBinding true - } - lintOptions { - checkReleaseBuilds false - disable 'MissingTranslation' - disable 'ExtraTranslation' - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - debug { - testCoverageEnabled(project.hasProperty('coverage')) - } - firebaseDisable { - System.setProperty("disableFirebase", "true") - ext.enableCrashlytics = false - } } + flavorDimensions "standard" productFlavors { full { @@ -197,25 +161,8 @@ android { ] } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - testOptions { - unitTests { - returnDefaultValues = true - includeAndroidResources = true - - all { - maxParallelForks = 10 - forkEvery = 20 - } - } - } useLibrary "org.apache.http.legacy" - } allprojects { @@ -241,27 +188,9 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - testImplementation "junit:junit:$junit_version" - testImplementation 'org.json:json:20201115' - testImplementation "org.mockito:mockito-core:${mockitoVersion}" - testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}" - testImplementation "org.powermock:powermock-module-junit4-rule-agent:${powermockVersion}" - testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}" - testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}" - testImplementation "joda-time:joda-time:$jodatime_version" - testImplementation('com.google.truth:truth:1.1.2') { - exclude group: "com.google.guava", module: "guava" - } - testImplementation "org.skyscreamer:jsonassert:1.5.0" - testImplementation "org.hamcrest:hamcrest-all:1.3" - - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0-alpha04' - androidTestImplementation "androidx.test.ext:junit:$androidx_junit" - androidTestImplementation "androidx.test:rules:$androidx_rules" - /* Dagger2 - We are going to use dagger.android which includes - * support for Activity and fragment injection so we need to include - * the following dependencies */ + * support for Activity and fragment injection so we need to include + * the following dependencies */ annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version" @@ -270,10 +199,11 @@ dependencies { /* Dagger2 - default dependency */ kapt "com.google.dagger:dagger-compiler:$dagger_version" - - androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' } +apply from: "${project.rootDir}/gradle/test_dependencies.gradle" + + /* // Run 'adb' shell command to clear application data of main app for 'debug' variant task clearMainAppData(type: Exec) { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cb897b727c..1abc55ecfe 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -25,6 +25,7 @@ + @@ -74,8 +75,12 @@ + android:excludeFromRecents="true" + android:exported="true" + android:launchMode="singleInstance" + android:permission="com.google.firebase.auth.api.gms.permission.LAUNCH_FEDERATED_SIGN_IN" + android:theme="@android:style/Theme.Translucent.NoTitleBar" + tools:replace="android:launchMode" /> = LinkedList() val unitLabel = if (units == Constants.MMOL) resourceHelper.gs(R.string.mmol) else resourceHelper.gs(R.string.mgdl) + val useAlarm = binding.alarmCheckBox.isChecked val activitySelected = binding.activityTt.isChecked if (activitySelected) @@ -192,6 +190,8 @@ class CarbsDialog : DialogFragmentWithDate() { val time = eventTime + timeOffset * 1000 * 60 if (timeOffset != 0) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(time)) + if (useAlarm && carbs > 0 && timeOffset > 0) + actions.add(resourceHelper.gs(R.string.alarminxmin, timeOffset).formatColor(resourceHelper, R.color.info)) val duration = binding.duration.value.toInt() if (duration > 0) actions.add(resourceHelper.gs(R.string.duration) + ": " + duration + resourceHelper.gs(R.string.shorthour)) @@ -257,6 +257,9 @@ class CarbsDialog : DialogFragmentWithDate() { nsUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset)) } } + if (useAlarm && carbs > 0 && timeOffset > 0) { + carbTimer.scheduleReminder(dateUtil._now() + T.mins(timeOffset.toLong()).msecs()) + } }, null) } } else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt index 91ced93606..74ca108a37 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt @@ -196,7 +196,7 @@ open class LoopPlugin @Inject constructor( val apsMode = sp.getString(R.string.key_aps_mode, "open") val pump = activePlugin.activePump var isLGS = false - if (!isSuspended && !pump.isSuspended) if (closedLoopEnabled.value()) if (maxIobAllowed == hardLimits.MAXIOB_LGS || apsMode == "lgs") isLGS = true + if (!isSuspended && !pump.isSuspended()) if (closedLoopEnabled.value()) if (maxIobAllowed == hardLimits.MAXIOB_LGS || apsMode == "lgs") isLGS = true return isLGS } @@ -317,7 +317,7 @@ open class LoopPlugin @Inject constructor( rxBus.send(EventLoopSetLastRunGui(resourceHelper.gs(R.string.loopsuspended))) return } - if (pump.isSuspended) { + if (pump.isSuspended()) { aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.pumpsuspended)) rxBus.send(EventLoopSetLastRunGui(resourceHelper.gs(R.string.pumpsuspended))) return @@ -511,12 +511,12 @@ open class LoopPlugin @Inject constructor( return } val pump = activePlugin.activePump - if (!pump.isInitialized) { + if (!pump.isInitialized()) { aapsLogger.debug(LTag.APS, "applyAPSRequest: " + resourceHelper.gs(R.string.pumpNotInitialized)) callback?.result(PumpEnactResult(injector).comment(resourceHelper.gs(R.string.pumpNotInitialized)).enacted(false).success(false))?.run() return } - if (pump.isSuspended) { + if (pump.isSuspended()) { aapsLogger.debug(LTag.APS, "applyAPSRequest: " + resourceHelper.gs(R.string.pumpsuspended)) callback?.result(PumpEnactResult(injector).comment(resourceHelper.gs(R.string.pumpsuspended)).enacted(false).success(false))?.run() return @@ -578,12 +578,12 @@ open class LoopPlugin @Inject constructor( .enacted(false).success(false))?.run() return } - if (!pump.isInitialized) { + if (!pump.isInitialized()) { aapsLogger.debug(LTag.APS, "applySMBRequest: " + resourceHelper.gs(R.string.pumpNotInitialized)) callback?.result(PumpEnactResult(injector).comment(resourceHelper.gs(R.string.pumpNotInitialized)).enacted(false).success(false))?.run() return } - if (pump.isSuspended) { + if (pump.isSuspended()) { aapsLogger.debug(LTag.APS, "applySMBRequest: " + resourceHelper.gs(R.string.pumpsuspended)) callback?.result(PumpEnactResult(injector).comment(resourceHelper.gs(R.string.pumpsuspended)).enacted(false).success(false))?.run() return diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.kt index 97a6079e4a..fe15677807 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.kt @@ -15,7 +15,6 @@ import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.HardLimits @@ -36,7 +35,7 @@ open class OpenAPSAMAPlugin @Inject constructor( private val profileFunction: ProfileFunction, private val context: Context, private val activePlugin: ActivePluginProvider, - private val treatmentsPlugin: TreatmentsPlugin, + private val treatmentsPlugin: TreatmentsInterface, private val iobCobCalculatorPlugin: IobCobCalculatorPlugin, private val hardLimits: HardLimits, private val profiler: Profiler, diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.kt index f1245810f0..c57e427194 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.kt @@ -17,7 +17,6 @@ import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.HardLimits import info.nightscout.androidaps.utils.Profiler @@ -37,7 +36,7 @@ open class OpenAPSSMBPlugin @Inject constructor( private val profileFunction: ProfileFunction, private val context: Context, private val activePlugin: ActivePluginProvider, - private val treatmentsPlugin: TreatmentsPlugin, + private val treatmentsPlugin: TreatmentsInterface, private val iobCobCalculatorPlugin: IobCobCalculatorPlugin, private val hardLimits: HardLimits, private val profiler: Profiler, diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt index f1a3dde59b..c2cbe83ff7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/safety/SafetyPlugin.kt @@ -13,7 +13,6 @@ import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.HardLimits import info.nightscout.androidaps.utils.Round @@ -38,7 +37,7 @@ class SafetyPlugin @Inject constructor( private val activePlugin: ActivePluginProvider, private val hardLimits: HardLimits, private val buildHelper: BuildHelper, - private val treatmentsPlugin: TreatmentsPlugin, + private val treatmentsPlugin: TreatmentsInterface, private val config: Config ) : PluginBase(PluginDescription() .mainType(PluginType.CONSTRAINTS) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index f658956b51..b0a28f92b2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -256,10 +256,10 @@ class ActionsFragment : DaggerFragment() { profileSwitch?.visibility = ( activePlugin.activeProfileInterface.profile != null && pump.pumpDescription.isSetBasalProfileCapable && - pump.isInitialized && - !pump.isSuspended).toVisibility() + pump.isInitialized() && + !pump.isSuspended()).toVisibility() - if (!pump.pumpDescription.isExtendedBolusCapable || !pump.isInitialized || pump.isSuspended || pump.isFakingTempsByExtendedBoluses) { + if (!pump.pumpDescription.isExtendedBolusCapable || !pump.isInitialized() || pump.isSuspended() || pump.isFakingTempsByExtendedBoluses) { extendedBolus?.visibility = View.GONE extendedBolusCancel?.visibility = View.GONE } else { @@ -275,7 +275,7 @@ class ActionsFragment : DaggerFragment() { } } - if (!pump.pumpDescription.isTempBasalCapable || !pump.isInitialized || pump.isSuspended) { + if (!pump.pumpDescription.isTempBasalCapable || !pump.isInitialized() || pump.isSuspended()) { setTempBasal?.visibility = View.GONE cancelTempBasal?.visibility = View.GONE } else { @@ -292,7 +292,7 @@ class ActionsFragment : DaggerFragment() { } val activeBgSource = activePlugin.activeBgSource historyBrowser?.visibility = (profile != null).toVisibility() - fill?.visibility = (pump.pumpDescription.isRefillingCapable && pump.isInitialized && !pump.isSuspended).toVisibility() + fill?.visibility = (pump.pumpDescription.isRefillingCapable && pump.isInitialized() && !pump.isSuspended()).toVisibility() pumpBatteryChange?.visibility = (pump.pumpDescription.isBatteryReplaceable || (pump is OmnipodErosPumpPlugin && pump.isUseRileyLinkBatteryLevel && pump.isBatteryChangeLoggingEnabled)).toVisibility() tempTarget?.visibility = (profile != null && config.APS).toVisibility() tddStats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt index c387e70f33..93411a1275 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt @@ -5,14 +5,16 @@ import android.widget.LinearLayout import androidx.annotation.DrawableRes import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.elements.InputString import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder import info.nightscout.androidaps.queue.Callback +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.JsonHelper +import info.nightscout.androidaps.utils.T +import info.nightscout.androidaps.utils.TimerUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import org.json.JSONObject import javax.inject.Inject @@ -22,6 +24,7 @@ class ActionAlarm(injector: HasAndroidInjector) : Action(injector) { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var context: Context + @Inject lateinit var timerUtil: TimerUtil var text = InputString(injector) @@ -33,10 +36,11 @@ class ActionAlarm(injector: HasAndroidInjector) : Action(injector) { override fun shortDescription(): String = resourceHelper.gs(R.string.alarm_message, text.value) @DrawableRes override fun icon(): Int = R.drawable.ic_access_alarm_24dp - override fun isValid(): Boolean = text.value.isNotEmpty() + override fun isValid(): Boolean = true // empty alarm will show app name override fun doAction(callback: Callback) { - ErrorHelperActivity.runAlarm(context, text.value, resourceHelper.gs(R.string.alarm), R.raw.modern_alarm) + timerUtil.scheduleReminder(DateUtil.now() + T.secs(10L).msecs(), text.value.takeIf { it.isNotBlank() } + ?: resourceHelper.gs(R.string.app_name)) callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt index fce6bb41c4..def0d59a6c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt @@ -11,15 +11,15 @@ import com.google.common.base.Optional import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.interfaces.TreatmentsInterface import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.plugins.general.automation.dialogs.ChooseTriggerDialog import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerChanged import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerClone import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerRemove import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.services.LastLocationDataContainer import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -29,13 +29,14 @@ import javax.inject.Inject import kotlin.reflect.full.primaryConstructor abstract class Trigger(val injector: HasAndroidInjector) { + @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var sp: SP @Inject lateinit var locationDataContainer: LastLocationDataContainer - @Inject lateinit var treatmentsPlugin: TreatmentsPlugin + @Inject lateinit var treatmentsInterface: TreatmentsInterface @Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin @@ -53,12 +54,13 @@ abstract class Trigger(val injector: HasAndroidInjector) { abstract fun duplicate(): Trigger companion object { + @JvmStatic fun scanForActivity(cont: Context?): AppCompatActivity? { when (cont) { - null -> return null + null -> return null is AppCompatActivity -> return cont - is ContextWrapper -> return scanForActivity(cont.baseContext) + is ContextWrapper -> return scanForActivity(cont.baseContext) else -> return null } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt index 27f736cf9a..5ff50b561c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt @@ -35,7 +35,7 @@ class TriggerBolusAgo(injector: HasAndroidInjector) : Trigger(injector) { } override fun shouldRun(): Boolean { - val lastBolusTime = treatmentsPlugin.getLastBolusTime(true) + val lastBolusTime = treatmentsInterface.getLastBolusTime(true) if (lastBolusTime == 0L) return if (comparator.value == Comparator.Compare.IS_NOT_AVAILABLE) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt index 26aa0c81b7..25ef553816 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt @@ -28,7 +28,7 @@ class TriggerTempTarget(injector: HasAndroidInjector) : Trigger(injector) { } override fun shouldRun(): Boolean { - val tt = treatmentsPlugin.tempTargetFromHistory + val tt = treatmentsInterface.tempTargetFromHistory if (tt == null && comparator.value == ComparatorExists.Compare.NOT_EXISTS) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) return true diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/openhumans/OpenHumansUploader.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/openhumans/OpenHumansUploader.kt index ecd151e426..31aa345d65 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/openhumans/OpenHumansUploader.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/openhumans/OpenHumansUploader.kt @@ -363,7 +363,7 @@ class OpenHumansUploader @Inject constructor( copyDisposable = Completable.fromCallable { MainApp.getDbHelper().clearOpenHumansQueue() } .andThen(Single.defer { Single.just(MainApp.getDbHelper().countOfAllRows + treatmentsPlugin.service.count()) }) .doOnSuccess { maxProgress = it } - .flatMapObservable { Observable.defer { Observable.fromIterable(treatmentsPlugin.service.treatmentData) } } + .flatMapObservable { Observable.defer { Observable.fromIterable(treatmentsPlugin.service.getTreatmentData()) } } .map { enqueueTreatment(it); increaseCounter() } .ignoreElements() .andThen(Observable.defer { Observable.fromIterable(repository.compatGetBgReadingsDataFromTime(0, true).blockingGet()) }) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 0a427d0da0..7dd0ea848a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -446,7 +446,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList // QuickWizard button val quickWizardEntry = quickWizard.getActive() - if (quickWizardEntry != null && lastBG != null && profile != null && pump.isInitialized && !pump.isSuspended) { + if (quickWizardEntry != null && lastBG != null && profile != null && pump.isInitialized() && !pump.isSuspended()) { binding.buttonsLayout.quickWizardButton.visibility = View.VISIBLE val wizard = quickWizardEntry.doCalc(profile, profileName, lastBG, false) binding.buttonsLayout.quickWizardButton.text = quickWizardEntry.buttonText() + "\n" + resourceHelper.gs(R.string.format_carbs, quickWizardEntry.carbs()) + @@ -463,7 +463,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList (lastRun.lastOpenModeAccept == 0L || lastRun.lastOpenModeAccept < lastRun.lastAPSRun) &&// never accepted or before last result lastRun.constraintsProcessed?.isChangeRequested == true // change is requested - if (showAcceptButton && pump.isInitialized && !pump.isSuspended && loopPlugin.isEnabled(PluginType.LOOP)) { + if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && loopPlugin.isEnabled(PluginType.LOOP)) { binding.buttonsLayout.acceptTempButton.visibility = View.VISIBLE binding.buttonsLayout.acceptTempButton.text = "${resourceHelper.gs(R.string.setbasalquestion)}\n${lastRun!!.constraintsProcessed}" } else { @@ -471,10 +471,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } // **** Various treatment buttons **** - binding.buttonsLayout.carbsButton.visibility = ((!activePlugin.activePump.pumpDescription.storesCarbInfo || pump.isInitialized && !pump.isSuspended) && profile != null && sp.getBoolean(R.string.key_show_carbs_button, true)).toVisibility() - binding.buttonsLayout.treatmentButton.visibility = (pump.isInitialized && !pump.isSuspended && profile != null && sp.getBoolean(R.string.key_show_treatment_button, false)).toVisibility() - binding.buttonsLayout.wizardButton.visibility = (pump.isInitialized && !pump.isSuspended && profile != null && sp.getBoolean(R.string.key_show_wizard_button, true)).toVisibility() - binding.buttonsLayout.insulinButton.visibility = (pump.isInitialized && !pump.isSuspended && profile != null && sp.getBoolean(R.string.key_show_insulin_button, true)).toVisibility() + binding.buttonsLayout.carbsButton.visibility = ((!activePlugin.activePump.pumpDescription.storesCarbInfo || pump.isInitialized() && !pump.isSuspended()) && profile != null && sp.getBoolean(R.string.key_show_carbs_button, true)).toVisibility() + binding.buttonsLayout.treatmentButton.visibility = (pump.isInitialized() && !pump.isSuspended() && profile != null && sp.getBoolean(R.string.key_show_treatment_button, false)).toVisibility() + binding.buttonsLayout.wizardButton.visibility = (pump.isInitialized() && !pump.isSuspended() && profile != null && sp.getBoolean(R.string.key_show_wizard_button, true)).toVisibility() + binding.buttonsLayout.insulinButton.visibility = (pump.isInitialized() && !pump.isSuspended() && profile != null && sp.getBoolean(R.string.key_show_insulin_button, true)).toVisibility() // **** Calibration & CGM buttons **** val xDripIsBgSource = xdripPlugin.isEnabled(PluginType.BGSOURCE) @@ -633,7 +633,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList binding.infoLayout.apsModeText.visibility = View.VISIBLE } - pump.isSuspended -> { + pump.isSuspended() -> { binding.infoLayout.apsMode.setImageResource(if (pump.pumpDescription.pumpType == PumpType.Insulet_Omnipod) { // For Omnipod, indicate the pump as disconnected when it's suspended. // The only way to 'reconnect' it, is through the Omnipod tab @@ -898,8 +898,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList menuChartSettings[g + 1][OverviewMenus.CharType.BGI.ordinal] -> useBGIForScale = true menuChartSettings[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] -> useDSForScale = true } - var alignIobScale = menuChartSettings[g + 1][OverviewMenus.CharType.ABS.ordinal] && menuChartSettings[g + 1][OverviewMenus.CharType.IOB.ordinal] - var alignDevBgiScale = menuChartSettings[g + 1][OverviewMenus.CharType.DEV.ordinal] && menuChartSettings[g + 1][OverviewMenus.CharType.BGI.ordinal] + val alignIobScale = menuChartSettings[g + 1][OverviewMenus.CharType.ABS.ordinal] && menuChartSettings[g + 1][OverviewMenus.CharType.IOB.ordinal] + val alignDevBgiScale = menuChartSettings[g + 1][OverviewMenus.CharType.DEV.ordinal] && menuChartSettings[g + 1][OverviewMenus.CharType.BGI.ordinal] if (menuChartSettings[g + 1][OverviewMenus.CharType.ABS.ordinal]) secondGraphData.addAbsIob(fromTime, now, useABSForScale, 1.0) if (menuChartSettings[g + 1][OverviewMenus.CharType.IOB.ordinal]) secondGraphData.addIob(fromTime, now, useIobForScale, 1.0, menuChartSettings[g + 1][OverviewMenus.CharType.PRE.ordinal], alignIobScale) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index 9f22e361b0..c44460c604 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -33,17 +33,16 @@ import info.nightscout.androidaps.plugins.general.smsCommunicator.events.EventSm import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePassword import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.receivers.BundleStore import info.nightscout.androidaps.receivers.DataReceiver import info.nightscout.androidaps.utils.* -import io.reactivex.rxkotlin.plusAssign import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference import io.reactivex.disposables.CompositeDisposable +import io.reactivex.rxkotlin.plusAssign import org.apache.commons.lang3.StringUtils import java.text.Normalizer import java.util.* @@ -270,7 +269,7 @@ class SmsCommunicatorPlugin @Inject constructor( "BOLUS" -> if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_remotecommandnotallowed))) else if (divided.size == 2 && DateUtil.now() - lastRemoteBolusTime < minDistance) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_remotebolusnotallowed))) - else if (divided.size == 2 && pump.isSuspended) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.pumpsuspended))) + else if (divided.size == 2 && pump.isSuspended()) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.pumpsuspended))) else if (divided.size == 2 || divided.size == 3) processBOLUS(divided, receivedSms) else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) "CARBS" -> @@ -450,7 +449,7 @@ class SmsCommunicatorPlugin @Inject constructor( private fun processTREATMENTS(divided: Array, receivedSms: Sms) { if (divided[1].toUpperCase(Locale.getDefault()) == "REFRESH") { - (activePlugin.activeTreatments as TreatmentsPlugin).service.resetTreatments() + activePlugin.activeTreatments.service.resetTreatments() rxBus.send(EventNSClientRestart()) sendSMS(Sms(receivedSms.phoneNumber, "TREATMENTS REFRESH SENT")) receivedSms.processed = true @@ -589,9 +588,10 @@ class SmsCommunicatorPlugin @Inject constructor( val finalPercentage = percentage messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(list[pindex - 1] as String, finalPercentage) { override fun run() { - uel.log("SMS PROFILE", reply) activePlugin.activeTreatments.doProfileSwitch(store, list[pindex - 1] as String, 0, finalPercentage, 0, DateUtil.now()) - sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.profileswitchcreated))) + val replyText = resourceHelper.gs(R.string.profileswitchcreated) + sendSMS(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS PROFILE", replyText) } }) } @@ -607,17 +607,18 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log("SMS BASAL", reply) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (result.success) { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcanceled) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS BASAL", replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS BASAL", replyText) } } }) @@ -639,17 +640,18 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(tempBasalPct, duration) { override fun run() { - uel.log("SMS BASAL", reply) commandQueue.tempBasalPercent(anInteger(), secondInteger(), true, profile, object : Callback() { override fun run() { if (result.success) { var replyText = if (result.isPercent) String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent), result.percent, result.duration) else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS BASAL", replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS BASAL", replyText) } } }) @@ -672,7 +674,6 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(tempBasal, duration) { override fun run() { - uel.log("SMS BASAL", reply) commandQueue.tempBasalAbsolute(aDouble(), secondInteger(), true, profile, object : Callback() { override fun run() { if (result.success) { @@ -680,10 +681,12 @@ class SmsCommunicatorPlugin @Inject constructor( else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS BASAL", replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS BASAL", replyText) } } }) @@ -700,7 +703,6 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log("SMS EXTENDED", reply) commandQueue.cancelExtended(object : Callback() { override fun run() { if (result.success) { @@ -711,6 +713,7 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = resourceHelper.gs(R.string.smscommunicator_extendedcancelfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS EXTENDED", replyText) } } }) @@ -729,7 +732,6 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(extended, duration) { override fun run() { - uel.log("SMS EXTENDED", reply) commandQueue.extendedBolus(aDouble(), secondInteger(), object : Callback() { override fun run() { if (result.success) { @@ -737,10 +739,12 @@ class SmsCommunicatorPlugin @Inject constructor( if (config.APS) replyText += "\n" + resourceHelper.gs(R.string.loopsuspended) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS EXTENDED", replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS EXTENDED", replyText) } } }) @@ -765,7 +769,6 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(bolus) { override fun run() { - uel.log("SMS BOLUS", reply) val detailedBolusInfo = DetailedBolusInfo() detailedBolusInfo.insulin = aDouble() detailedBolusInfo.source = Source.USER @@ -810,10 +813,12 @@ class SmsCommunicatorPlugin @Inject constructor( } } sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS BOLUS", replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS BOLUS", replyText) } } }) @@ -842,7 +847,6 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(grams, time) { override fun run() { - uel.log("SMS CARBS", reply) val detailedBolusInfo = DetailedBolusInfo() detailedBolusInfo.carbs = anInteger().toDouble() detailedBolusInfo.source = Source.USER @@ -854,10 +858,12 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS CARBS", replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS CARBS", replyText) } } }) @@ -866,6 +872,7 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS CARBS", replyText) } } }) @@ -883,7 +890,6 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log("SMS TARGET", reply) val units = profileFunction.getUnits() var keyDuration = 0 var defaultTargetDuration = 0 @@ -931,6 +937,7 @@ class SmsCommunicatorPlugin @Inject constructor( val ttString = if (units == Constants.MMOL) DecimalFormatter.to1Decimal(tt) else DecimalFormatter.to0Decimal(tt) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_set), ttString, ttDuration) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS TARGET", replyText) } }) } else if (isStop) { @@ -939,7 +946,6 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log("SMS TARGET", reply) val tempTarget = TempTarget() .source(Source.USER) .date(DateUtil.now()) @@ -949,6 +955,7 @@ class SmsCommunicatorPlugin @Inject constructor( activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS TARGET", reply) } }) } else @@ -964,10 +971,10 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log("SMS SMS", reply) sp.putBoolean(R.string.key_smscommunicator_remotecommandsallowed, false) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_stoppedsms)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS SMS", replyText) } }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) @@ -981,9 +988,11 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(cal) { override fun run() { - uel.log("SMS CAL", reply) val result = xdripCalibrations.sendIntent(aDouble!!) - if (result) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_calibrationsent))) else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_calibrationfailed))) + val replyText = + if (result) resourceHelper.gs(R.string.smscommunicator_calibrationsent) else resourceHelper.gs(R.string.smscommunicator_calibrationfailed) + sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) + uel.log("SMS CAL", replyText) } }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt index 7a4e014024..2fbdbe6360 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt @@ -50,7 +50,7 @@ import javax.inject.Singleton class ActionStringHandler @Inject constructor( private val sp: SP, private val rxBus: RxBusWrapper, - private val aapsSchedulers: AapsSchedulers, + aapsSchedulers: AapsSchedulers, private val resourceHelper: ResourceHelper, private val injector: HasAndroidInjector, private val context: Context, @@ -262,7 +262,7 @@ class ActionStringHandler @Inject constructor( rAction = "statusmessage" rMessage = "OLD DATA - " //if pump is not busy: try to fetch data - if (activePump.isBusy) { + if (activePump.isBusy()) { rMessage += resourceHelper.gs(R.string.pumpbusy) } else { rMessage += "trying to fetch data from pump." diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java index 15ae4409ad..354468f7aa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java @@ -41,6 +41,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpPluginBase; +import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; @@ -80,7 +81,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr private final ResourceHelper resourceHelper; private final ProfileFunction profileFunction; - private final TreatmentsPlugin treatmentsPlugin; + private final TreatmentsInterface treatmentsPlugin; private final info.nightscout.androidaps.utils.sharedPreferences.SP sp; private RxBusWrapper rxBus; private final CommandQueueProvider commandQueue; @@ -136,7 +137,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr RxBusWrapper rxBus, ResourceHelper resourceHelper, ProfileFunction profileFunction, - TreatmentsPlugin treatmentsPlugin, + TreatmentsInterface treatmentsPlugin, SP sp, CommandQueueProvider commandQueue, Context context diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index f5b46ffc9e..638439e728 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -49,6 +49,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpPluginBase; +import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; @@ -129,7 +130,6 @@ import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_erro import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.NoActiveTBRToCanceLException; import info.nightscout.androidaps.plugins.pump.insight.utils.ExceptionTranslator; import info.nightscout.androidaps.plugins.pump.insight.utils.ParameterBlockUtil; -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.TimeChangeType; import info.nightscout.androidaps.utils.resources.ResourceHelper; @@ -141,7 +141,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, private final AAPSLogger aapsLogger; private final RxBusWrapper rxBus; private final ResourceHelper resourceHelper; - private final TreatmentsPlugin treatmentsPlugin; + private final TreatmentsInterface treatmentsPlugin; private final SP sp; private final CommandQueueProvider commandQueue; private final ProfileFunction profileFunction; @@ -203,7 +203,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, AAPSLogger aapsLogger, RxBusWrapper rxBus, ResourceHelper resourceHelper, - TreatmentsPlugin treatmentsPlugin, + TreatmentsInterface treatmentsPlugin, SP sp, CommandQueueProvider commandQueue, ProfileFunction profileFunction, diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java deleted file mode 100644 index 143d60d606..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java +++ /dev/null @@ -1,280 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.mdi; - -import androidx.annotation.NonNull; - -import org.json.JSONException; -import org.json.JSONObject; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import dagger.android.HasAndroidInjector; -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.data.DetailedBolusInfo; -import info.nightscout.androidaps.data.Profile; -import info.nightscout.androidaps.data.PumpEnactResult; -import info.nightscout.androidaps.interfaces.CommandQueueProvider; -import info.nightscout.androidaps.interfaces.PluginDescription; -import info.nightscout.androidaps.interfaces.PluginType; -import info.nightscout.androidaps.interfaces.PumpDescription; -import info.nightscout.androidaps.interfaces.PumpInterface; -import info.nightscout.androidaps.interfaces.PumpPluginBase; -import info.nightscout.androidaps.logging.AAPSLogger; -import info.nightscout.androidaps.logging.LTag; -import info.nightscout.androidaps.plugins.common.ManufacturerType; -import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; -import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; -import info.nightscout.androidaps.utils.DateUtil; -import info.nightscout.androidaps.utils.InstanceId; -import info.nightscout.androidaps.utils.TimeChangeType; -import info.nightscout.androidaps.utils.resources.ResourceHelper; - - -/** - * Created by mike on 05.08.2016. - */ -@Singleton -public class MDIPlugin extends PumpPluginBase implements PumpInterface { - - private final TreatmentsPlugin treatmentsPlugin; - private final PumpDescription pumpDescription = new PumpDescription(); - - @Inject - public MDIPlugin( - HasAndroidInjector injector, - AAPSLogger aapsLogger, - ResourceHelper resourceHelper, - CommandQueueProvider commandQueue, - TreatmentsPlugin treatmentsPlugin - ) { - super(new PluginDescription() - .mainType(PluginType.PUMP) - .pluginIcon(R.drawable.ic_ict) - .pluginName(R.string.mdi) - .description(R.string.description_pump_mdi), - injector, aapsLogger, resourceHelper, commandQueue - ); - this.treatmentsPlugin = treatmentsPlugin; - - pumpDescription.isBolusCapable = true; - pumpDescription.bolusStep = 0.5d; - - pumpDescription.isExtendedBolusCapable = false; - pumpDescription.isTempBasalCapable = false; - pumpDescription.isSetBasalProfileCapable = false; - pumpDescription.isRefillingCapable = false; - pumpDescription.isBatteryReplaceable = false; - } - - @Override - public boolean isFakingTempsByExtendedBoluses() { - return false; - } - - @NonNull @Override - public PumpEnactResult loadTDDs() { - //no result, could read DB in the future? - return new PumpEnactResult(getInjector()); - } - - @Override - public boolean isInitialized() { - return true; - } - - @Override - public boolean isSuspended() { - return false; - } - - @Override - public boolean isBusy() { - return false; - } - - @Override - public boolean isConnected() { - return true; - } - - @Override - public boolean isConnecting() { - return false; - } - - @Override - public boolean isHandshakeInProgress() { - return false; - } - - @Override - public void connect(@NonNull String reason) { - } - - @Override - public void disconnect(@NonNull String reason) { - } - - @Override public int waitForDisconnectionInSeconds() { - return 0; - } - - @Override - public void stopConnecting() { - } - - @Override - public void getPumpStatus(@NonNull String reason) { - } - - @NonNull @Override - public PumpEnactResult setNewBasalProfile(@NonNull Profile profile) { - // Do nothing here. we are using ConfigBuilderPlugin.getPlugin().getActiveProfile().getProfile(); - PumpEnactResult result = new PumpEnactResult(getInjector()); - result.success = true; - return result; - } - - @Override - public boolean isThisProfileSet(@NonNull Profile profile) { - return false; - } - - @Override - public long lastDataTime() { - return System.currentTimeMillis(); - } - - @Override - public double getBaseBasalRate() { - return 0d; - } - - @Override - public double getReservoirLevel() { - return -1; - } - - @Override - public int getBatteryLevel() { - return -1; - } - - @NonNull @Override - public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { - PumpEnactResult result = new PumpEnactResult(getInjector()); - result.success = true; - result.bolusDelivered = detailedBolusInfo.insulin; - result.carbsDelivered = detailedBolusInfo.carbs; - result.comment = getResourceHelper().gs(R.string.virtualpump_resultok); - treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false); - return result; - } - - @Override - public void stopBolusDelivering() { - } - - @NonNull @Override - public PumpEnactResult setTempBasalAbsolute(double absoluteRate, int durationInMinutes, @NonNull Profile profile, boolean enforceNew) { - PumpEnactResult result = new PumpEnactResult(getInjector()); - result.success = false; - result.comment = getResourceHelper().gs(R.string.pumperror); - getAapsLogger().debug(LTag.PUMPBTCOMM, "Setting temp basal absolute: " + result); - return result; - } - - @NonNull @Override - public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean enforceNew) { - PumpEnactResult result = new PumpEnactResult(getInjector()); - result.success = false; - result.comment = getResourceHelper().gs(R.string.pumperror); - getAapsLogger().debug(LTag.PUMPBTCOMM, "Settings temp basal percent: " + result); - return result; - } - - @NonNull @Override - public PumpEnactResult setExtendedBolus(double insulin, int durationInMinutes) { - PumpEnactResult result = new PumpEnactResult(getInjector()); - result.success = false; - result.comment = getResourceHelper().gs(R.string.pumperror); - getAapsLogger().debug(LTag.PUMPBTCOMM, "Setting extended bolus: " + result); - return result; - } - - @NonNull @Override - public PumpEnactResult cancelTempBasal(boolean force) { - PumpEnactResult result = new PumpEnactResult(getInjector()); - result.success = false; - result.comment = getResourceHelper().gs(R.string.pumperror); - getAapsLogger().debug(LTag.PUMPBTCOMM, "Cancel temp basal: " + result); - return result; - } - - @NonNull @Override - public PumpEnactResult cancelExtendedBolus() { - PumpEnactResult result = new PumpEnactResult(getInjector()); - result.success = false; - result.comment = getResourceHelper().gs(R.string.pumperror); - getAapsLogger().debug(LTag.PUMPBTCOMM, "Canceling extended bolus: " + result); - return result; - } - - @NonNull @Override - public JSONObject getJSONStatus(@NonNull Profile profile, @NonNull String profileName, @NonNull String version) { - long now = System.currentTimeMillis(); - JSONObject pump = new JSONObject(); - JSONObject status = new JSONObject(); - JSONObject extended = new JSONObject(); - try { - status.put("status", "normal"); - extended.put("Version", version); - extended.put("ActiveProfile", profileName); - status.put("timestamp", DateUtil.toISOString(now)); - - pump.put("status", status); - pump.put("extended", extended); - pump.put("clock", DateUtil.toISOString(now)); - } catch (JSONException e) { - getAapsLogger().error("Exception: ", e); - } - return pump; - } - - @NonNull @Override - public ManufacturerType manufacturer() { - return ManufacturerType.AndroidAPS; - } - - @NonNull @Override - public PumpType model() { - return PumpType.MDI; - } - - @NonNull @Override - public String serialNumber() { - return InstanceId.INSTANCE.instanceId(); - } - - @NonNull @Override - public PumpDescription getPumpDescription() { - return pumpDescription; - } - - @NonNull @Override - public String shortStatus(boolean veryShort) { - return model().getModel(); - } - - @Override - public boolean canHandleDST() { - return true; - } - - @Override - public void timezoneOrDSTChanged(@NonNull TimeChangeType changeType) { - - } - - -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.kt new file mode 100644 index 0000000000..ea7b47f332 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.kt @@ -0,0 +1,145 @@ +package info.nightscout.androidaps.plugins.pump.mdi + +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.R +import info.nightscout.androidaps.data.DetailedBolusInfo +import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.data.PumpEnactResult +import info.nightscout.androidaps.interfaces.* +import info.nightscout.androidaps.logging.AAPSLogger +import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.plugins.common.ManufacturerType +import info.nightscout.androidaps.plugins.pump.common.defs.PumpType +import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin +import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.InstanceId.instanceId +import info.nightscout.androidaps.utils.resources.ResourceHelper +import org.json.JSONException +import org.json.JSONObject +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class MDIPlugin @Inject constructor( + injector: HasAndroidInjector, + aapsLogger: AAPSLogger, + resourceHelper: ResourceHelper, + commandQueue: CommandQueueProvider, + private val treatmentsPlugin: TreatmentsPlugin +) : PumpPluginBase(PluginDescription() + .mainType(PluginType.PUMP) + .pluginIcon(R.drawable.ic_ict) + .pluginName(R.string.mdi) + .description(R.string.description_pump_mdi), + injector, aapsLogger, resourceHelper, commandQueue +), PumpInterface { + + override val pumpDescription = PumpDescription() + + init { + pumpDescription.isBolusCapable = true + pumpDescription.bolusStep = 0.5 + pumpDescription.isExtendedBolusCapable = false + pumpDescription.isTempBasalCapable = false + pumpDescription.isSetBasalProfileCapable = false + pumpDescription.isRefillingCapable = false + pumpDescription.isBatteryReplaceable = false + } + + override val isFakingTempsByExtendedBoluses: Boolean = false + + override fun loadTDDs(): PumpEnactResult = PumpEnactResult(injector) + override fun isInitialized(): Boolean = true + override fun isSuspended(): Boolean = false + override fun isBusy(): Boolean = false + override fun isConnected(): Boolean = true + override fun isConnecting(): Boolean = false + override fun isHandshakeInProgress(): Boolean = false + override fun connect(reason: String) {} + override fun disconnect(reason: String) {} + override fun waitForDisconnectionInSeconds(): Int = 0 + override fun stopConnecting() {} + override fun getPumpStatus(reason: String) {} + override fun setNewBasalProfile(profile: Profile): PumpEnactResult = PumpEnactResult(injector).success(true) + override fun isThisProfileSet(profile: Profile): Boolean = false + override fun lastDataTime(): Long = System.currentTimeMillis() + override val baseBasalRate: Double = 0.0 + override val reservoirLevel: Double = -1.0 + override val batteryLevel: Int = -1 + + override fun deliverTreatment(detailedBolusInfo: DetailedBolusInfo): PumpEnactResult { + val result = PumpEnactResult(injector) + result.success = true + result.bolusDelivered = detailedBolusInfo.insulin + result.carbsDelivered = detailedBolusInfo.carbs + result.comment = resourceHelper.gs(R.string.virtualpump_resultok) + treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false) + return result + } + + override fun stopBolusDelivering() {} + override fun setTempBasalAbsolute(absoluteRate: Double, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult { + val result = PumpEnactResult(injector) + result.success = false + result.comment = resourceHelper.gs(R.string.pumperror) + aapsLogger.debug(LTag.PUMPBTCOMM, "Setting temp basal absolute: $result") + return result + } + + override fun setTempBasalPercent(percent: Int, durationInMinutes: Int, profile: Profile, enforceNew: Boolean): PumpEnactResult { + val result = PumpEnactResult(injector) + result.success = false + result.comment = resourceHelper.gs(R.string.pumperror) + aapsLogger.debug(LTag.PUMPBTCOMM, "Settings temp basal percent: $result") + return result + } + + override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult { + val result = PumpEnactResult(injector) + result.success = false + result.comment = resourceHelper.gs(R.string.pumperror) + aapsLogger.debug(LTag.PUMPBTCOMM, "Setting extended bolus: $result") + return result + } + + override fun cancelTempBasal(enforceNew: Boolean): PumpEnactResult { + val result = PumpEnactResult(injector) + result.success = false + result.comment = resourceHelper.gs(R.string.pumperror) + aapsLogger.debug(LTag.PUMPBTCOMM, "Cancel temp basal: $result") + return result + } + + override fun cancelExtendedBolus(): PumpEnactResult { + val result = PumpEnactResult(injector) + result.success = false + result.comment = resourceHelper.gs(R.string.pumperror) + aapsLogger.debug(LTag.PUMPBTCOMM, "Canceling extended bolus: $result") + return result + } + + override fun getJSONStatus(profile: Profile, profileName: String, version: String): JSONObject { + val now = System.currentTimeMillis() + val pump = JSONObject() + val status = JSONObject() + val extended = JSONObject() + try { + status.put("status", "normal") + extended.put("Version", version) + extended.put("ActiveProfile", profileName) + status.put("timestamp", DateUtil.toISOString(now)) + pump.put("status", status) + pump.put("extended", extended) + pump.put("clock", DateUtil.toISOString(now)) + } catch (e: JSONException) { + aapsLogger.error("Exception: ", e) + } + return pump + } + + override fun manufacturer(): ManufacturerType = ManufacturerType.AndroidAPS + override fun model(): PumpType = PumpType.MDI + override fun serialNumber(): String = instanceId() + override fun shortStatus(veryShort: Boolean): String = model().model + override fun canHandleDST(): Boolean = true +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt index 48a9bbc942..50af5cb9f0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt @@ -133,12 +133,12 @@ class VirtualPumpPlugin @Inject constructor( return PumpEnactResult(injector) } - override val isInitialized: Boolean = true - override val isSuspended: Boolean = false - override val isBusy: Boolean = false - override val isConnected: Boolean = true - override val isConnecting: Boolean = false - override val isHandshakeInProgress: Boolean = false + override fun isInitialized(): Boolean = true + override fun isSuspended(): Boolean = false + override fun isBusy(): Boolean = false + override fun isConnected(): Boolean = true + override fun isConnecting(): Boolean = false + override fun isHandshakeInProgress(): Boolean = false override fun connect(reason: String) { //if (!Config.NSCLIENT) NSUpload.uploadDeviceStatus() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java index 49d1070b7d..a4f85e3882 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentService.java @@ -16,6 +16,7 @@ import com.j256.ormlite.support.ConnectionSource; import com.j256.ormlite.table.TableUtils; import org.apache.commons.lang3.StringUtils; +import org.jetbrains.annotations.NotNull; import org.json.JSONException; import org.json.JSONObject; @@ -39,6 +40,8 @@ import info.nightscout.androidaps.events.EventNsTreatment; import info.nightscout.androidaps.events.EventReloadTreatmentData; import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; +import info.nightscout.androidaps.interfaces.TreatmentServiceInterface; +import info.nightscout.androidaps.interfaces.UpdateReturn; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; @@ -57,7 +60,7 @@ import io.reactivex.disposables.CompositeDisposable; * Created by mike on 24.09.2017. */ -public class TreatmentService extends OrmLiteBaseService { +public class TreatmentService extends OrmLiteBaseService implements TreatmentServiceInterface { @Inject AAPSLogger aapsLogger; @Inject FabricPrivacy fabricPrivacy; @@ -471,7 +474,7 @@ public class TreatmentService extends OrmLiteBaseService { } - public UpdateReturn createOrUpdateMedtronic(Treatment treatment, boolean fromNightScout) { + @NotNull public UpdateReturn createOrUpdateMedtronic(@NotNull Treatment treatment, boolean fromNightScout) { if (MedtronicHistoryData.doubleBolusDebug) aapsLogger.debug(LTag.DATATREATMENTS, "DoubleBolusDebug: createOrUpdateMedtronic:: originalTreatment={}, fromNightScout={}", treatment, fromNightScout); @@ -821,22 +824,4 @@ public class TreatmentService extends OrmLiteBaseService { return null; } - public class UpdateReturn { - public UpdateReturn(boolean success, boolean newRecord) { - this.success = success; - this.newRecord = newRecord; - } - - boolean newRecord; - boolean success; - - @Override - public String toString() { - return "UpdateReturn [" + - "newRecord=" + newRecord + - ", success=" + success + - ']'; - } - } - } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java index dbb4846bde..41e3673493 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsPlugin.java @@ -46,7 +46,9 @@ import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.interfaces.ProfileStore; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.interfaces.TreatmentServiceInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface; +import info.nightscout.androidaps.interfaces.UpdateReturn; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; @@ -82,7 +84,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface private final CompositeDisposable disposable = new CompositeDisposable(); - protected TreatmentService service; + protected TreatmentServiceInterface service; private IobTotal lastTreatmentCalculation; private IobTotal lastTempBasalsCalculation; @@ -180,7 +182,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface super.onStop(); } - public TreatmentService getService() { + @Override + public TreatmentServiceInterface getService() { return this.service; } @@ -620,9 +623,9 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface } public TreatmentUpdateReturn createOrUpdateMedtronic(Treatment treatment, boolean fromNightScout) { - TreatmentService.UpdateReturn resultRecord = getService().createOrUpdateMedtronic(treatment, fromNightScout); + UpdateReturn resultRecord = getService().createOrUpdateMedtronic(treatment, fromNightScout); - return new TreatmentUpdateReturn(resultRecord.success, resultRecord.newRecord); + return new TreatmentUpdateReturn(resultRecord.getSuccess(), resultRecord.getNewRecord()); } // return true if new record is created @@ -643,7 +646,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface treatment.carbs = detailedBolusInfo.carbs; treatment.mealBolus = treatment.carbs > 0; treatment.boluscalc = detailedBolusInfo.boluscalc != null ? detailedBolusInfo.boluscalc.toString() : null; - TreatmentService.UpdateReturn creatOrUpdateResult; + UpdateReturn creatOrUpdateResult; getAapsLogger().debug(medtronicPump && MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: addToHistoryTreatment::treatment={} " + treatment); @@ -652,7 +655,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface else creatOrUpdateResult = getService().createOrUpdateMedtronic(treatment, false); - boolean newRecordCreated = creatOrUpdateResult.newRecord; + boolean newRecordCreated = creatOrUpdateResult.getNewRecord(); //log.debug("Adding new Treatment record" + treatment.toString()); if (detailedBolusInfo.carbTime != 0) { @@ -673,7 +676,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface if (newRecordCreated && detailedBolusInfo.isValid) nsUpload.uploadTreatmentRecord(detailedBolusInfo); - if (!allowUpdate && !creatOrUpdateResult.success) { + if (!allowUpdate && !creatOrUpdateResult.getSuccess()) { getAapsLogger().error("Treatment could not be added to DB", new Exception()); String status = String.format(resourceHelper.gs(R.string.error_adding_treatment_message), treatment.insulin, (int) treatment.carbs, dateUtil.dateAndTimeString(treatment.date)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt index 3a46793e02..0e4f7cc200 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt @@ -64,11 +64,11 @@ class TreatmentsUserEntryFragment : DaggerFragment() { val current = entries[position] holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) holder.binding.action.text = current.action - holder.binding.s.text = current.s - holder.binding.d1.text = if (current.d1 != 0.0) current.d1.toString() else "" - holder.binding.d2.text = if (current.d2 != 0.0) current.d2.toString() else "" - holder.binding.i1.text = if (current.i1 != 0) current.i1.toString() else "" - holder.binding.i1.text = if (current.i2 != 0) current.i2.toString() else "" + if (current.s != "") holder.binding.s.text = current.s else holder.binding.s.visibility = View.GONE + if (current.d1 != 0.0) holder.binding.d1.text = current.d1.toString() else holder.binding.d1.visibility = View.GONE + if (current.d2 != 0.0) holder.binding.d2.text = current.d2.toString() else holder.binding.d2.visibility = View.GONE + if (current.i1 != 0) holder.binding.i1.text = current.i1.toString() else holder.binding.i1.visibility = View.GONE + if (current.i2 != 0) holder.binding.i2.text = current.i2.toString() else holder.binding.i2.visibility = View.GONE } inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { diff --git a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.kt b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.kt index 740f3f2839..c1b4fa7aa5 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.kt @@ -31,7 +31,6 @@ class QueueThread internal constructor( var waitingForDisconnect = false private var mWakeLock: PowerManager.WakeLock? = null - init { mWakeLock = (context.getSystemService(Context.POWER_SERVICE) as PowerManager).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, resourceHelper.gs(R.string.app_name) + ":QueueThread") } @@ -46,7 +45,7 @@ class QueueThread internal constructor( while (true) { val secondsElapsed = (System.currentTimeMillis() - connectionStartTime) / 1000 val pump = activePlugin.activePump - if (!pump.isConnected && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) { + if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) { rxBus.send(EventDismissBolusProgressIfRunning(null)) rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.connectiontimedout))) aapsLogger.debug(LTag.PUMPQUEUE, "timed out") @@ -86,19 +85,19 @@ class QueueThread internal constructor( return } } - if (pump.isHandshakeInProgress) { + if (pump.isHandshakeInProgress()) { aapsLogger.debug(LTag.PUMPQUEUE, "handshaking $secondsElapsed") rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.HANDSHAKING, secondsElapsed.toInt())) SystemClock.sleep(100) continue } - if (pump.isConnecting) { + if (pump.isConnecting()) { aapsLogger.debug(LTag.PUMPQUEUE, "connecting $secondsElapsed") rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTING, secondsElapsed.toInt())) SystemClock.sleep(1000) continue } - if (!pump.isConnected) { + if (!pump.isConnected()) { aapsLogger.debug(LTag.PUMPQUEUE, "connect") rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTING, secondsElapsed.toInt())) pump.connect("Connection needed") diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt index d97ab4f7a9..eb20d8acb4 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt @@ -29,6 +29,7 @@ import javax.inject.Inject import kotlin.math.abs class KeepAliveReceiver : DaggerBroadcastReceiver() { + @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var activePlugin: ActivePluginProvider @@ -44,6 +45,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() { @Inject lateinit var dateUtil: DateUtil companion object { + private val KEEP_ALIVE_MILLISECONDS = T.mins(5).msecs() private val STATUS_UPDATE_FREQUENCY = T.mins(15).msecs() private val IOB_UPDATE_FREQUENCY_IN_MINS = 5L @@ -128,10 +130,10 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() { } if (!pump.isThisProfileSet(profile) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE)) { rxBus.send(EventProfileNeedsUpdate()) - } else if (isStatusOutdated && !pump.isBusy) { + } else if (isStatusOutdated && !pump.isBusy()) { lastReadStatus = System.currentTimeMillis() commandQueue.readStatus("KeepAlive. Status outdated.", null) - } else if (isBasalOutdated && !pump.isBusy) { + } else if (isBasalOutdated && !pump.isBusy()) { lastReadStatus = System.currentTimeMillis() commandQueue.readStatus("KeepAlive. Basal outdated.", null) } diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt index baf7bad0ba..55ed268dfe 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt @@ -217,9 +217,11 @@ class SWDefinition @Inject constructor( .updateDelay(5) .label(R.string.treatmentssafety_maxcarbs_title) .comment(R.string.common_values)) - .validator { sp.contains(R.string.key_age) - && sp.getDouble(R.string.key_treatmentssafety_maxbolus, 0.0) > 0 - && sp.getDouble(R.string.key_treatmentssafety_maxcarbs, 0.0) > 0 } + .validator { + sp.contains(R.string.key_age) + && sp.getDouble(R.string.key_treatmentssafety_maxbolus, 0.0) > 0 + && sp.getDouble(R.string.key_treatmentssafety_maxcarbs, 0.0) > 0 + } private val screenInsulin = SWScreen(injector, R.string.configbuilder_insulin) .skippable(false) .add(SWPlugin(injector, this) @@ -303,7 +305,7 @@ class SWDefinition @Inject constructor( // For Omnipod, consider the pump initialized when a RL has been configured successfully // Users will be prompted to activate a Pod after completing the setup wizard. - return activePump.isInitialized || (activePump is OmnipodErosPumpPlugin && activePump.isRileyLinkReady) + return activePump.isInitialized() || (activePump is OmnipodErosPumpPlugin && activePump.isRileyLinkReady) } private val screenAps = SWScreen(injector, R.string.configbuilder_aps) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/CarbTimer.kt b/app/src/main/java/info/nightscout/androidaps/utils/CarbTimer.kt new file mode 100644 index 0000000000..c029b01af2 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/utils/CarbTimer.kt @@ -0,0 +1,63 @@ +package info.nightscout.androidaps.utils + +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.Constants +import info.nightscout.androidaps.R +import info.nightscout.androidaps.plugins.general.automation.AutomationEvent +import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin +import info.nightscout.androidaps.plugins.general.automation.actions.ActionAlarm +import info.nightscout.androidaps.plugins.general.automation.elements.Comparator +import info.nightscout.androidaps.plugins.general.automation.elements.InputDelta +import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerBg +import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnector +import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDelta +import info.nightscout.androidaps.utils.resources.ResourceHelper +import java.text.DecimalFormat +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class CarbTimer @Inject constructor( + private val injector: HasAndroidInjector, + private val resourceHelper: ResourceHelper, + private val automationPlugin: AutomationPlugin, + private val timerUtil: TimerUtil +) { + + fun scheduleReminder(time: Long, text: String? = null) = + timerUtil.scheduleReminder(time, text ?: resourceHelper.gs(R.string.timetoeat)) + + fun scheduleEatReminder() { + val event = AutomationEvent(injector).apply { + title = resourceHelper.gs(R.string.bolusadvisor) + readOnly = true + systemAction = true + autoRemove = true + trigger = TriggerConnector(injector, TriggerConnector.Type.OR).apply { + + // Bg under 180 mgdl and dropping by 15 mgdl + list.add(TriggerConnector(injector, TriggerConnector.Type.AND).apply { + list.add(TriggerBg(injector, 180.0, Constants.MGDL, Comparator.Compare.IS_LESSER)) + list.add(TriggerDelta(injector, InputDelta(injector, -15.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.DELTA), Constants.MGDL, Comparator.Compare.IS_EQUAL_OR_LESSER)) + list.add(TriggerDelta(injector, InputDelta(injector, -8.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.SHORT_AVERAGE), Constants.MGDL, Comparator.Compare.IS_EQUAL_OR_LESSER)) + }) + // Bg under 160 mgdl and dropping by 9 mgdl + list.add(TriggerConnector(injector, TriggerConnector.Type.AND).apply { + list.add(TriggerBg(injector, 160.0, Constants.MGDL, Comparator.Compare.IS_LESSER)) + list.add(TriggerDelta(injector, InputDelta(injector, -9.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.DELTA), Constants.MGDL, Comparator.Compare.IS_EQUAL_OR_LESSER)) + list.add(TriggerDelta(injector, InputDelta(injector, -5.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.SHORT_AVERAGE), Constants.MGDL, Comparator.Compare.IS_EQUAL_OR_LESSER)) + }) + // Bg under 145 mgdl and dropping + list.add(TriggerConnector(injector, TriggerConnector.Type.AND).apply { + list.add(TriggerBg(injector, 145.0, Constants.MGDL, Comparator.Compare.IS_LESSER)) + list.add(TriggerDelta(injector, InputDelta(injector, 0.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.DELTA), Constants.MGDL, Comparator.Compare.IS_EQUAL_OR_LESSER)) + list.add(TriggerDelta(injector, InputDelta(injector, 0.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.SHORT_AVERAGE), Constants.MGDL, Comparator.Compare.IS_EQUAL_OR_LESSER)) + }) + } + actions.add(ActionAlarm(injector, resourceHelper.gs(R.string.time_to_eat))) + } + + automationPlugin.addIfNotExists(event) + } + +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt b/app/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt new file mode 100644 index 0000000000..b62f00df54 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt @@ -0,0 +1,27 @@ +package info.nightscout.androidaps.utils + +import android.content.Context +import android.content.Intent +import android.provider.AlarmClock +import info.nightscout.androidaps.R +import info.nightscout.androidaps.utils.resources.ResourceHelper +import javax.inject.Inject +import javax.inject.Singleton + +@Singleton +class TimerUtil @Inject constructor( + private val context: Context, + private val resourceHelper: ResourceHelper, +) { + + fun scheduleReminder(time: Long, text: String? = null) { + Intent(AlarmClock.ACTION_SET_TIMER).apply { + val length: Int = ((time - DateUtil.now()) / 1000).toInt() + flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK + putExtra(AlarmClock.EXTRA_LENGTH, length) + putExtra(AlarmClock.EXTRA_SKIP_UI, true) + putExtra(AlarmClock.EXTRA_MESSAGE, text ?: resourceHelper.gs(R.string.app_name)) + context.startActivity(this) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt index e690ce4dba..37fccabd8c 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt @@ -6,7 +6,6 @@ import android.text.Spanned import com.google.common.base.Joiner import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Config -import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.data.DetailedBolusInfo @@ -22,18 +21,10 @@ import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker -import info.nightscout.androidaps.plugins.general.automation.AutomationEvent -import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin -import info.nightscout.androidaps.plugins.general.automation.actions.ActionAlarm -import info.nightscout.androidaps.plugins.general.automation.elements.Comparator -import info.nightscout.androidaps.plugins.general.automation.elements.InputDelta -import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerBg -import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnector -import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDelta -import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTime import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.queue.Callback +import info.nightscout.androidaps.utils.CarbTimer import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.Round @@ -44,7 +35,6 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import org.json.JSONException import org.json.JSONObject -import java.text.DecimalFormat import java.util.* import javax.inject.Inject import kotlin.math.abs @@ -63,10 +53,10 @@ class BolusWizard @Inject constructor( @Inject lateinit var commandQueue: CommandQueueProvider @Inject lateinit var loopPlugin: LoopPlugin @Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin - @Inject lateinit var automationPlugin: AutomationPlugin @Inject lateinit var dateUtil: DateUtil @Inject lateinit var config: Config @Inject lateinit var uel: UserEntryLogger + @Inject lateinit var carbTimer: CarbTimer init { injector.androidInjector().inject(this) @@ -363,7 +353,7 @@ class BolusWizard @Inject constructor( if (!result.success) { ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), R.raw.boluserror) } else - scheduleEatReminder() + carbTimer.scheduleEatReminder() } }) } @@ -434,57 +424,9 @@ class BolusWizard @Inject constructor( } } if (useAlarm && carbs > 0 && carbTime > 0) { - scheduleReminder(dateUtil._now() + T.mins(carbTime.toLong()).msecs()) + carbTimer.scheduleReminder(dateUtil._now() + T.mins(carbTime.toLong()).msecs()) } } }) } - - private fun scheduleEatReminder() { - val event = AutomationEvent(injector).apply { - title = resourceHelper.gs(R.string.bolusadvisor) - readOnly = true - systemAction = true - autoRemove = true - trigger = TriggerConnector(injector, TriggerConnector.Type.OR).apply { - - // Bg under 180 mgdl and dropping by 15 mgdl - list.add(TriggerConnector(injector, TriggerConnector.Type.AND).apply { - list.add(TriggerBg(injector, 180.0, Constants.MGDL, Comparator.Compare.IS_LESSER)) - list.add(TriggerDelta(injector, InputDelta(injector, -15.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.DELTA), Constants.MGDL, Comparator.Compare.IS_EQUAL_OR_LESSER)) - list.add(TriggerDelta(injector, InputDelta(injector, -8.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.SHORT_AVERAGE), Constants.MGDL, Comparator.Compare.IS_EQUAL_OR_LESSER)) - }) - // Bg under 160 mgdl and dropping by 9 mgdl - list.add(TriggerConnector(injector, TriggerConnector.Type.AND).apply { - list.add(TriggerBg(injector, 160.0, Constants.MGDL, Comparator.Compare.IS_LESSER)) - list.add(TriggerDelta(injector, InputDelta(injector, -9.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.DELTA), Constants.MGDL, Comparator.Compare.IS_EQUAL_OR_LESSER)) - list.add(TriggerDelta(injector, InputDelta(injector, -5.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.SHORT_AVERAGE), Constants.MGDL, Comparator.Compare.IS_EQUAL_OR_LESSER)) - }) - // Bg under 145 mgdl and dropping - list.add(TriggerConnector(injector, TriggerConnector.Type.AND).apply { - list.add(TriggerBg(injector, 145.0, Constants.MGDL, Comparator.Compare.IS_LESSER)) - list.add(TriggerDelta(injector, InputDelta(injector, 0.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.DELTA), Constants.MGDL, Comparator.Compare.IS_EQUAL_OR_LESSER)) - list.add(TriggerDelta(injector, InputDelta(injector, 0.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.SHORT_AVERAGE), Constants.MGDL, Comparator.Compare.IS_EQUAL_OR_LESSER)) - }) - } - actions.add(ActionAlarm(injector, resourceHelper.gs(R.string.time_to_eat))) - } - - automationPlugin.addIfNotExists(event) - } - - private fun scheduleReminder(time: Long) { - val event = AutomationEvent(injector).apply { - title = resourceHelper.gs(R.string.timetoeat) - readOnly = true - systemAction = true - autoRemove = true - trigger = TriggerConnector(injector, TriggerConnector.Type.AND).apply { - list.add(TriggerTime(injector, time)) - } - actions.add(ActionAlarm(injector, resourceHelper.gs(R.string.timetoeat))) - } - - automationPlugin.addIfNotExists(event) - } -} +} \ No newline at end of file diff --git a/app/src/main/jniLibs/README.md b/app/src/main/jniLibs/README.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/app/src/main/jniLibs/arm64-v8a/libBleCommandUtil.so b/app/src/main/jniLibs/arm64-v8a/libBleCommandUtil.so deleted file mode 100644 index 69e283b5fe..0000000000 Binary files a/app/src/main/jniLibs/arm64-v8a/libBleCommandUtil.so and /dev/null differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libBleCommandUtil.so b/app/src/main/jniLibs/armeabi-v7a/libBleCommandUtil.so deleted file mode 100644 index 0c717bc3e8..0000000000 Binary files a/app/src/main/jniLibs/armeabi-v7a/libBleCommandUtil.so and /dev/null differ diff --git a/app/src/main/jniLibs/armeabi/libBleCommandUtil.so b/app/src/main/jniLibs/armeabi/libBleCommandUtil.so deleted file mode 100644 index a51a8c7d9a..0000000000 Binary files a/app/src/main/jniLibs/armeabi/libBleCommandUtil.so and /dev/null differ diff --git a/app/src/main/jniLibs/mips/libBleCommandUtil.so b/app/src/main/jniLibs/mips/libBleCommandUtil.so deleted file mode 100644 index fcff5eb6b2..0000000000 Binary files a/app/src/main/jniLibs/mips/libBleCommandUtil.so and /dev/null differ diff --git a/app/src/main/jniLibs/mips64/libBleCommandUtil.so b/app/src/main/jniLibs/mips64/libBleCommandUtil.so deleted file mode 100644 index a8a292ea13..0000000000 Binary files a/app/src/main/jniLibs/mips64/libBleCommandUtil.so and /dev/null differ diff --git a/app/src/main/jniLibs/x86/libBleCommandUtil.so b/app/src/main/jniLibs/x86/libBleCommandUtil.so deleted file mode 100644 index 638a9def95..0000000000 Binary files a/app/src/main/jniLibs/x86/libBleCommandUtil.so and /dev/null differ diff --git a/app/src/main/jniLibs/x86_64/libBleCommandUtil.so b/app/src/main/jniLibs/x86_64/libBleCommandUtil.so deleted file mode 100644 index 94873d3732..0000000000 Binary files a/app/src/main/jniLibs/x86_64/libBleCommandUtil.so and /dev/null differ diff --git a/app/src/main/res/layout/dialog_carbs.xml b/app/src/main/res/layout/dialog_carbs.xml index 66c58a61bf..f0f306c6ff 100644 --- a/app/src/main/res/layout/dialog_carbs.xml +++ b/app/src/main/res/layout/dialog_carbs.xml @@ -75,107 +75,160 @@ - + android:paddingEnd="5dp"> - + - + - + - + - + + - + - + - + - + + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + Šipka trendu Kanyla Vstup uživatele + Použijte hodnoty pro největší jídlo, jaké obvykle jíte\n diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml index 8cffc8b783..106f34a0af 100644 --- a/app/src/main/res/values-de-rDE/strings.xml +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -1162,4 +1162,5 @@ Unerwartetes Verhalten. Trendpfeil Kanüle Benutzereingabe + Verwende die Werte der größten Mahlzeit, die Du normalerweise zu Dir nimmst\n diff --git a/app/src/main/res/values-fr-rFR/objectives.xml b/app/src/main/res/values-fr-rFR/objectives.xml index 288de82bbb..54809e4ba5 100644 --- a/app/src/main/res/values-fr-rFR/objectives.xml +++ b/app/src/main/res/values-fr-rFR/objectives.xml @@ -21,7 +21,7 @@ Activation de fonctionnalités supplémentaires pour l\'utilisation en journée, telles que la fonction SMB Activation de l\'automatisation Lisez le wiki et augmentez le maxIA pour que les SMBs fonctionnent correctement ! Un bon début est maxIA = moyenne des Bolus Repas + 3 x maximum débit Basal quotidien - Lisez la documentation comment l\'automatisation fonctionne. Configurez vos premières règles simples. Au lieu de mettre une action, configurez une notification. Quand vous êtes sûr que l\'automatisation est déclenchée au bon moment, remplacez la notification par une action réelle. (https://androidaps.readthedocs.io/en/latest/CROWDIN/fr/Usage/Automation.html) + Lisez la documentation comment l\'automatisation fonctionne. Configurez vos premières règles simples. Au lieu de mettre une action, configurez une notification. Quand vous êtes sûr que l\'automatisation est déclenchée au bon moment, remplacez la notification par une action réelle. (https://androidaps.readthedocs.io/fr/latest/Usage/Automation.html) Glycémie disponible sur NS Statut de la pompe disponible sur NS Activation manuelle @@ -36,7 +36,7 @@ Affichage du contenu du plugin Boucle Modification de l\'échelle du graphique par un appui long sur la courbe de glycémie Entrer - Si vous avez au moins 3 mois d\'expérience de boucle fermée avec d\'autres systèmes, vous pourriez avoir droit à un code permettant d\'ignorer les objectifs. Voir https://androidaps.readthedocs.io/en/latest/CROWDIN/fr/Usage/Objectives.html#ignorer-les-objectifs pour plus de détails. + Si vous avez au moins 3 mois d\'expérience de boucle fermée avec d\'autres systèmes, vous pourriez avoir droit à un code permettant d\'ignorer les objectifs. Voir https://androidaps.readthedocs.io/fr/latest/Usage/Objectives.html#ignorer-les-objectifs pour plus de détails. Code accepté Code invalide Prouver ses connaissances @@ -46,10 +46,10 @@ Prochain non terminé Code requis : %1$s (Sélectionnez toutes les bonnes réponses) - https://androidaps.readthedocs.io/en/latest/CROWDIN/fr/Getting-Started/FAQ.html#what-to-do-when-taking-a-shower-or-bath - https://androidaps.readthedocs.io/en/latest/CROWDIN/fr/Getting-Started/Screenshots.html#the-homescreen - https://androidaps.readthedocs.io/en/latest/CROWDIN/fr/Getting-Started/Screenshots.html#config-builder - https://androidaps.readthedocs.io/en/latest/CROWDIN/fr/Getting-Started/Screenshots.html#the-homescreen + https://androidaps.readthedocs.io/fr/latest/Getting-Started/FAQ.html#que-faire-pour-prendre-une-douche-ou-un-bain + https://androidaps.readthedocs.io/fr/latest/Getting-Started/Screenshots.html + https://androidaps.readthedocs.io/fr/latest/Configuration/Config-Builder.html + https://androidaps.readthedocs.io/fr/latest/Getting-Started/Screenshots.html Non connecté à Internet Échec de la récupération de l\'heure Exigences de l\'objectif non atteintes diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index b8a1ace3fd..959da11884 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -1162,4 +1162,5 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Flèche de tendance Canule Entrées utilisateur + Utilisez les valeurs qui correspondent à vos plus gros repas\n diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml index ccedf44eb5..8bfdf04a07 100644 --- a/app/src/main/res/values-it-rIT/strings.xml +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -1161,4 +1161,5 @@ Freccia trend Cannula Inserimento utente + Usa i valori del cibo più abbondante che mangi di solito\n diff --git a/app/src/main/res/values-iw-rIL/strings.xml b/app/src/main/res/values-iw-rIL/strings.xml index b1450e9f52..2b8d794200 100644 --- a/app/src/main/res/values-iw-rIL/strings.xml +++ b/app/src/main/res/values-iw-rIL/strings.xml @@ -180,7 +180,7 @@ שמור טעינה מחדש של הפרופיל תקשורת SMS - מספרי טלפון מותרים + מספרי טלפון מורשים + XXXXXXXXXX; + YYYYYYYYYY לאישור מתן בולוס %1$.2f יחידות יש להשיב עם הקוד %2$s למתן %1$.2f יחידות בולוס ארוחה יש להשיב עם הקוד %2$s @@ -1161,4 +1161,5 @@ חץ מגמה צינורית קלט המשתמש + השתמשו בערכים הגבוהים ביותר של מזונות שאתם אוכלים בדרך כלל\n diff --git a/app/src/main/res/values-no-rNO/strings.xml b/app/src/main/res/values-no-rNO/strings.xml index 181ac9fe55..e87337521a 100644 --- a/app/src/main/res/values-no-rNO/strings.xml +++ b/app/src/main/res/values-no-rNO/strings.xml @@ -1161,4 +1161,5 @@ Trend pil Kanyle Bruker registrering + Bruk verdiene for det største måltidet du normalt spiser\n diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 50c0176157..543467fda4 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -1161,4 +1161,5 @@ Seta de tendência Cânula Entrada de Utilizador + Utilize valores da sua maior refeição que normalmente come\n diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml index 2e0825e547..af7bfd5b0b 100644 --- a/app/src/main/res/values-ru-rRU/strings.xml +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -1163,4 +1163,5 @@ Context | Edit Context Стрелка тренда Катетер помпы Запись пользователя + Введите максимальные значения вашего приема пищи \n diff --git a/app/src/main/res/values-sk-rSK/strings.xml b/app/src/main/res/values-sk-rSK/strings.xml index 29e570471f..9339c222f7 100644 --- a/app/src/main/res/values-sk-rSK/strings.xml +++ b/app/src/main/res/values-sk-rSK/strings.xml @@ -420,6 +420,7 @@ BAZ DEV AKT + -BGI ABS DEVSLOPE O aplikácii @@ -627,6 +628,7 @@ Automaticky doplňovať chýbajúcu glykémiu z NS SMB podané pumpou Aktivita + Vplyv na glykémiu (BGI) Citlivosť Odchýlky Aktívne sacharidy @@ -1158,4 +1160,6 @@ Vyčistiť filter Trendová šípka Kanyla + Vstup používateľa + Použite hodnoty pre najväčšie jedlo, aké obvykle jete\n diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 0b02d9a048..ecffee5c8e 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -125,69 +125,6 @@ YpsoPump - - Other (unsupported) - 512 - 712 - 515 - 715 - 522 - 722 - 523 (Fw 2.4A or lower) - 723 (Fw 2.4A or lower) - 554 (EU Fw. <= 2.6A) - 754 (EU Fw. <= 2.6A) - 554 (CA Fw. <= 2.7A) - 754 (CA Fw. <= 2.7A) - - - - @string/medtronic_pump_frequency_us_ca - @string/medtronic_pump_frequency_worldwide - - - - @string/key_medtronic_pump_frequency_us_ca - @string/key_medtronic_pump_frequency_worldwide - - - - 5 - 10 - 15 - - - - @string/medtronic_pump_encoding_4b6b_local - @string/medtronic_pump_encoding_4b6b_rileylink - - - - @string/common_on - @string/common_off - - - - @string/key_medtronic_pump_encoding_4b6b_local - @string/key_medtronic_pump_encoding_4b6b_rileylink - - - - @string/medtronic_pump_battery_no - @string/medtronic_pump_battery_alkaline - @string/medtronic_pump_battery_lithium - @string/medtronic_pump_battery_nizn - @string/medtronic_pump_battery_nimh - - - - @string/key_medtronic_pump_battery_no - @string/key_medtronic_pump_battery_alkaline - @string/key_medtronic_pump_battery_lithium - @string/key_medtronic_pump_battery_nizn - @string/key_medtronic_pump_battery_nimh - - 15 30 diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c45b97d50c..3ca653f8ca 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -65,7 +65,4 @@ #2E2E2E - #FFFFFF - #BBBBBB - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0d7e5910da..9c0acd512a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1251,7 +1251,6 @@ snoozedTo snooze_dst_in24h snooze_loopdisabled - ^\\d{6} Use of Extended bolus feature will stop closed loop mode for the time of running extended bolus. Do you really want it? Closed loop disabled because of running Extended bolus \"PhoneChecker\" diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 054f8f8d23..b79d02361d 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -22,16 +22,6 @@ @color/colorAccent - - - + + +