From 8ce5a881d380881281fe676c74382cba68cc199a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 11 Apr 2021 17:58:50 +0200 Subject: [PATCH] _now() -> now() --- .../info/nightscout/androidaps/MainApp.kt | 2 +- .../activities/ProfileHelperActivity.kt | 6 ++-- .../androidaps/activities/SurveyActivity.kt | 2 +- .../androidaps/dialogs/CarbsDialog.kt | 2 +- .../androidaps/dialogs/InsulinDialog.kt | 2 +- .../androidaps/dialogs/ProfileSwitchDialog.kt | 3 +- .../androidaps/dialogs/TempTargetDialog.kt | 2 +- .../androidaps/dialogs/WizardDialog.kt | 6 ++-- .../androidaps/plugins/aps/loop/LoopPlugin.kt | 14 ++++---- .../aps/openAPSAMA/DetermineBasalResultAMA.kt | 2 +- .../aps/openAPSAMA/OpenAPSAMAPlugin.kt | 4 +-- .../aps/openAPSSMB/DetermineBasalResultSMB.kt | 3 +- .../aps/openAPSSMB/OpenAPSSMBPlugin.kt | 4 +-- .../objectives/ObjectivesFragment.kt | 8 ++--- .../objectives/ObjectivesPlugin.kt | 32 +++++++++---------- .../activities/ObjectivesExamDialog.kt | 2 +- .../objectives/objectives/Objective.kt | 6 ++-- .../objectives/objectives/Objective0.kt | 2 +- .../constraints/safety/SafetyPlugin.kt | 2 +- .../general/actions/ActionsFragment.kt | 6 ++-- .../general/maintenance/ImportExportPrefs.kt | 3 +- .../nsclient/NSClientAddUpdateWorker.kt | 2 +- .../general/nsclient/data/NSDeviceStatus.kt | 16 +++++----- .../nsclient/services/NSClientService.java | 8 ++--- .../general/overview/OverviewFragment.kt | 8 ++--- .../general/overview/graphData/GraphData.kt | 2 +- .../general/smsCommunicator/AuthRequest.kt | 4 +-- .../smsCommunicator/SmsCommunicatorPlugin.kt | 18 +++++------ .../smsCommunicator/otp/OneTimePassword.kt | 2 +- .../general/tidepool/comm/TidepoolUploader.kt | 2 +- .../general/tidepool/comm/UploadChunk.kt | 6 ++-- .../general/tidepool/utils/RateLimit.kt | 4 +-- .../general/wear/ActionStringHandler.kt | 4 +-- .../IobCobCalculatorPlugin.kt | 16 +++++----- .../iob/iobCobCalculator/IobCobOref1Thread.kt | 8 ++--- .../iob/iobCobCalculator/IobCobThread.kt | 6 ++-- .../profile/local/LocalProfilePlugin.kt | 4 +-- .../plugins/profile/ns/NSProfileFragment.kt | 2 +- .../androidaps/plugins/pump/mdi/MDIPlugin.kt | 2 +- .../pump/virtual/VirtualPumpFragment.kt | 4 +-- .../plugins/pump/virtual/VirtualPumpPlugin.kt | 22 ++++++------- .../androidaps/plugins/source/DexcomPlugin.kt | 2 +- .../plugins/source/NSClientSourcePlugin.kt | 4 +-- .../plugins/source/RandomBgPlugin.kt | 3 +- .../plugins/treatments/TreatmentsFragment.kt | 2 +- .../plugins/treatments/TreatmentsPlugin.java | 4 +-- .../fragments/TreatmentsBolusCarbsFragment.kt | 8 ++--- .../TreatmentsProfileSwitchFragment.kt | 4 +-- .../fragments/TreatmentsTempTargetFragment.kt | 4 +-- .../TreatmentsTemporaryBasalsFragment.kt | 4 +-- .../androidaps/queue/CommandQueue.kt | 2 +- .../queue/commands/CommandSMBBolus.kt | 2 +- .../androidaps/receivers/KeepAliveReceiver.kt | 2 +- .../androidaps/utils/ActivityMonitor.kt | 8 ++--- .../androidaps/utils/stats/TddCalculator.kt | 4 +-- .../androidaps/utils/stats/TirCalculator.kt | 4 +-- .../androidaps/utils/wizard/BolusWizard.kt | 4 +-- .../utils/wizard/QuickWizardEntry.kt | 3 +- .../objectives/ObjectivesPluginTest.kt | 2 +- .../smsCommunicator/AuthRequestTest.kt | 5 ++- .../SmsCommunicatorPluginTest.kt | 7 ++-- .../general/automation/AutomationEvent.kt | 2 +- .../general/automation/AutomationPlugin.kt | 4 +-- .../general/automation/actions/ActionAlarm.kt | 2 +- .../automation/actions/ActionProfileSwitch.kt | 2 +- .../actions/ActionStartTempTarget.kt | 2 +- .../actions/ActionStopTempTarget.kt | 2 +- .../automation/elements/InputDateTime.kt | 2 +- .../general/automation/elements/InputTime.kt | 2 +- .../automation/elements/InputTimeRange.kt | 4 +-- .../automation/triggers/TriggerBolusAgo.kt | 2 +- .../general/automation/triggers/TriggerIob.kt | 3 +- .../triggers/TriggerPumpLastConnection.kt | 3 +- .../triggers/TriggerRecurringTime.kt | 2 +- .../automation/triggers/TriggerTempTarget.kt | 2 +- .../automation/triggers/TriggerTime.kt | 3 +- .../automation/triggers/TriggerTimeRange.kt | 3 +- .../triggers/TriggerAutosensValueTest.kt | 2 +- .../automation/triggers/TriggerBgTest.kt | 3 +- .../triggers/TriggerBolusAgoTest.kt | 4 +-- .../automation/triggers/TriggerCOBTest.kt | 2 +- .../automation/triggers/TriggerDeltaTest.kt | 2 +- .../automation/triggers/TriggerIobTest.kt | 4 +-- .../triggers/TriggerLocationTest.kt | 2 +- .../triggers/TriggerProfilePercentTest.kt | 2 +- .../triggers/TriggerPumpLastConnectionTest.kt | 4 +-- .../triggers/TriggerRecurringTimeTest.kt | 2 +- .../triggers/TriggerTempTargetTest.kt | 2 +- .../triggers/TriggerTimeRangeTest.kt | 2 +- .../automation/triggers/TriggerTimeTest.kt | 2 +- .../triggers/TriggerWifiSsidTest.kt | 2 +- .../plugins/pump/combo/ComboPlugin.java | 4 +-- .../androidaps/db/ProfileSwitch.java | 2 +- .../extensions/DeviceStatusExtension.kt | 6 ++-- .../extensions/ExtendedBolusExtension.kt | 6 ++-- .../extensions/PumpStateExtension.kt | 6 ++-- .../extensions/TemporaryBasalExtension.kt | 6 ++-- .../iobCobCalculator/GlucoseStatusProvider.kt | 2 +- .../plugins/pump/PumpSyncImplementation.kt | 10 +++--- .../nightscout/androidaps/utils/DateUtil.kt | 12 +++---- .../nightscout/androidaps/utils/TimerUtil.kt | 2 +- .../androidaps/data/IobTotalTest.kt | 2 +- .../iob/iobCalculator/GlucoseStatusTest.kt | 2 +- .../androidaps/dana/DanaFragment.kt | 2 +- .../nightscout/androidaps/dana/DanaPump.kt | 12 +++---- .../danaRKorean/DanaRKoreanPlugin.java | 6 ++-- .../services/DanaRKoreanExecutionService.java | 2 +- .../androidaps/danaRv2/DanaRv2Plugin.java | 8 ++--- .../danaRv2/comm/MsgHistoryEvents_v2.kt | 3 +- .../services/DanaRv2ExecutionService.java | 2 +- .../androidaps/danar/AbstractDanaRPlugin.java | 8 ++--- .../androidaps/danar/DanaRPlugin.java | 6 ++-- .../danar/comm/MsgStatusTempBasal.kt | 3 +- .../AbstractDanaRExecutionService.java | 10 +++--- .../danar/services/DanaRExecutionService.java | 3 +- .../androidaps/danars/DanaRSPlugin.kt | 8 ++--- .../comm/DanaRS_Packet_APS_History_Events.kt | 3 +- .../androidaps/danars/services/BLEComm.kt | 2 +- .../danars/services/DanaRSService.kt | 10 +++--- .../comm/DanaRsPacketApsHistoryEventsTest.kt | 3 +- .../DanaRsPacketApsSetEventHistoryTest.kt | 3 +- .../pump/common/PumpPluginAbstract.java | 6 ++-- .../omnipod/eros/OmnipodErosPumpPlugin.java | 5 ++- 123 files changed, 273 insertions(+), 298 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.kt b/app/src/main/java/info/nightscout/androidaps/MainApp.kt index db3e97d199..9f7b7013c5 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.kt @@ -68,7 +68,7 @@ class MainApp : DaggerApplication() { commitHash = null } disposable += repository.runTransaction(VersionChangeTransaction(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, gitRemote, commitHash)).subscribe() - disposable += repository.runTransaction(InsertIfNewByTimestampTherapyEventTransaction(timestamp = dateUtil._now(), type = TherapyEvent.Type.NOTE, note = getString(info.nightscout.androidaps.core.R.string.androidaps_start).toString() + " - " + Build.MANUFACTURER + " " + Build.MODEL, glucoseUnit = TherapyEvent.GlucoseUnit.MGDL)).subscribe() + disposable += repository.runTransaction(InsertIfNewByTimestampTherapyEventTransaction(timestamp = dateUtil.now(), type = TherapyEvent.Type.NOTE, note = getString(info.nightscout.androidaps.core.R.string.androidaps_start).toString() + " - " + Build.MANUFACTURER + " " + Build.MODEL, glucoseUnit = TherapyEvent.GlucoseUnit.MGDL)).subscribe() disposable += compatDBHelper.dbChangeDisposable() registerActivityLifecycleCallbacks(activityMonitor) JodaTimeAndroid.init(this) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt index a8432c3f83..03e6cf9a7c 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt @@ -114,7 +114,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { } // Profile switch - profileSwitch = databaseHelper.getProfileSwitchData(dateUtil._now() - T.months(2).msecs(), true) + profileSwitch = databaseHelper.getProfileSwitchData(dateUtil.now() - T.months(2).msecs(), true) binding.profileswitchList.setOnClickListener { PopupMenu(this, binding.profileswitchList).apply { @@ -141,7 +141,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { profile?.let { OKDialog.showConfirmation(this, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile), Runnable { localProfilePlugin.addProfile(localProfilePlugin.copyFrom(it, "DefaultProfile " + - dateUtil.dateAndTimeAndSecondsString(dateUtil._now()) + dateUtil.dateAndTimeAndSecondsString(dateUtil.now()) .replace(".", "/") )) rxBus.send(EventLocalProfileChanged()) @@ -210,7 +210,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { getProfile(ageUsed[1], tddUsed[1], weightUsed[1], pctUsed[1] / 100.0, 1)?.let { profile1 -> ProfileViewerDialog().also { pvd -> pvd.arguments = Bundle().also { - it.putLong("time", dateUtil._now()) + it.putLong("time", dateUtil.now()) it.putInt("mode", ProfileViewerDialog.Mode.PROFILE_COMPARE.ordinal) it.putString("customProfile", profile0.data.toString()) it.putString("customProfile2", profile1.data.toString()) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt index d69e62fa47..6a06bf36e0 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt @@ -69,7 +69,7 @@ class SurveyActivity : NoSplashAppCompatActivity() { defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())?.let { profile -> ProfileViewerDialog().also { pvd -> pvd.arguments = Bundle().also { - it.putLong("time", dateUtil._now()) + it.putLong("time", dateUtil.now()) it.putInt("mode", ProfileViewerDialog.Mode.PROFILE_COMPARE.ordinal) it.putString("customProfile", runningProfile.data.toString()) it.putString("customProfile2", profile.data.toString()) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt index b02534d36a..ce7fc47e3a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -303,7 +303,7 @@ class CarbsDialog : DialogFragmentWithDate() { }) } if (useAlarm && carbs > 0 && timeOffset > 0) { - carbTimer.scheduleReminder(dateUtil._now() + T.mins(timeOffset.toLong()).msecs()) + carbTimer.scheduleReminder(dateUtil.now() + T.mins(timeOffset.toLong()).msecs()) } }, null) } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt index 3eb3e7113e..7773e42829 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -175,7 +175,7 @@ class InsulinDialog : DialogFragmentWithDate() { actions.add(resourceHelper.gs(R.string.temptargetshort) + ": " + (DecimalFormatter.to1Decimal(eatingSoonTT) + " " + unitLabel + " (" + resourceHelper.gs(R.string.format_mins, eatingSoonTTDuration) + ")").formatColor(resourceHelper, R.color.tempTargetConfirmation)) val timeOffset = binding.time.value.toInt() - val time = dateUtil._now() + T.mins(timeOffset.toLong()).msecs() + val time = dateUtil.now() + T.mins(timeOffset.toLong()).msecs() if (timeOffset != 0) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(time)) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index 0590fcf984..08d470d442 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -16,7 +16,6 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin -import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -83,7 +82,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { binding.profile.setSelection(p) } ?: return - treatmentsPlugin.getProfileSwitchFromHistory(dateUtil._now())?.let { ps -> + treatmentsPlugin.getProfileSwitchFromHistory(dateUtil.now())?.let { ps -> if (ps.isCPP) { binding.reuselayout.visibility = View.VISIBLE binding.reusebutton.text = resourceHelper.gs(R.string.reuse_profile_pct_hours, ps.percentage, ps.timeshift) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt index 94f4c611fa..556617303d 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -88,7 +88,7 @@ class TempTargetDialog : DialogFragmentWithDate() { // temp target context?.let { context -> - if (repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() is ValueWrapper.Existing) + if (repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing) binding.targetCancel.visibility = View.VISIBLE else binding.targetCancel.visibility = View.GONE diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt index 39dc0165d9..9f4a1d5a65 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt @@ -210,7 +210,7 @@ class WizardDialog : DaggerDialogFragment() { private fun onCheckedChanged(buttonView: CompoundButton, @Suppress("UNUSED_PARAMETER") state: Boolean) { saveCheckedStates() - binding.ttcheckbox.isEnabled = binding.bgcheckbox.isChecked && repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() is ValueWrapper.Existing + binding.ttcheckbox.isEnabled = binding.bgcheckbox.isChecked && repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing if (buttonView.id == binding.cobcheckbox.id) processCobCheckBox() calculateInsulin() @@ -268,7 +268,7 @@ class WizardDialog : DaggerDialogFragment() { // Set BG if not old binding.bgInput.value = iobCobCalculator.actualBg()?.valueToUnits(units) ?: 0.0 - binding.ttcheckbox.isEnabled = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() is ValueWrapper.Existing + binding.ttcheckbox.isEnabled = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing // IOB calculation val bolusIob = iobCobCalculator.calculateIobFromBolus().round() @@ -308,7 +308,7 @@ class WizardDialog : DaggerDialogFragment() { } bg = if (binding.bgcheckbox.isChecked) bg else 0.0 - val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() + val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() val tempTarget = if (binding.ttcheckbox.isChecked && dbRecord is ValueWrapper.Existing) dbRecord.value else null // COB 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 18b3ce1b96..c6264fa2fc 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 @@ -313,7 +313,7 @@ open class LoopPlugin @Inject constructor( lastRun = (lastRun ?: LastRun()).also { lastRun -> lastRun.request = apsResult lastRun.constraintsProcessed = resultAfterConstraints - lastRun.lastAPSRun = dateUtil._now() + lastRun.lastAPSRun = dateUtil.now() lastRun.source = (usedAPS as PluginBase).name lastRun.tbrSetByPump = null lastRun.smbSetByPump = null @@ -408,7 +408,7 @@ open class LoopPlugin @Inject constructor( if (result.enacted || result.success) { lastRun.tbrSetByPump = result lastRun.lastTBRRequest = lastRun.lastAPSRun - lastRun.lastTBREnact = dateUtil._now() + lastRun.lastTBREnact = dateUtil.now() rxBus.send(EventLoopUpdateGui()) applySMBRequest(resultAfterConstraints, object : Callback() { override fun run() { @@ -416,7 +416,7 @@ open class LoopPlugin @Inject constructor( if (result.enacted || result.success) { lastRun.smbSetByPump = result lastRun.lastSMBRequest = lastRun.lastAPSRun - lastRun.lastSMBEnact = dateUtil._now() + lastRun.lastSMBEnact = dateUtil.now() } else { Thread { SystemClock.sleep(1000) @@ -507,8 +507,8 @@ open class LoopPlugin @Inject constructor( if (result.enacted) { lastRun.tbrSetByPump = result lastRun.lastTBRRequest = lastRun.lastAPSRun - lastRun.lastTBREnact = dateUtil._now() - lastRun.lastOpenModeAccept = dateUtil._now() + lastRun.lastTBREnact = dateUtil.now() + lastRun.lastOpenModeAccept = dateUtil.now() buildDeviceStatus(dateUtil, this@LoopPlugin, iobCobCalculator, profileFunction, activePlugin.activePump, receiverStatusStore, runningConfiguration, BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION)?.also { @@ -658,7 +658,7 @@ open class LoopPlugin @Inject constructor( } }) } - if (pump.pumpDescription.isExtendedBolusCapable && iobCobCalculator.getExtendedBolus(dateUtil._now()) != null) { + if (pump.pumpDescription.isExtendedBolusCapable && iobCobCalculator.getExtendedBolus(dateUtil.now()) != null) { commandQueue.cancelExtended(object : Callback() { override fun run() { if (!result.success) { @@ -684,7 +684,7 @@ open class LoopPlugin @Inject constructor( override fun createOfflineEvent(durationInMinutes: Int) { disposable += repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction( - timestamp = dateUtil._now(), + timestamp = dateUtil.now(), type = TherapyEvent.Type.APS_OFFLINE, duration = T.mins(durationInMinutes.toLong()).msecs(), enteredBy = "openaps://" + "AndroidAPS", diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalResultAMA.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalResultAMA.kt index b93afc5984..6f66dd235f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalResultAMA.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/DetermineBasalResultAMA.kt @@ -13,7 +13,7 @@ class DetermineBasalResultAMA private constructor(injector: HasAndroidInjector) private var snoozeBG = 0.0 internal constructor(injector: HasAndroidInjector, result: NativeObject, j: JSONObject) : this(injector) { - date = dateUtil._now() + date = dateUtil.now() json = j if (result.containsKey("error")) { reason = result["error"].toString() 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 6dfb95224b..891a14239a 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 @@ -116,7 +116,7 @@ open class OpenAPSAMAPlugin @Inject constructor( var maxBg = hardLimits.verifyHardLimits(Round.roundTo(profile.targetHighMgdl, 0.1), R.string.profile_high_target, HardLimits.VERY_HARD_LIMIT_MAX_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_MAX_BG[1].toDouble()) var targetBg = hardLimits.verifyHardLimits(profile.targetMgdl, R.string.temp_target_value, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble()) var isTempTarget = false - val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() + val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() if (tempTarget is ValueWrapper.Existing) { isTempTarget = true minBg = hardLimits.verifyHardLimits(tempTarget.value.lowTarget, R.string.temp_target_low_target, HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1].toDouble()) @@ -160,7 +160,7 @@ open class OpenAPSAMAPlugin @Inject constructor( lastAPSResult = null lastAPSRun = 0 } else { - if (determineBasalResultAMA.rate == 0.0 && determineBasalResultAMA.duration == 0 && iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil._now()) == null) determineBasalResultAMA.tempBasalRequested = false + if (determineBasalResultAMA.rate == 0.0 && determineBasalResultAMA.duration == 0 && iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now()) == null) determineBasalResultAMA.tempBasalRequested = false determineBasalResultAMA.iob = iobArray[0] val now = System.currentTimeMillis() determineBasalResultAMA.json?.put("timestamp", dateUtil.toISOString(now)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.kt index 43342ee6be..996621b8db 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.kt @@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.aps.openAPSSMB import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.aps.loop.APSResult -import info.nightscout.androidaps.utils.DateUtil import org.json.JSONException import org.json.JSONObject @@ -13,7 +12,7 @@ class DetermineBasalResultSMB private constructor(injector: HasAndroidInjector) private var snoozeBG = 0.0 internal constructor(injector: HasAndroidInjector, result: JSONObject) : this(injector) { - date = dateUtil._now() + date = dateUtil.now() json = result try { if (result.has("error")) { 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 27aeacecd3..6517feb45c 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 @@ -122,7 +122,7 @@ open class OpenAPSSMBPlugin @Inject constructor( var maxBg = hardLimits.verifyHardLimits(Round.roundTo(profile.targetHighMgdl, 0.1), R.string.profile_high_target, HardLimits.VERY_HARD_LIMIT_MAX_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_MAX_BG[1].toDouble()) var targetBg = hardLimits.verifyHardLimits(profile.targetMgdl, R.string.temp_target_value, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble()) var isTempTarget = false - val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() + val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() if (tempTarget is ValueWrapper.Existing) { isTempTarget = true minBg = hardLimits.verifyHardLimits(tempTarget.value.lowTarget, R.string.temp_target_low_target, HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1].toDouble()) @@ -187,7 +187,7 @@ open class OpenAPSSMBPlugin @Inject constructor( } else { // TODO still needed with oref1? // Fix bug determine basal - if (determineBasalResultSMB.rate == 0.0 && determineBasalResultSMB.duration == 0 && iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil._now()) == null) determineBasalResultSMB.tempBasalRequested = false + if (determineBasalResultSMB.rate == 0.0 && determineBasalResultSMB.duration == 0 && iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now()) == null) determineBasalResultSMB.tempBasalRequested = false determineBasalResultSMB.iob = iobArray[0] determineBasalResultSMB.json?.put("timestamp", dateUtil.toISOString(now)) determineBasalResultSMB.inputConstraints = inputConstraints diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index 3a3cafe91c..8f161e6ae2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -237,7 +237,7 @@ class ObjectivesFragment : DaggerFragment() { holder.binding.verify.setOnClickListener { receiverStatusStore.updateNetworkStatus() if (binding.fake.isChecked) { - objective.accomplishedOn = dateUtil._now() + objective.accomplishedOn = dateUtil.now() scrollToCurrentObjective() startUpdateTimer() rxBus.send(EventObjectivesUpdateGui()) @@ -249,7 +249,7 @@ class ObjectivesFragment : DaggerFragment() { rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0)) sntpClient.ntpTime(object : SntpClient.Callback() { override fun run() { - aapsLogger.debug("NTP time: $time System time: ${dateUtil._now()}") + aapsLogger.debug("NTP time: $time System time: ${dateUtil.now()}") SystemClock.sleep(300) if (!networkConnected) { rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.notconnected), 99)) @@ -276,7 +276,7 @@ class ObjectivesFragment : DaggerFragment() { holder.binding.start.setOnClickListener { receiverStatusStore.updateNetworkStatus() if (binding.fake.isChecked) { - objective.startedOn = dateUtil._now() + objective.startedOn = dateUtil.now() scrollToCurrentObjective() startUpdateTimer() rxBus.send(EventObjectivesUpdateGui()) @@ -288,7 +288,7 @@ class ObjectivesFragment : DaggerFragment() { rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0)) sntpClient.ntpTime(object : SntpClient.Callback() { override fun run() { - aapsLogger.debug("NTP time: $time System time: ${dateUtil._now()}") + aapsLogger.debug("NTP time: $time System time: ${dateUtil.now()}") SystemClock.sleep(300) if (!networkConnected) { rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.notconnected), 99)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt index d2b09d7853..f101ee7037 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt @@ -127,22 +127,22 @@ class ObjectivesPlugin @Inject constructor( if (!url.endsWith("/")) url = "$url/" @Suppress("DEPRECATION") val hashNS = Hashing.sha1().hashString(url + BuildConfig.APPLICATION_ID + "/" + requestCode, Charsets.UTF_8).toString() if (request.equals(hashNS.substring(0, 10), ignoreCase = true)) { - sp.putLong("Objectives_" + "openloop" + "_started", dateUtil._now()) - sp.putLong("Objectives_" + "openloop" + "_accomplished", dateUtil._now()) - sp.putLong("Objectives_" + "maxbasal" + "_started", dateUtil._now()) - sp.putLong("Objectives_" + "maxbasal" + "_accomplished", dateUtil._now()) - sp.putLong("Objectives_" + "maxiobzero" + "_started", dateUtil._now()) - sp.putLong("Objectives_" + "maxiobzero" + "_accomplished", dateUtil._now()) - sp.putLong("Objectives_" + "maxiob" + "_started", dateUtil._now()) - sp.putLong("Objectives_" + "maxiob" + "_accomplished", dateUtil._now()) - sp.putLong("Objectives_" + "autosens" + "_started", dateUtil._now()) - sp.putLong("Objectives_" + "autosens" + "_accomplished", dateUtil._now()) - sp.putLong("Objectives_" + "ama" + "_started", dateUtil._now()) - sp.putLong("Objectives_" + "ama" + "_accomplished", dateUtil._now()) - sp.putLong("Objectives_" + "smb" + "_started", dateUtil._now()) - sp.putLong("Objectives_" + "smb" + "_accomplished", dateUtil._now()) - sp.putLong("Objectives_" + "auto" + "_started", dateUtil._now()) - sp.putLong("Objectives_" + "auto" + "_accomplished", dateUtil._now()) + sp.putLong("Objectives_" + "openloop" + "_started", dateUtil.now()) + sp.putLong("Objectives_" + "openloop" + "_accomplished", dateUtil.now()) + sp.putLong("Objectives_" + "maxbasal" + "_started", dateUtil.now()) + sp.putLong("Objectives_" + "maxbasal" + "_accomplished", dateUtil.now()) + sp.putLong("Objectives_" + "maxiobzero" + "_started", dateUtil.now()) + sp.putLong("Objectives_" + "maxiobzero" + "_accomplished", dateUtil.now()) + sp.putLong("Objectives_" + "maxiob" + "_started", dateUtil.now()) + sp.putLong("Objectives_" + "maxiob" + "_accomplished", dateUtil.now()) + sp.putLong("Objectives_" + "autosens" + "_started", dateUtil.now()) + sp.putLong("Objectives_" + "autosens" + "_accomplished", dateUtil.now()) + sp.putLong("Objectives_" + "ama" + "_started", dateUtil.now()) + sp.putLong("Objectives_" + "ama" + "_accomplished", dateUtil.now()) + sp.putLong("Objectives_" + "smb" + "_started", dateUtil.now()) + sp.putLong("Objectives_" + "smb" + "_accomplished", dateUtil.now()) + sp.putLong("Objectives_" + "auto" + "_started", dateUtil.now()) + sp.putLong("Objectives_" + "auto" + "_accomplished", dateUtil.now()) setupObjectives() OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeaccepted)) uel.log(Action.OBJECTIVES_SKIPPED, Sources.Objectives) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt index 2d6a220229..50c91dd6b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/activities/ObjectivesExamDialog.kt @@ -108,7 +108,7 @@ class ObjectivesExamDialog : DaggerDialogFragment() { } task.answered = result if (!result) { - task.disabledTo = dateUtil._now() + T.hours(1).msecs() + task.disabledTo = dateUtil.now() + T.hours(1).msecs() ToastUtils.showToastInUiThread(context, R.string.wronganswer) } else task.disabledTo = 0 updateGui() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.kt index 020aabd66e..71f258781d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective.kt @@ -56,7 +56,7 @@ abstract class Objective(injector: HasAndroidInjector, spName: String, @StringRe this.gate = gate startedOn = sp.getLong("Objectives_" + spName + "_started", 0L) accomplishedOn = sp.getLong("Objectives_" + spName + "_accomplished", 0L) - if (accomplishedOn - dateUtil._now() > T.hours(3).msecs() || startedOn - dateUtil._now() > T.hours(3).msecs()) { // more than 3 hours in the future + if (accomplishedOn - dateUtil.now() > T.hours(3).msecs() || startedOn - dateUtil.now() > T.hours(3).msecs()) { // more than 3 hours in the future startedOn = 0 accomplishedOn = 0 } @@ -70,7 +70,7 @@ abstract class Objective(injector: HasAndroidInjector, spName: String, @StringRe } val isAccomplished: Boolean - get() = accomplishedOn != 0L && accomplishedOn < dateUtil._now() + get() = accomplishedOn != 0L && accomplishedOn < dateUtil.now() val isStarted: Boolean get() = startedOn != 0L @@ -145,7 +145,7 @@ abstract class Objective(injector: HasAndroidInjector, spName: String, @StringRe override fun isCompleted(): Boolean = answered - fun isEnabledAnswer(): Boolean = disabledTo < dateUtil._now() + fun isEnabledAnswer(): Boolean = disabledTo < dateUtil.now() fun option(option: Option): ExamTask { options.add(option) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective0.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective0.kt index d7c718525f..feb7fe73d7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective0.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective0.kt @@ -64,7 +64,7 @@ class Objective0(injector: HasAndroidInjector) : Objective(injector, "config", R }) tasks.add(object : Task(this, R.string.activate_profile) { override fun isCompleted(): Boolean { - return treatmentsPlugin.getProfileSwitchFromHistory(dateUtil._now()) != null + return treatmentsPlugin.getProfileSwitchFromHistory(dateUtil.now()) != null } }) } 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 dbd3cc8ea6..1c1407c500 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 @@ -70,7 +70,7 @@ class SafetyPlugin @Inject constructor( value[aapsLogger, false, resourceHelper.gs(R.string.closed_loop_disabled_on_dev_branch)] = this } val pump = activePlugin.activePump - if (!pump.isFakingTempsByExtendedBoluses && iobCobCalculator.getExtendedBolus(dateUtil._now()) != null) { + if (!pump.isFakingTempsByExtendedBoluses && iobCobCalculator.getExtendedBolus(dateUtil.now()) != null) { value[aapsLogger, false, resourceHelper.gs(R.string.closed_loop_disabled_with_eb)] = this } return value 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 7377ad4c83..473aa35f6c 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 @@ -164,7 +164,7 @@ class ActionsFragment : DaggerFragment() { } } extendedBolusCancel?.setOnClickListener { - if (iobCobCalculator.getExtendedBolus(dateUtil._now()) != null) { + if (iobCobCalculator.getExtendedBolus(dateUtil.now()) != null) { uel.log(Action.CANCEL_EXTENDED_BOLUS, Sources.Actions) commandQueue.cancelExtended(object : Callback() { override fun run() { @@ -179,7 +179,7 @@ class ActionsFragment : DaggerFragment() { TempBasalDialog().show(childFragmentManager, "Actions") } cancelTempBasal?.setOnClickListener { - if (iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil._now()) != null) { + if (iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now()) != null) { uel.log(Action.CANCEL_TEMP_BASAL, Sources.Actions) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { @@ -274,7 +274,7 @@ class ActionsFragment : DaggerFragment() { extendedBolus?.visibility = View.GONE extendedBolusCancel?.visibility = View.GONE } else { - val activeExtendedBolus = repository.getExtendedBolusActiveAt(dateUtil._now()).blockingGet() + val activeExtendedBolus = repository.getExtendedBolusActiveAt(dateUtil.now()).blockingGet() if (activeExtendedBolus is ValueWrapper.Existing) { extendedBolus?.visibility = View.GONE extendedBolusCancel?.visibility = View.VISIBLE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt index f6c9a37859..af857b64dc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt @@ -41,7 +41,6 @@ import io.reactivex.Single import java.io.File import java.io.FileNotFoundException import java.io.IOException -import java.util.* import javax.inject.Inject import javax.inject.Singleton import kotlin.system.exitProcess @@ -96,7 +95,7 @@ class ImportExportPrefs @Inject constructor( val metadata: MutableMap = mutableMapOf() metadata[PrefsMetadataKey.DEVICE_NAME] = PrefMetadata(detectUserName(context), PrefsStatus.OK) - metadata[PrefsMetadataKey.CREATED_AT] = PrefMetadata(dateUtil.toISOString(dateUtil._now()), PrefsStatus.OK) + metadata[PrefsMetadataKey.CREATED_AT] = PrefMetadata(dateUtil.toISOString(dateUtil.now()), PrefsStatus.OK) metadata[PrefsMetadataKey.AAPS_VERSION] = PrefMetadata(BuildConfig.VERSION_NAME, PrefsStatus.OK) metadata[PrefsMetadataKey.AAPS_FLAVOUR] = PrefMetadata(BuildConfig.FLAVOR, PrefsStatus.OK) metadata[PrefsMetadataKey.DEVICE_MODEL] = PrefMetadata(config.currentDeviceModelString, PrefsStatus.OK) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt index 86f860bcb2..ad5ef82d8a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt @@ -71,7 +71,7 @@ class NSClientAddUpdateWorker( //Find latest date in treatment val mills = safeGetLong(json, "mills") - if (mills != 0L && mills < dateutil._now()) + if (mills != 0L && mills < dateutil.now()) if (mills > latestDateInReceivedData) latestDateInReceivedData = mills if (insulin > 0) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt index c103628ba6..1ef337e2d8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt @@ -164,12 +164,12 @@ class NSDeviceStatus @Inject constructor( // test warning level val level = when { - pumpData.clock + nsSettingsStatus.extendedPumpSettings("urgentClock") * 60 * 1000L < dateUtil._now() -> Levels.URGENT - pumpData.reservoir < nsSettingsStatus.extendedPumpSettings("urgentRes") -> Levels.URGENT + pumpData.clock + nsSettingsStatus.extendedPumpSettings("urgentClock") * 60 * 1000L < dateUtil.now() -> Levels.URGENT + pumpData.reservoir < nsSettingsStatus.extendedPumpSettings("urgentRes") -> Levels.URGENT pumpData.isPercent && pumpData.percent < nsSettingsStatus.extendedPumpSettings("urgentBattP") -> Levels.URGENT - !pumpData.isPercent && pumpData.voltage < nsSettingsStatus.extendedPumpSettings("urgentBattV") -> Levels.URGENT - pumpData.clock + nsSettingsStatus.extendedPumpSettings("warnClock") * 60 * 1000L < dateUtil._now() -> Levels.WARN - pumpData.reservoir < nsSettingsStatus.extendedPumpSettings("warnRes") -> Levels.WARN + !pumpData.isPercent && pumpData.voltage < nsSettingsStatus.extendedPumpSettings("urgentBattV") -> Levels.URGENT + pumpData.clock + nsSettingsStatus.extendedPumpSettings("warnClock") * 60 * 1000L < dateUtil.now() -> Levels.WARN + pumpData.reservoir < nsSettingsStatus.extendedPumpSettings("warnRes") -> Levels.WARN pumpData.isPercent && pumpData.percent < nsSettingsStatus.extendedPumpSettings("warnBattP") -> Levels.WARN !pumpData.isPercent && pumpData.voltage < nsSettingsStatus.extendedPumpSettings("warnBattV") -> Levels.WARN else -> Levels.INFO @@ -273,9 +273,9 @@ class NSDeviceStatus @Inject constructor( // test warning level val level = when { - deviceStatusOpenAPSData.clockSuggested + T.mins(sp.getLong(R.string.key_nsalarm_urgent_staledatavalue, 31)).msecs() < dateUtil._now() -> Levels.URGENT - deviceStatusOpenAPSData.clockSuggested + T.mins(sp.getLong(R.string.key_nsalarm_staledatavalue, 16)).msecs() < dateUtil._now() -> Levels.WARN - else -> Levels.INFO + deviceStatusOpenAPSData.clockSuggested + T.mins(sp.getLong(R.string.key_nsalarm_urgent_staledatavalue, 31)).msecs() < dateUtil.now() -> Levels.URGENT + deviceStatusOpenAPSData.clockSuggested + T.mins(sp.getLong(R.string.key_nsalarm_staledatavalue, 16)).msecs() < dateUtil.now() -> Levels.WARN + else -> Levels.INFO } string.append("") if (deviceStatusOpenAPSData.clockSuggested != 0L) string.append(dateUtil.minAgo(resourceHelper, deviceStatusOpenAPSData.clockSuggested)).append(" ") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java index b0a7e7245c..35671b20f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java @@ -228,7 +228,7 @@ public class NSClientService extends DaggerService { } public void processAddAck(NSAddAck ack) { - lastAckTime = dateUtil._now(); + lastAckTime = dateUtil.now(); // new room way if (ack.getOriginalObject() instanceof DataSyncSelector.PairTemporaryTarget) { DataSyncSelector.PairTemporaryTarget pair = (DataSyncSelector.PairTemporaryTarget) ack.getOriginalObject(); @@ -400,7 +400,7 @@ public class NSClientService extends DaggerService { } public void processUpdateAck(NSUpdateAck ack) { - lastAckTime = dateUtil._now(); + lastAckTime = dateUtil.now(); // new room way if (ack.getOriginalObject() instanceof DataSyncSelector.PairTemporaryTarget) { DataSyncSelector.PairTemporaryTarget pair = (DataSyncSelector.PairTemporaryTarget) ack.getOriginalObject(); @@ -591,7 +591,7 @@ public class NSClientService extends DaggerService { void watchdog() { synchronized (reconnections) { - long now = dateUtil._now(); + long now = dateUtil.now(); reconnections.add(now); for (int i = 0; i < reconnections.size(); i++) { Long r = reconnections.get(i); @@ -833,7 +833,7 @@ public class NSClientService extends DaggerService { if (action == null) addedOrUpdatedTreatments.put(jsonTreatment); else if (action.equals("update")) addedOrUpdatedTreatments.put(jsonTreatment); - else if (action.equals("remove") && mills > dateUtil._now() - T.days(1).msecs()) // handle 1 day old deletions only + else if (action.equals("remove") && mills > dateUtil.now() - T.days(1).msecs()) // handle 1 day old deletions only removedTreatments.put(jsonTreatment); } if (removedTreatments.length() > 0) { 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 111854753d..4138c4d7b8 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 @@ -309,7 +309,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList R.id.active_profile -> { ProfileViewerDialog().also { pvd -> pvd.arguments = Bundle().also { - it.putLong("time", dateUtil._now()) + it.putLong("time", dateUtil.now()) it.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal) } }.show(childFragmentManager, "ProfileViewDialog") @@ -549,7 +549,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList if (_binding == null) return aapsLogger.debug("UpdateGUI from $from") - binding.infoLayout.time.text = dateUtil.timeString(dateUtil._now()) + binding.infoLayout.time.text = dateUtil.timeString(dateUtil.now()) if (!profileFunction.isProfileValid("Overview")) { binding.loopPumpStatusLayout.pumpStatus.setText(R.string.noprofileset) @@ -680,7 +680,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } // temp target - val tempTarget: ValueWrapper = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() + val tempTarget: ValueWrapper = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() if (tempTarget is ValueWrapper.Existing) { binding.loopPumpStatusLayout.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) binding.loopPumpStatusLayout.tempTarget.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning)) @@ -723,7 +723,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList if (percentRate < 100) binding.infoLayout.baseBasalIcon.setImageResource(R.drawable.ic_cp_basal_tbr_low) // Extended bolus - val extendedBolus = repository.getExtendedBolusActiveAt(dateUtil._now()).blockingGet() + val extendedBolus = repository.getExtendedBolusActiveAt(dateUtil.now()).blockingGet() binding.infoLayout.extendedBolus.text = if (extendedBolus is ValueWrapper.Existing && !pump.isFakingTempsByExtendedBoluses) resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.value.rate) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt index 02023a8894..018acf9881 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt @@ -415,7 +415,7 @@ class GraphData( if (showPrediction) { val autosensData = iobCobCalculator.getLastAutosensDataSynchronized("GraphData") val lastAutosensResult = autosensData?.autosensResult ?: AutosensResult() - val isTempTarget = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() is ValueWrapper.Existing + val isTempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing val iobPrediction: MutableList = ArrayList() val iobPredictionArray = iobCobCalculator.calculateIobArrayForSMB(lastAutosensResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, isTempTarget) for (i in iobPredictionArray) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/AuthRequest.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/AuthRequest.kt index 15aa18b2c3..7d19bed23d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/AuthRequest.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/AuthRequest.kt @@ -29,7 +29,7 @@ class AuthRequest internal constructor( init { injector.androidInjector().inject(this) - date = dateUtil._now() + date = dateUtil.now() smsCommunicatorPlugin.sendSMS(Sms(requester.phoneNumber, requestText)) } @@ -47,7 +47,7 @@ class AuthRequest internal constructor( smsCommunicatorPlugin.sendSMS(Sms(requester.phoneNumber, resourceHelper.gs(R.string.sms_wrongcode))) return } - if (dateUtil._now() - date < Constants.SMS_CONFIRM_TIMEOUT) { + if (dateUtil.now() - date < Constants.SMS_CONFIRM_TIMEOUT) { processed = true aapsLogger.debug(LTag.SMS, "Processing confirmed SMS: " + requester.text) action.run() 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 58aa14697e..e7ce0b9bd1 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 @@ -276,7 +276,7 @@ class SmsCommunicatorPlugin @Inject constructor( else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) "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 && 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 || divided.size == 3) processBOLUS(divided, receivedSms) else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) @@ -317,7 +317,7 @@ class SmsCommunicatorPlugin @Inject constructor( if (actualBG != null) { reply = resourceHelper.gs(R.string.sms_actualbg) + " " + actualBG.valueToUnitsString(units) + ", " } else if (lastBG != null) { - val agoMilliseconds = dateUtil._now() - lastBG.timestamp + val agoMilliseconds = dateUtil.now() - lastBG.timestamp val agoMin = (agoMilliseconds / 60.0 / 1000.0).toInt() reply = resourceHelper.gs(R.string.sms_lastbg) + " " + lastBG.valueToUnitsString(units) + " " + String.format(resourceHelper.gs(R.string.sms_minago), agoMin) + ", " } @@ -431,7 +431,7 @@ class SmsCommunicatorPlugin @Inject constructor( commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (result.success) { - loopPlugin.suspendTo(dateUtil._now() + anInteger() * 60L * 1000) + loopPlugin.suspendTo(dateUtil.now() + anInteger() * 60L * 1000) loopPlugin.createOfflineEvent(anInteger() * 60) rxBus.send(EventRefreshOverview("SMS_LOOP_SUSPENDED")) val replyText = resourceHelper.gs(R.string.smscommunicator_loopsuspended) + " " + @@ -584,7 +584,7 @@ class SmsCommunicatorPlugin @Inject constructor( val finalPercentage = percentage messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(list[pIndex - 1] as String, finalPercentage) { override fun run() { - activePlugin.activeTreatments.doProfileSwitch(store, list[pIndex - 1] as String, 0, finalPercentage, 0, dateUtil._now()) + activePlugin.activeTreatments.doProfileSwitch(store, list[pIndex - 1] as String, 0, finalPercentage, 0, dateUtil.now()) val replyText = resourceHelper.gs(R.string.profileswitchcreated) sendSMS(Sms(receivedSms.phoneNumber, replyText)) uel.log(Action.PROFILE_SWITCH, Sources.SMS, @@ -804,7 +804,7 @@ class SmsCommunicatorPlugin @Inject constructor( else String.format(resourceHelper.gs(R.string.smscommunicator_bolusdelivered), resultBolusDelivered) replyText += "\n" + activePlugin.activePump.shortStatus(true) - lastRemoteBolusTime = dateUtil._now() + lastRemoteBolusTime = dateUtil.now() if (isMeal) { profileFunction.getProfile()?.let { currentProfile -> var eatingSoonTTDuration = sp.getInt(R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration) @@ -819,7 +819,7 @@ class SmsCommunicatorPlugin @Inject constructor( else -> Constants.defaultEatingSoonTTmgdl } disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( - timestamp = dateUtil._now(), + timestamp = dateUtil.now(), duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()), reason = TemporaryTarget.Reason.EATING_SOON, lowTarget = Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()), @@ -875,7 +875,7 @@ class SmsCommunicatorPlugin @Inject constructor( private fun processCARBS(divided: Array, receivedSms: Sms) { var grams = SafeParse.stringToInt(divided[1]) - var time = dateUtil._now() + var time = dateUtil.now() if (divided.size > 2) { time = toTodayTime(divided[2].toUpperCase(Locale.getDefault())) if (time == 0L) { @@ -964,7 +964,7 @@ class SmsCommunicatorPlugin @Inject constructor( tt = Profile.toCurrentUnits(profileFunction, tt) tt = if (tt > 0) tt else if (units == Constants.MMOL) defaultTargetMMOL else defaultTargetMGDL disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( - timestamp = dateUtil._now(), + timestamp = dateUtil.now(), duration = TimeUnit.MINUTES.toMillis(ttDuration.toLong()), reason = TemporaryTarget.Reason.EATING_SOON, lowTarget = Profile.toMgdl(tt, profileFunction.getUnits()), @@ -989,7 +989,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil._now())) + disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil.now())) .subscribe({ result -> result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } }, { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/otp/OneTimePassword.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/otp/OneTimePassword.kt index 3d48e84cd7..77470340a1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/otp/OneTimePassword.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/otp/OneTimePassword.kt @@ -86,7 +86,7 @@ class OneTimePassword @Inject constructor( return OneTimePasswordValidationResult.ERROR_WRONG_PIN } - val counter: Long = dateUtil._now() / 30000L + val counter: Long = dateUtil.now() / 30000L val acceptableTokens: MutableList = mutableListOf(generateOneTimePassword(counter)) for (i in 0 until Constants.OTP_ACCEPT_OLD_TOKENS_COUNT) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/TidepoolUploader.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/TidepoolUploader.kt index c05fdd7a11..cd15fac40d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/TidepoolUploader.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/TidepoolUploader.kt @@ -232,7 +232,7 @@ class TidepoolUploader @Inject constructor( } private fun uploadNext() { - if (uploadChunk.getLastEnd() < dateUtil._now() - T.mins(1).msecs()) { + if (uploadChunk.getLastEnd() < dateUtil.now() - T.mins(1).msecs()) { SystemClock.sleep(3000) aapsLogger.debug(LTag.TIDEPOOL, "Restarting doUpload. Last: " + dateUtil.dateAndTimeString(uploadChunk.getLastEnd())) doUpload() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt index 49086b3785..573147c14c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/comm/UploadChunk.kt @@ -41,7 +41,7 @@ class UploadChunk @Inject constructor( return null session.start = getLastEnd() - session.end = min(session.start + maxUploadSize, dateUtil._now()) + session.end = min(session.start + maxUploadSize, dateUtil.now()) val result = get(session.start, session.end) if (result.length < 3) { @@ -81,7 +81,7 @@ class UploadChunk @Inject constructor( fun getLastEnd(): Long { val result = sp.getLong(R.string.key_tidepool_last_end, 0) - return max(result, dateUtil._now() - T.months(2).msecs()) + return max(result, dateUtil.now() - T.months(2).msecs()) } fun setLastEnd(time: Long) { @@ -101,7 +101,7 @@ class UploadChunk @Inject constructor( // TODO we could make sure we include records older than the first bg record for completeness val start: Long = 0 - val end = dateUtil._now() + val end = dateUtil.now() val bgReadingList = repository.compatGetBgReadingsDataFromTime(start, end, true) .blockingGet() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/utils/RateLimit.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/utils/RateLimit.kt index 3169adcd94..020e6714f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/utils/RateLimit.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/tidepool/utils/RateLimit.kt @@ -21,13 +21,13 @@ class RateLimit @Inject constructor( fun rateLimit(name: String, seconds: Int): Boolean { // check if over limit rateLimits[name]?.let { - if (dateUtil._now() - it < T.secs(seconds.toLong()).msecs()) { + if (dateUtil.now() - it < T.secs(seconds.toLong()).msecs()) { aapsLogger.debug(LTag.TIDEPOOL, "$name rate limited: $seconds seconds") return false } } // not over limit - rateLimits[name] = dateUtil._now() + rateLimits[name] = dateUtil.now() return true } } 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 1fe3c26e11..cfc399335d 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 @@ -220,7 +220,7 @@ class ActionStringHandler @Inject constructor( } val format = DecimalFormat("0.00") val formatInt = DecimalFormat("0") - val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() + val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() val tempTarget = if (dbRecord is ValueWrapper.Existing) dbRecord.value else null val bolusWizard = BolusWizard(injector).doCalc(profile, profileName, tempTarget, @@ -457,7 +457,7 @@ class ActionStringHandler @Inject constructor( } val profile = profileFunction.getProfile() ?: return "No profile set :(" //Check for Temp-Target: - val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() + val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() if (tempTarget is ValueWrapper.Existing) { ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.value.lowTarget, tempTarget.value.lowTarget, Constants.MGDL, profileFunction.getUnits()) ret += "\nuntil: " + dateUtil.timeString(tempTarget.value.end) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt index 47c465d5e0..a90de3e18a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt @@ -466,7 +466,7 @@ open class IobCobCalculatorPlugin @Inject constructor( } private fun calculateFromTreatmentsAndTemps(time: Long, lastAutosensResult: AutosensResult, exercise_mode: Boolean, half_basal_exercise_target: Int, isTempTarget: Boolean): IobTotal { - val now = dateUtil._now() + val now = dateUtil.now() val bolusIob = calculateIobFromBolusToTime(time).round() val basalIob = getCalculationToTimeTempBasals(time, lastAutosensResult, exercise_mode, half_basal_exercise_target, isTempTarget).round() // OpenAPSSMB only @@ -551,7 +551,7 @@ open class IobCobCalculatorPlugin @Inject constructor( val autosensData = if (_synchronized) getLastAutosensDataSynchronized(reason) else getLastAutosensData(reason) var displayCob: Double? = null var futureCarbs = 0.0 - val now = dateUtil._now() + val now = dateUtil.now() val carbs = repository.getCarbsDataFromTimeExpanded(now, true).blockingGet() if (autosensData != null) { displayCob = autosensData.cob @@ -658,7 +658,7 @@ open class IobCobCalculatorPlugin @Inject constructor( override fun calculateIobArrayForSMB(lastAutosensResult: AutosensResult, exercise_mode: Boolean, half_basal_exercise_target: Int, isTempTarget: Boolean): Array { // predict IOB out to DIA plus 30m - val now = dateUtil._now() + val now = dateUtil.now() val len = 4 * 60 / 5 val array = Array(len) { IobTotal(0) } for ((pos, i) in (0 until len).withIndex()) { @@ -809,7 +809,7 @@ open class IobCobCalculatorPlugin @Inject constructor( fun range(): Long = ((profileFunction.getProfile()?.dia ?: Constants.defaultDIA) * 60 * 60 * 1000).toLong() - override fun calculateIobFromBolus(): IobTotal = calculateIobFromBolusToTime(dateUtil._now()) + override fun calculateIobFromBolus(): IobTotal = calculateIobFromBolusToTime(dateUtil.now()) override fun calculateIobFromBolusToTime(toTime: Long): IobTotal { val total = IobTotal(toTime) @@ -842,7 +842,7 @@ open class IobCobCalculatorPlugin @Inject constructor( private fun calculateIobToTimeFromExtendedBoluses(toTime: Long): IobTotal { val total = IobTotal(toTime) - val now = dateUtil._now() + val now = dateUtil.now() val pumpInterface = activePlugin.activePump if (!pumpInterface.isFakingTempsByExtendedBoluses) { val extendedBoluses = repository.getExtendedBolusDataFromTimeToTime(toTime - range(), toTime, true).blockingGet() @@ -906,11 +906,11 @@ open class IobCobCalculatorPlugin @Inject constructor( } override fun calculateIobFromTempBasalsIncludingConvertedExtended(): IobTotal = - calculateIobToTimeFromTempBasalsIncludingConvertedExtended(dateUtil._now()) + calculateIobToTimeFromTempBasalsIncludingConvertedExtended(dateUtil.now()) override fun calculateIobToTimeFromTempBasalsIncludingConvertedExtended(toTime: Long): IobTotal { val total = IobTotal(toTime) - val now = dateUtil._now() + val now = dateUtil.now() val pumpInterface = activePlugin.activePump val temporaryBasals = repository.getTemporaryBasalsDataFromTimeToTime(toTime - range(), toTime, true).blockingGet() @@ -947,7 +947,7 @@ open class IobCobCalculatorPlugin @Inject constructor( open fun getCalculationToTimeTempBasals(toTime: Long, lastAutosensResult: AutosensResult, exercise_mode: Boolean, half_basal_exercise_target: Int, isTempTarget: Boolean): IobTotal { val total = IobTotal(toTime) val pumpInterface = activePlugin.activePump - val now = dateUtil._now() + val now = dateUtil.now() val temporaryBasals = repository.getTemporaryBasalsDataFromTimeToTime(toTime - range(), toTime, true).blockingGet() for (pos in temporaryBasals.indices) { val t = temporaryBasals[pos] diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.kt b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.kt index 047764e69c..299e7e3f74 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.kt @@ -66,7 +66,7 @@ class IobCobOref1Thread internal constructor( } override fun run() { - val start = dateUtil._now() + val start = dateUtil.now() mWakeLock?.acquire(T.mins(10).msecs()) try { aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA thread started: $from") @@ -103,7 +103,7 @@ class IobCobOref1Thread internal constructor( // check if data already exists var bgTime = bucketedData[i].timestamp bgTime = iobCobCalculatorPlugin.roundUpTime(bgTime) - if (bgTime > iobCobCalculatorPlugin.roundUpTime(dateUtil._now())) continue + if (bgTime > iobCobCalculatorPlugin.roundUpTime(dateUtil.now())) continue var existing: AutosensData? if (autosensDataTable[bgTime].also { existing = it } != null) { previous = existing @@ -293,7 +293,7 @@ class IobCobOref1Thread internal constructor( // TODO AS-FIX @Suppress("SimplifyBooleanWithConstants") if (false && sp.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity)) { - val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() + val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() if (tempTarget is ValueWrapper.Existing && tempTarget.value.target() >= 100) { autosensData.extraDeviation.add(-(tempTarget.value.target() - 100) / 20) } @@ -306,7 +306,7 @@ class IobCobOref1Thread internal constructor( val hours = calendar[Calendar.HOUR_OF_DAY] if (min in 0..4 && hours % 2 == 0) autosensData.extraDeviation.add(0.0) previous = autosensData - if (bgTime < dateUtil._now()) autosensDataTable.put(bgTime, autosensData) + if (bgTime < dateUtil.now()) autosensDataTable.put(bgTime, autosensData) aapsLogger.debug(LTag.AUTOSENS, "Running detectSensitivity from: " + dateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + dateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime()) val sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime) aapsLogger.debug(LTag.AUTOSENS, "Sensitivity result: $sensitivity") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.kt b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.kt index 0ca669a313..ea8af5eb8e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.kt @@ -65,7 +65,7 @@ class IobCobThread @Inject internal constructor( } override fun run() { - val start = dateUtil._now() + val start = dateUtil.now() mWakeLock?.acquire(T.mins(10).msecs()) try { aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA thread started: $from") @@ -102,7 +102,7 @@ class IobCobThread @Inject internal constructor( // check if data already exists var bgTime = bucketedData[i].timestamp bgTime = iobCobCalculatorPlugin.roundUpTime(bgTime) - if (bgTime > iobCobCalculatorPlugin.roundUpTime(dateUtil._now())) continue + if (bgTime > iobCobCalculatorPlugin.roundUpTime(dateUtil.now())) continue var existing: AutosensData? if (autosensDataTable[bgTime].also { existing = it } != null) { previous = existing @@ -253,7 +253,7 @@ class IobCobThread @Inject internal constructor( autosensData.pastSensitivity += "C" } previous = autosensData - if (bgTime < dateUtil._now()) autosensDataTable.put(bgTime, autosensData) + if (bgTime < dateUtil.now()) autosensDataTable.put(bgTime, autosensData) aapsLogger.debug(LTag.AUTOSENS, "Running detectSensitivity from: " + dateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + dateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime()) val sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime) aapsLogger.debug(LTag.AUTOSENS, "Sensitivity result: $sensitivity") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index 3bdc6a055e..ff4d41b6b5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -204,7 +204,7 @@ class LocalProfilePlugin @Inject constructor( fun copyFrom(profile: Profile, newName: String): SingleProfile { var verifiedName = newName if (rawProfile?.getSpecificProfile(newName) != null) { - verifiedName += " " + dateUtil._now().toString() + verifiedName += " " + dateUtil.now().toString() } val sp = SingleProfile() sp.name = verifiedName @@ -341,7 +341,7 @@ class LocalProfilePlugin @Inject constructor( } } if (numOfProfiles > 0) json.put("defaultProfile", currentProfile()?.name) - json.put("startDate", dateUtil.toISOAsUTC(dateUtil._now())) + json.put("startDate", dateUtil.toISOAsUTC(dateUtil.now())) json.put("store", store) } catch (e: JSONException) { aapsLogger.error("Unhandled exception", e) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt index d68418931c..d6869ad370 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt @@ -68,7 +68,7 @@ class NSProfileFragment : DaggerFragment() { uel.log(Action.PROFILE_SWITCH, Sources.NSProfile, ValueWithUnit.SimpleString(name), ValueWithUnit.Percent(100)) - treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, dateUtil._now()) + treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, dateUtil.now()) }) } } 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 index fec273fb22..609d753704 100644 --- 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 @@ -79,7 +79,7 @@ class MDIPlugin @Inject constructor( timestamp = detailedBolusInfo.timestamp, amount = detailedBolusInfo.insulin, type = detailedBolusInfo.bolusType, - pumpId = dateUtil._now(), + pumpId = dateUtil.now(), pumpType = PumpType.MDI, pumpSerial = serialNumber()) if (detailedBolusInfo.carbs > 0) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt index 527e66eb3d..f2eb4bb5e1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt @@ -95,9 +95,9 @@ class VirtualPumpFragment : DaggerFragment() { if (_binding == null) return val profile = profileFunction.getProfile() ?: return binding.basabasalrate.text = resourceHelper.gs(R.string.pump_basebasalrate, virtualPumpPlugin.baseBasalRate) - binding.tempbasal.text = iobCobCalculator.getTempBasal(dateUtil._now())?.toStringFull(profile, dateUtil) + binding.tempbasal.text = iobCobCalculator.getTempBasal(dateUtil.now())?.toStringFull(profile, dateUtil) ?: "" - binding.extendedbolus.text = iobCobCalculator.getExtendedBolus(dateUtil._now())?.toStringFull(dateUtil) + binding.extendedbolus.text = iobCobCalculator.getExtendedBolus(dateUtil.now())?.toStringFull(dateUtil) ?: "" binding.battery.text = resourceHelper.gs(R.string.format_percent, virtualPumpPlugin.batteryPercent) binding.reservoir.text = resourceHelper.gs(R.string.formatinsulinunits, virtualPumpPlugin.reservoirInUnits.toDouble()) 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 026fc53ee7..5c15fa88d9 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 @@ -206,7 +206,7 @@ open class VirtualPumpPlugin @Inject constructor( timestamp = detailedBolusInfo.timestamp, amount = detailedBolusInfo.insulin, type = detailedBolusInfo.bolusType, - pumpId = dateUtil._now(), + pumpId = dateUtil.now(), pumpType = pumpType ?: PumpType.GENERIC_AAPS, pumpSerial = serialNumber()) if (detailedBolusInfo.carbs > 0) @@ -229,12 +229,12 @@ open class VirtualPumpPlugin @Inject constructor( result.duration = durationInMinutes result.comment = resourceHelper.gs(R.string.virtualpump_resultok) pumpSync.syncTemporaryBasalWithPumpId( - timestamp = dateUtil._now(), + timestamp = dateUtil.now(), rate = absoluteRate, duration = T.mins(durationInMinutes.toLong()).msecs(), isAbsolute = true, type = tbrType, - pumpId = dateUtil._now(), + pumpId = dateUtil.now(), pumpType = pumpType ?: PumpType.GENERIC_AAPS, pumpSerial = serialNumber() ) @@ -254,12 +254,12 @@ open class VirtualPumpPlugin @Inject constructor( result.duration = durationInMinutes result.comment = resourceHelper.gs(R.string.virtualpump_resultok) pumpSync.syncTemporaryBasalWithPumpId( - timestamp = dateUtil._now(), + timestamp = dateUtil.now(), rate = percent.toDouble(), duration = T.mins(durationInMinutes.toLong()).msecs(), isAbsolute = false, type = tbrType, - pumpId = dateUtil._now(), + pumpId = dateUtil.now(), pumpType = pumpType ?: PumpType.GENERIC_AAPS, pumpSerial = serialNumber() ) @@ -279,11 +279,11 @@ open class VirtualPumpPlugin @Inject constructor( result.duration = durationInMinutes result.comment = resourceHelper.gs(R.string.virtualpump_resultok) pumpSync.syncExtendedBolusWithPumpId( - timestamp = dateUtil._now(), + timestamp = dateUtil.now(), amount = insulin, duration = T.mins(durationInMinutes.toLong()).msecs(), isEmulatingTB = false, - pumpId = dateUtil._now(), + pumpId = dateUtil.now(), pumpType = pumpType ?: PumpType.GENERIC_AAPS, pumpSerial = serialNumber() ) @@ -301,8 +301,8 @@ open class VirtualPumpPlugin @Inject constructor( if (pumpSync.expectedPumpState().temporaryBasal != null) { result.enacted = true pumpSync.syncStopTemporaryBasalWithPumpId( - timestamp = dateUtil._now(), - endPumpId = dateUtil._now(), + timestamp = dateUtil.now(), + endPumpId = dateUtil.now(), pumpType = pumpType ?: PumpType.GENERIC_AAPS, pumpSerial = serialNumber() ) @@ -317,8 +317,8 @@ open class VirtualPumpPlugin @Inject constructor( val result = PumpEnactResult(injector) if (pumpSync.expectedPumpState().extendedBolus != null) { pumpSync.syncStopExtendedBolusWithPumpId( - timestamp = dateUtil._now(), - endPumpId = dateUtil._now(), + timestamp = dateUtil.now(), + endPumpId = dateUtil.now(), pumpType = pumpType ?: PumpType.GENERIC_AAPS, pumpSerial = serialNumber() ) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt index 21ac388999..c5b41e1502 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt @@ -120,7 +120,7 @@ class DexcomPlugin @Inject constructor( for (i in 0 until meters.size()) { meters.getBundle(i.toString())?.let { val timestamp = it.getLong("timestamp") * 1000 - val now = dateUtil._now() + val now = dateUtil.now() if (timestamp > now - T.months(1).msecs() && timestamp < now) { calibrations.add(CgmSourceTransaction.Calibration( timestamp = it.getLong("timestamp") * 1000, diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt index 734bec03f5..ad9fc19c72 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt @@ -127,12 +127,12 @@ class NSClientSourcePlugin @Inject constructor( val glucoseValues = mutableListOf() for (i in 0 until sgvs.length()) { val sgv = toGv(sgvs.getJSONObject(i)) ?: continue - if (sgv.timestamp < dateUtil._now() && sgv.timestamp > latestDateInReceivedData) latestDateInReceivedData = sgv.timestamp + if (sgv.timestamp < dateUtil.now() && sgv.timestamp > latestDateInReceivedData) latestDateInReceivedData = sgv.timestamp glucoseValues += sgv } // Was that sgv more less 5 mins ago ? - if (T.msecs(dateUtil._now() - latestDateInReceivedData).mins() < 5L) { + if (T.msecs(dateUtil.now() - latestDateInReceivedData).mins() < 5L) { rxBus.send(EventDismissNotification(Notification.NS_ALARM)) rxBus.send(EventDismissNotification(Notification.NS_URGENT_ALARM)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt index 49d30ea7f7..a0eaf0ddfd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/RandomBgPlugin.kt @@ -18,7 +18,6 @@ import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.XDripBroadcast import info.nightscout.androidaps.utils.buildHelper.BuildHelper -import info.nightscout.androidaps.utils.extensions.isRunningTest import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import io.reactivex.disposables.CompositeDisposable @@ -103,7 +102,7 @@ class RandomBgPlugin @Inject constructor( val glucoseValues = mutableListOf() glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( - timestamp = dateUtil._now(), + timestamp = dateUtil.now(), value = bgMgdl, raw = 0.0, noise = null, diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsFragment.kt index ff941b4af9..8d9951c490 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/TreatmentsFragment.kt @@ -127,6 +127,6 @@ class TreatmentsFragment : DaggerFragment() { private fun updateGui() { if (_binding == null) return - binding.extendedBoluses.visibility = (activePlugin.activePump.pumpDescription.isExtendedBolusCapable || iobCobCalculator.getExtendedBolus(dateUtil._now()) != null).toVisibility() + binding.extendedBoluses.visibility = (activePlugin.activePump.pumpDescription.isExtendedBolusCapable || iobCobCalculator.getExtendedBolus(dateUtil.now()) != null).toVisibility() } } \ No newline at end of file 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 4d7fecd5db..a665e53368 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 @@ -147,7 +147,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface private void initializeProfileSwitchData(long range) { getAapsLogger().debug(LTag.DATATREATMENTS, "initializeProfileSwitchData"); synchronized (profiles) { - profiles.reset().add(databaseHelper.getProfileSwitchData(dateUtil._now() - range, false)); + profiles.reset().add(databaseHelper.getProfileSwitchData(dateUtil.now() - range, false)); } } @@ -161,7 +161,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface @Deprecated @Override public List getTreatmentsFromHistoryAfterTimestamp(long fromTimestamp) { - return repository.getBolusesIncludingInvalidFromTimeToTime(fromTimestamp, dateUtil._now(), true) + return repository.getBolusesIncludingInvalidFromTimeToTime(fromTimestamp, dateUtil.now(), true) .blockingGet() .stream() .map(bolus -> new Treatment(getInjector(), bolus)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusCarbsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusCarbsFragment.kt index e530d9dc6e..c94a00f068 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusCarbsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusCarbsFragment.kt @@ -113,7 +113,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), resourceHelper.gs(R.string.deletefuturetreatments) + "?", Runnable { uel.log(Action.DELETE_FUTURE_TREATMENTS, Sources.Treatments) repository - .getBolusesDataFromTime(dateUtil._now(), false) + .getBolusesDataFromTime(dateUtil.now(), false) .observeOn(aapsSchedulers.main) .subscribe { list -> list.forEach { bolus -> @@ -125,7 +125,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { } } repository - .getCarbsDataFromTime(dateUtil._now(), false) + .getCarbsDataFromTime(dateUtil.now(), false) .observeOn(aapsSchedulers.main) .subscribe { list -> list.forEach { carb -> @@ -137,7 +137,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { } } repository - .getBolusCalculatorResultsDataFromTime(dateUtil._now(), false) + .getBolusCalculatorResultsDataFromTime(dateUtil.now(), false) .observeOn(aapsSchedulers.main) .subscribe { list -> list.forEach { bolusCalc -> @@ -281,7 +281,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() { val iob = bolus.iobCalc(activePlugin, System.currentTimeMillis(), profile.dia) holder.binding.iob.text = resourceHelper.gs(R.string.formatinsulinunits, iob.iobContrib) if (iob.iobContrib != 0.0) holder.binding.iob.setTextColor(resourceHelper.gc(R.color.colorActive)) else holder.binding.iob.setTextColor(holder.binding.carbs.currentTextColor) - if (bolus.timestamp > dateUtil._now()) holder.binding.date.setTextColor(resourceHelper.gc(R.color.colorScheduled)) else holder.binding.date.setTextColor(holder.binding.carbs.currentTextColor) + if (bolus.timestamp > dateUtil.now()) holder.binding.date.setTextColor(resourceHelper.gc(R.color.colorScheduled)) else holder.binding.date.setTextColor(holder.binding.carbs.currentTextColor) holder.binding.mealOrCorrection.text = when (ml.bolus.type) { Bolus.Type.SMB -> "SMB" diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt index 5c9d9ffe4c..b05dfb2b40 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt @@ -69,7 +69,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { super.onViewCreated(view, savedInstanceState) binding.recyclerview.setHasFixedSize(true) binding.recyclerview.layoutManager = LinearLayoutManager(view.context) - binding.recyclerview.adapter = RecyclerProfileViewAdapter(databaseHelper.getProfileSwitchData(dateUtil._now() - T.days(30).msecs(), false)) + binding.recyclerview.adapter = RecyclerProfileViewAdapter(databaseHelper.getProfileSwitchData(dateUtil.now() - T.days(30).msecs(), false)) binding.refreshFromNightscout.setOnClickListener { activity?.let { activity -> @@ -108,7 +108,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { fun updateGUI() { if (_binding == null) return - binding.recyclerview.swapAdapter(RecyclerProfileViewAdapter(databaseHelper.getProfileSwitchData(dateUtil._now() - T.days(30).msecs(), false)), false) + binding.recyclerview.swapAdapter(RecyclerProfileViewAdapter(databaseHelper.getProfileSwitchData(dateUtil.now() - T.days(30).msecs(), false)), false) } inner class RecyclerProfileViewAdapter(private var profileSwitchList: List) : RecyclerView.Adapter() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt index 349853a1a3..78ead608b6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt @@ -153,7 +153,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() { private inner class RecyclerViewAdapter internal constructor(private var tempTargetList: List) : RecyclerView.Adapter() { - private val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() + private val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() private val currentlyActiveTarget = if (dbRecord is ValueWrapper.Existing) dbRecord.value else null override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): TempTargetsViewHolder = @@ -174,7 +174,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() { holder.binding.date.setTextColor( when { tempTarget.id == currentlyActiveTarget?.id -> resourceHelper.gc(R.color.colorActive) - tempTarget.timestamp > dateUtil._now() -> resourceHelper.gc(R.color.colorScheduled) + tempTarget.timestamp > dateUtil.now() -> resourceHelper.gc(R.color.colorScheduled) else -> holder.binding.reasonColon.currentTextColor }) holder.binding.remove.tag = tempTarget diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt index cebbfef585..c1dee0908d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt @@ -171,7 +171,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { holder.binding.duration.text = resourceHelper.gs(R.string.format_mins, T.msecs(tempBasal.duration).mins()) if (tempBasal.isAbsolute) holder.binding.rate.text = resourceHelper.gs(R.string.pump_basebasalrate, tempBasal.rate) else holder.binding.rate.text = resourceHelper.gs(R.string.format_percent, tempBasal.rate.toInt()) - val now = dateUtil._now() + val now = dateUtil.now() var iob = IobTotal(now) val profile = profileFunction.getProfile(now) if (profile != null) iob = tempBasal.iobCalc(now, profile, activePlugin.activeInsulin) @@ -194,7 +194,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { init { binding.remove.setOnClickListener { v: View -> val tempBasal = v.tag as TemporaryBasal - val profile = profileFunction.getProfile(dateUtil._now()) + val profile = profileFunction.getProfile(dateUtil.now()) ?: return@setOnClickListener context?.let { OKDialog.showConfirmation(it, resourceHelper.gs(R.string.removerecord), diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt index fffb7e59b1..2db33b17d4 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.kt @@ -201,7 +201,7 @@ open class CommandQueue @Inject constructor( if ((detailedBolusInfo.carbs > 0) && (!activePlugin.get().activePump.pumpDescription.storesCarbInfo || detailedBolusInfo.carbsDuration != 0L || - (detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp) > dateUtil._now()) + (detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp) > dateUtil.now()) ) { disposable += repository.runTransactionForResult(detailedBolusInfo.insertCarbsTransaction()) .subscribeBy( diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.kt b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.kt index 7d937ce0c9..4e425da52b 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.kt @@ -23,7 +23,7 @@ class CommandSMBBolus( override fun execute() { val r: PumpEnactResult val lastBolusTime = repository.getLastBolusRecord()?.timestamp ?: 0L - if (lastBolusTime != 0L && lastBolusTime + T.mins(3).msecs() > dateUtil._now()) { + if (lastBolusTime != 0L && lastBolusTime + T.mins(3).msecs() > dateUtil.now()) { aapsLogger.debug(LTag.PUMPQUEUE, "SMB requested but still in 3 min interval") r = PumpEnactResult(injector).enacted(false).success(false).comment("SMB requested but still in 3 min interval") } else if (detailedBolusInfo.deliverAtTheLatest != 0L && detailedBolusInfo.deliverAtTheLatest + T.mins(1).msecs() > System.currentTimeMillis()) { 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 9cbca96a78..8cd383cb6b 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt +++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt @@ -106,7 +106,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() { shouldUploadStatus = true else if (dateUtil.isOlderThan(activePlugin.activeAPS.lastAPSRun, 5)) shouldUploadStatus = true if (dateUtil.isOlderThan(lastIobUpload, IOB_UPDATE_FREQUENCY_IN_MINUTES) && shouldUploadStatus) { - lastIobUpload = dateUtil._now() + lastIobUpload = dateUtil.now() buildDeviceStatus(dateUtil, loopPlugin, iobCobCalculatorPlugin, profileFunction, activePlugin.activePump, receiverStatusStore, runningConfiguration, BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION)?.also { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/ActivityMonitor.kt b/app/src/main/java/info/nightscout/androidaps/utils/ActivityMonitor.kt index b6b4608ee7..313d82308b 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/ActivityMonitor.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/ActivityMonitor.kt @@ -27,10 +27,10 @@ class ActivityMonitor @Inject constructor( aapsLogger.debug(LTag.UI, "onActivityPaused: $name resumed == 0") return } - val elapsed = dateUtil._now() - resumed + val elapsed = dateUtil.now() - resumed val total = sp.getLong("Monitor_" + name + "_total", 0) if (total == 0L) { - sp.putLong("Monitor_" + name + "_start", dateUtil._now()) + sp.putLong("Monitor_" + name + "_start", dateUtil.now()) } sp.putLong("Monitor_" + name + "_total", total + elapsed) aapsLogger.debug(LTag.UI, "onActivityPaused: $name elapsed=$elapsed total=${total + elapsed}") @@ -39,7 +39,7 @@ class ActivityMonitor @Inject constructor( override fun onActivityResumed(activity: Activity?) { val name = activity?.javaClass?.simpleName ?: return aapsLogger.debug(LTag.UI, "onActivityResumed: $name") - sp.putLong("Monitor_" + name + "_" + "resumed", dateUtil._now()) + sp.putLong("Monitor_" + name + "_" + "resumed", dateUtil.now()) } override fun onActivityStarted(activity: Activity?) { @@ -66,7 +66,7 @@ class ActivityMonitor @Inject constructor( val activity = key.split("_")[1].replace("Activity", "") val duration = dateUtil.niceTimeScalar(v as Long, resourceHelper) val start = sp.getLong(key.replace("total", "start"), 0) - val days = T.msecs(dateUtil._now() - start).days() + val days = T.msecs(dateUtil.now() - start).days() result += resourceHelper.gs(R.string.activitymonitorformat, activity, duration, days) } return result diff --git a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt index b1b3365709..d20e0c0cbd 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/stats/TddCalculator.kt @@ -30,8 +30,8 @@ class TddCalculator @Inject constructor( ) { fun calculate(days: Long): LongSparseArray { - val startTime = MidnightTime.calc(dateUtil._now() - T.days(days).msecs()) - val endTime = MidnightTime.calc(dateUtil._now()) + val startTime = MidnightTime.calc(dateUtil.now() - T.days(days).msecs()) + val endTime = MidnightTime.calc(dateUtil.now()) val result = LongSparseArray() repository.getBolusesDataFromTimeToTime(startTime, endTime, true).blockingGet() diff --git a/app/src/main/java/info/nightscout/androidaps/utils/stats/TirCalculator.kt b/app/src/main/java/info/nightscout/androidaps/utils/stats/TirCalculator.kt index 2b996c34a8..eaa702f63f 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/stats/TirCalculator.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/stats/TirCalculator.kt @@ -26,8 +26,8 @@ class TirCalculator @Inject constructor( fun calculate(days: Long, lowMgdl: Double, highMgdl: Double): LongSparseArray { if (lowMgdl < 39) throw RuntimeException("Low below 39") if (lowMgdl > highMgdl) throw RuntimeException("Low > High") - val startTime = MidnightTime.calc(dateUtil._now() - T.days(days).msecs()) - val endTime = MidnightTime.calc(dateUtil._now()) + val startTime = MidnightTime.calc(dateUtil.now() - T.days(days).msecs()) + val endTime = MidnightTime.calc(dateUtil.now()) val bgReadings = repository.compatGetBgReadingsDataFromTime(startTime, endTime, true).blockingGet() val result = LongSparseArray() 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 ab34971cdd..5e9dfb11b2 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 @@ -249,7 +249,7 @@ class BolusWizard @Inject constructor( private fun createBolusCalculatorResult(): BolusCalculatorResult = BolusCalculatorResult( - timestamp = dateUtil._now(), + timestamp = dateUtil.now(), targetBGLow = targetBGLow, targetBGHigh = targetBGHigh, isf = sens, @@ -439,7 +439,7 @@ class BolusWizard @Inject constructor( } if (useAlarm && carbs > 0 && carbTime > 0) { - carbTimer.scheduleReminder(dateUtil._now() + T.mins(carbTime.toLong()).msecs()) + carbTimer.scheduleReminder(dateUtil.now() + T.mins(carbTime.toLong()).msecs()) } } }) diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizardEntry.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizardEntry.kt index dbaba180c5..5d3496e7e6 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizardEntry.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/wizard/QuickWizardEntry.kt @@ -18,7 +18,6 @@ import info.nightscout.androidaps.extensions.valueToUnits import info.nightscout.androidaps.utils.sharedPreferences.SP import org.json.JSONException import org.json.JSONObject -import java.util.* import javax.inject.Inject class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjector) { @@ -77,7 +76,7 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec fun isActive(): Boolean = Profile.secondsFromMidnight() >= validFrom() && Profile.secondsFromMidnight() <= validTo() fun doCalc(profile: Profile, profileName: String, lastBG: GlucoseValue, _synchronized: Boolean): BolusWizard { - val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() + val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() val tempTarget = if (dbRecord is ValueWrapper.Existing) dbRecord.value else null //BG var bg = 0.0 diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt index 7e2307533d..81c12437cf 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPluginTest.kt @@ -55,7 +55,7 @@ class ObjectivesPluginTest : TestBase() { c = objectivesPlugin.isLoopInvocationAllowed(c) Assert.assertEquals("Objectives: Objective 1 not started", c.getReasons(aapsLogger)) Assert.assertEquals(false, c.value()) - objectivesPlugin.objectives[ObjectivesPlugin.FIRST_OBJECTIVE].startedOn = dateUtil._now() + objectivesPlugin.objectives[ObjectivesPlugin.FIRST_OBJECTIVE].startedOn = dateUtil.now() } @Test fun notStartedObjective6ShouldLimitClosedLoop() { diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/AuthRequestTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/AuthRequestTest.kt index de7801890d..dcc14fabfc 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/AuthRequestTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/AuthRequestTest.kt @@ -5,7 +5,6 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBase -import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePassword import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePasswordValidationResult import info.nightscout.androidaps.utils.DateUtil @@ -89,10 +88,10 @@ class AuthRequestTest : TestBase() { // test timed out message val now: Long = 10000 PowerMockito.mockStatic(DateUtil::class.java) - PowerMockito.`when`(dateUtil._now()).thenReturn(now) + PowerMockito.`when`(dateUtil.now()).thenReturn(now) authRequest = AuthRequest(injector, requester, "Request text", "ABC", action) actionCalled = false - PowerMockito.`when`(dateUtil._now()).thenReturn(now + T.mins(Constants.SMS_CONFIRM_TIMEOUT).msecs() + 1) + PowerMockito.`when`(dateUtil.now()).thenReturn(now + T.mins(Constants.SMS_CONFIRM_TIMEOUT).msecs() + 1) authRequest.action("ABC") Assert.assertFalse(actionCalled) } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index 3295bd0508..8869464e7b 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt @@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.general.smsCommunicator -import android.content.Context import android.telephony.SmsManager import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector @@ -885,7 +884,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { Assert.assertEquals("BOLUS", smsCommunicatorPlugin.messages[0].text) Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text) `when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(1.0)) - PowerMockito.`when`(dateUtilMocked._now()).thenReturn(1000L) + PowerMockito.`when`(dateUtilMocked.now()).thenReturn(1000L) `when`(sp.getLong(R.string.key_smscommunicator_remotebolusmindistance, T.msecs(Constants.remoteBolusMinDistance).mins())).thenReturn(15L) //BOLUS 1 smsCommunicatorPlugin.messages = ArrayList() @@ -894,7 +893,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.messages[0].text) Assert.assertEquals("Remote bolus not available. Try again later.", smsCommunicatorPlugin.messages[1].text) `when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) - PowerMockito.`when`(dateUtilMocked._now()).thenReturn(Constants.remoteBolusMinDistance + 1002L) + PowerMockito.`when`(dateUtilMocked.now()).thenReturn(Constants.remoteBolusMinDistance + 1002L) //BOLUS 0 smsCommunicatorPlugin.messages = ArrayList() @@ -990,7 +989,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { } @Test fun processCarbsTest() { - PowerMockito.`when`(dateUtilMocked._now()).thenReturn(1000000L) + PowerMockito.`when`(dateUtilMocked.now()).thenReturn(1000000L) `when`(sp.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(false) //CAL smsCommunicatorPlugin.messages = ArrayList() diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt index e71b58a312..ca2ba012e0 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationEvent.kt @@ -84,6 +84,6 @@ class AutomationEvent(private val injector: HasAndroidInjector) { } fun shouldRun(): Boolean { - return lastRun <= dateUtil._now() - T.mins(5).msecs() + return lastRun <= dateUtil.now() - T.mins(5).msecs() } } \ No newline at end of file diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt index 6a3c5f8d83..3f5790b128 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt @@ -208,7 +208,7 @@ class AutomationPlugin @Inject constructor( action.doAction(object : Callback() { override fun run() { val sb = StringBuilder() - sb.append(dateUtil.timeString(dateUtil._now())) + sb.append(dateUtil.timeString(dateUtil.now())) sb.append(" ") sb.append(if (result.success) "☺" else "▼") sb.append(" ") @@ -229,7 +229,7 @@ class AutomationPlugin @Inject constructor( } } SystemClock.sleep(1100) - event.lastRun = dateUtil._now() + event.lastRun = dateUtil.now() if (event.autoRemove) automationEvents.remove(event) } } diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt index 470b74dfd2..1461e20838 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionAlarm.kt @@ -40,7 +40,7 @@ class ActionAlarm(injector: HasAndroidInjector) : Action(injector) { override fun isValid(): Boolean = true // empty alarm will show app name override fun doAction(callback: Callback) { - timerUtil.scheduleReminder(dateUtil._now() + T.secs(10L).msecs(), text.value.takeIf { it.isNotBlank() } + 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/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt index 07c727195b..5c2dadb9ca 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt @@ -62,7 +62,7 @@ class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) { uel.log(UserEntry.Action.PROFILE_SWITCH, Sources.Automation, title, ValueWithUnit.SimpleString(inputProfileName.value), ValueWithUnit.Percent(100)) - activePlugin.activeTreatments.doProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, dateUtil._now()) + activePlugin.activeTreatments.doProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, dateUtil.now()) callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() } diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt index 068d112649..4512a16034 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt @@ -106,7 +106,7 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) { } fun tt() = TemporaryTarget( - timestamp = dateUtil._now(), + timestamp = dateUtil.now(), duration = TimeUnit.MINUTES.toMillis(duration.getMinutes().toLong()), reason = TemporaryTarget.Reason.AUTOMATION, lowTarget = Profile.toMgdl(value.value, value.units), diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt index 932d7d9d0a..9d4443d466 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt @@ -30,7 +30,7 @@ class ActionStopTempTarget(injector: HasAndroidInjector) : Action(injector) { override fun icon(): Int = R.drawable.ic_stop_24dp override fun doAction(callback: Callback) { - disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil._now())) + disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil.now())) .subscribe({ result -> uel.log(UserEntry.Action.CANCEL_TT, Sources.Automation, title) result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt index 13c94c7eff..df0939bfa7 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputDateTime.kt @@ -12,7 +12,7 @@ import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper import java.util.* -class InputDateTime(private val resourceHelper: ResourceHelper, private val dateUtil: DateUtil, var value: Long = dateUtil._now()) : Element() { +class InputDateTime(private val resourceHelper: ResourceHelper, private val dateUtil: DateUtil, var value: Long = dateUtil.now()) : Element() { override fun addToLayout(root: LinearLayout) { val label = TextView(root.context) diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt index 2605125c9b..d73b5150b6 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTime.kt @@ -15,7 +15,7 @@ import java.util.* class InputTime(private val resourceHelper: ResourceHelper, private val dateUtil: DateUtil) : Element() { - var value: Int = getMinSinceMidnight(dateUtil._now()) + var value: Int = getMinSinceMidnight(dateUtil.now()) override fun addToLayout(root: LinearLayout) { val label = TextView(root.context) diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt index c37d040df0..6511eb8194 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/InputTimeRange.kt @@ -15,8 +15,8 @@ import java.util.* class InputTimeRange(private val resourceHelper: ResourceHelper, private val dateUtil: DateUtil) : Element() { - var start: Int = getMinSinceMidnight(dateUtil._now()) - var end: Int = getMinSinceMidnight(dateUtil._now()) + var start: Int = getMinSinceMidnight(dateUtil.now()) + var end: Int = getMinSinceMidnight(dateUtil.now()) override fun addToLayout(root: LinearLayout) { val label = TextView(root.context) diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt index 2ac5203aec..b7b47aa66f 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgo.kt @@ -45,7 +45,7 @@ class TriggerBolusAgo(injector: HasAndroidInjector) : Trigger(injector) { aapsLogger.debug(LTag.AUTOMATION, "NOT ready for execution: " + friendlyDescription()) false } - val last = (dateUtil._now() - lastBolusTime).toDouble() / (60 * 1000) + val last = (dateUtil.now() - lastBolusTime).toDouble() / (60 * 1000) aapsLogger.debug(LTag.AUTOMATION, "LastBolus min ago: $minutesAgo") val doRun = comparator.value.check(last.toInt(), minutesAgo.getMinutes()) if (doRun) { diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIob.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIob.kt index 59e7e712f6..a4e62d090e 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIob.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIob.kt @@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.general.automation.elements.InputInsul import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel -import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.JsonHelper import org.json.JSONObject @@ -35,7 +34,7 @@ class TriggerIob(injector: HasAndroidInjector) : Trigger(injector) { override fun shouldRun(): Boolean { val profile = profileFunction.getProfile() ?: return false - val iob = iobCobCalculatorPlugin.calculateFromTreatmentsAndTempsSynchronized(dateUtil._now(), profile) + val iob = iobCobCalculatorPlugin.calculateFromTreatmentsAndTempsSynchronized(dateUtil.now(), profile) if (comparator.value.check(iob.iob, insulin.value)) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) return true diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnection.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnection.kt index d43b2a61d7..cfcdd788ba 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnection.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnection.kt @@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.general.automation.elements.InputDurat import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel -import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.JsonHelper.safeGetInt import info.nightscout.androidaps.utils.JsonHelper.safeGetString import org.json.JSONObject @@ -47,7 +46,7 @@ class TriggerPumpLastConnection(injector: HasAndroidInjector) : Trigger(injector aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) return true } - val connectionAgo = (dateUtil._now() - lastConnection) / (60 * 1000) + val connectionAgo = (dateUtil.now() - lastConnection) / (60 * 1000) aapsLogger.debug(LTag.AUTOMATION, "Last connection min ago: $connectionAgo") if (comparator.value.check(connectionAgo.toInt(), minutesAgo.value)) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt index c382803c21..383adcce50 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTime.kt @@ -32,7 +32,7 @@ class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) { } override fun shouldRun(): Boolean { - val currentMinSinceMidnight = getMinSinceMidnight(dateUtil._now()) + val currentMinSinceMidnight = getMinSinceMidnight(dateUtil.now()) val scheduledDayOfWeek = Calendar.getInstance()[Calendar.DAY_OF_WEEK] if (days.isSet(Objects.requireNonNull(InputWeekDay.DayOfWeek.fromCalendarInt(scheduledDayOfWeek)))) { if (currentMinSinceMidnight >= time.value && currentMinSinceMidnight - time.value < 5) { diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt index 9c7d64add0..216e84871d 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTarget.kt @@ -30,7 +30,7 @@ class TriggerTempTarget(injector: HasAndroidInjector) : Trigger(injector) { } override fun shouldRun(): Boolean { - val tt = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() + val tt = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() if (tt is ValueWrapper.Absent && comparator.value == ComparatorExists.Compare.NOT_EXISTS) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) return true diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt index 92f180144b..f03c35c6fc 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.kt @@ -8,7 +8,6 @@ import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.InputDateTime import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel -import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.JsonHelper import info.nightscout.androidaps.utils.T import org.json.JSONObject @@ -32,7 +31,7 @@ class TriggerTime(injector: HasAndroidInjector) : Trigger(injector) { } override fun shouldRun(): Boolean { - val now = dateUtil._now() + val now = dateUtil.now() if (now >= time.value && now - time.value < T.mins(5).msecs()) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) return true diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt index 488f3d1d19..494b3980cf 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRange.kt @@ -9,7 +9,6 @@ import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.general.automation.elements.InputTimeRange import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel -import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.JsonHelper.safeGetInt import info.nightscout.androidaps.utils.MidnightTime import org.json.JSONObject @@ -38,7 +37,7 @@ class TriggerTimeRange(injector: HasAndroidInjector) : Trigger(injector) { } override fun shouldRun(): Boolean { - val currentMinSinceMidnight = getMinSinceMidnight(dateUtil._now()) + val currentMinSinceMidnight = getMinSinceMidnight(dateUtil.now()) var doRun = false if (range.start < range.end && range.start < currentMinSinceMidnight && currentMinSinceMidnight < range.end) doRun = true else if (range.start > range.end && (range.start < currentMinSinceMidnight || currentMinSinceMidnight < range.end)) doRun = true diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt index 9cc4c9be05..a8c803c8ff 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValueTest.kt @@ -114,7 +114,7 @@ class TriggerAutosensValueTest : TriggerTestBase() { @Before fun mock() { - PowerMockito.`when`(dateUtil._now()).thenReturn(now) + PowerMockito.`when`(dateUtil.now()).thenReturn(now) } private fun generateAutosensData(): AutosensData { diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt index 7d4a060e81..fe0e9049ba 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.kt @@ -13,7 +13,6 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.`when` -import org.powermock.api.mockito.PowerMockito import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner import java.util.* @@ -28,7 +27,7 @@ class TriggerBgTest : TriggerTestBase() { fun prepare() { `when`(profileFunction.getUnits()).thenReturn(Constants.MGDL) `when`(iobCobCalculatorPlugin.dataLock).thenReturn(Any()) - `when`(dateUtil._now()).thenReturn(now) + `when`(dateUtil.now()).thenReturn(now) } @Test diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt index 6e1e68d24e..29beab1464 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBolusAgoTest.kt @@ -24,7 +24,7 @@ class TriggerBolusAgoTest : TriggerTestBase() { @Before fun mock() { - PowerMockito.`when`(dateUtil._now()).thenReturn(now) + PowerMockito.`when`(dateUtil.now()).thenReturn(now) } @Test @@ -36,7 +36,7 @@ class TriggerBolusAgoTest : TriggerTestBase() { type = Bolus.Type.NORMAL ) ) // Set last bolus time to now - `when`(dateUtil._now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min + `when`(dateUtil.now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min var t = TriggerBolusAgo(injector).setValue(110).comparator(Comparator.Compare.IS_EQUAL) Assert.assertEquals(110, t.minutesAgo.value) Assert.assertEquals(Comparator.Compare.IS_EQUAL, t.comparator.value) diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOBTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOBTest.kt index 258eef4fa3..d194c50b1b 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOBTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerCOBTest.kt @@ -22,7 +22,7 @@ class TriggerCOBTest : TriggerTestBase() { var now = 1514766900000L @Before fun mock() { - PowerMockito.`when`(dateUtil._now()).thenReturn(now) + PowerMockito.`when`(dateUtil.now()).thenReturn(now) PowerMockito.`when`(sp.getInt(ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt())).thenReturn(48) } diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt index 53e0ca56b8..9a9107ec4b 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerDeltaTest.kt @@ -27,7 +27,7 @@ class TriggerDeltaTest : TriggerTestBase() { @Before fun mock() { - PowerMockito.`when`(dateUtil._now()).thenReturn(now) + PowerMockito.`when`(dateUtil.now()).thenReturn(now) `when`(iobCobCalculatorPlugin.dataLock).thenReturn(Any()) `when`(profileFunction.getUnits()).thenReturn(Constants.MGDL) } diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIobTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIobTest.kt index aae4ed46b3..d013e2f9c4 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIobTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerIobTest.kt @@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.general.automation.triggers import com.google.common.base.Optional import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.data.IobTotal -import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.utils.DateUtil import org.json.JSONObject @@ -13,7 +12,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentMatchers import org.mockito.Mockito.`when` -import org.powermock.api.mockito.PowerMockito import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @@ -24,7 +22,7 @@ class TriggerIobTest : TriggerTestBase() { var now = 1514766900000L @Before fun mock() { - `when`(dateUtil._now()).thenReturn(now) + `when`(dateUtil.now()).thenReturn(now) `when`(profileFunction.getProfile()).thenReturn(validProfile) } diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocationTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocationTest.kt index 88e7a5d7a6..c533c8f257 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocationTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerLocationTest.kt @@ -25,7 +25,7 @@ class TriggerLocationTest : TriggerTestBase() { @Before fun mock() { PowerMockito.mockStatic(LocationService::class.java) - `when`(dateUtil._now()).thenReturn(now) + `when`(dateUtil.now()).thenReturn(now) PowerMockito.spy(LocationService::class.java) `when`(locationDataContainer.lastLocation).thenReturn(mockedLocation()) } diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercentTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercentTest.kt index e0fd1f0537..27c910ca78 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercentTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerProfilePercentTest.kt @@ -23,7 +23,7 @@ class TriggerProfilePercentTest : TriggerTestBase() { @Before fun mock() { `when`(profileFunction.getProfile()).thenReturn(validProfile) - PowerMockito.`when`(dateUtil._now()).thenReturn(now) + PowerMockito.`when`(dateUtil.now()).thenReturn(now) } @Test fun shouldRunTest() { diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnectionTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnectionTest.kt index 7a6aadc798..bddce94217 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnectionTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerPumpLastConnectionTest.kt @@ -21,7 +21,7 @@ class TriggerPumpLastConnectionTest : TriggerTestBase() { @Before fun mock() { - PowerMockito.`when`(dateUtil._now()).thenReturn(now) + PowerMockito.`when`(dateUtil.now()).thenReturn(now) } @Test @@ -29,7 +29,7 @@ class TriggerPumpLastConnectionTest : TriggerTestBase() { // System.currentTimeMillis() is always 0 // and so is every last connection time Assert.assertEquals(0L, testPumpPlugin.lastDataTime()) - PowerMockito.`when`(dateUtil._now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min + PowerMockito.`when`(dateUtil.now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min var t = TriggerPumpLastConnection(injector).setValue(110).comparator(Comparator.Compare.IS_EQUAL) Assert.assertEquals(110, t.minutesAgo.value) Assert.assertEquals(Comparator.Compare.IS_EQUAL, t.comparator.value) diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt index b76fc0bd90..e764e22747 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerRecurringTimeTest.kt @@ -20,7 +20,7 @@ class TriggerRecurringTimeTest : TriggerTestBase() { @Before fun mock() { now = MidnightTime.calc() + T.mins(95).msecs() // 95 min from midnight - PowerMockito.`when`(dateUtil._now()).thenReturn(now) + PowerMockito.`when`(dateUtil.now()).thenReturn(now) } @Test fun shouldRunTest() { diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTargetTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTargetTest.kt index 7560ca0423..64ba71fd14 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTargetTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTempTargetTest.kt @@ -20,7 +20,7 @@ class TriggerTempTargetTest : TriggerTestBase() { var now = 1514766900000L @Before fun mock() { - PowerMockito.`when`(dateUtil._now()).thenReturn(now) + PowerMockito.`when`(dateUtil.now()).thenReturn(now) } /* @Test fun shouldRunTest() { diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRangeTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRangeTest.kt index 2726fbd349..3e01059aa6 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRangeTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeRangeTest.kt @@ -23,7 +23,7 @@ class TriggerTimeRangeTest : TriggerTestBase() { @Before fun mock() { val nowMills = MidnightTime.calcPlusMinutes(now) - PowerMockito.`when`(dateUtil._now()).thenReturn(nowMills) + PowerMockito.`when`(dateUtil.now()).thenReturn(nowMills) } @Test diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeTest.kt index 16f5a42947..8c38c37761 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTimeTest.kt @@ -21,7 +21,7 @@ class TriggerTimeTest : TriggerTestBase() { var now = 1514766900000L @Before fun mock() { - PowerMockito.`when`(dateUtil._now()).thenReturn(now) + PowerMockito.`when`(dateUtil.now()).thenReturn(now) } @Test fun shouldRunTest() { diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsidTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsidTest.kt index 5dfd6e4ee9..4b38476f98 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsidTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerWifiSsidTest.kt @@ -24,7 +24,7 @@ class TriggerWifiSsidTest : TriggerTestBase() { @Before fun mock() { PowerMockito.mockStatic(NetworkChangeReceiver::class.java) - PowerMockito.`when`(dateUtil._now()).thenReturn(now) + PowerMockito.`when`(dateUtil.now()).thenReturn(now) } @Test fun shouldRunTest() { diff --git a/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java b/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java index 926a2f3545..aa4bfba45a 100644 --- a/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java +++ b/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java @@ -969,7 +969,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr // so update the var with it, so the check routines below can work on it preCheckResult = alertConfirmationResult; } else if (activeAlert.errorCode != null) { - Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, dateUtil._now(), getResourceHelper().gs(R.string.combo_is_in_error_state, activeAlert.errorCode, activeAlert.message), Notification.URGENT, 0); + Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, dateUtil.now(), getResourceHelper().gs(R.string.combo_is_in_error_state, activeAlert.errorCode, activeAlert.message), Notification.URGENT, 0); rxBus.send(new EventNewNotification(notification)); return preCheckResult.success(false); } @@ -1067,7 +1067,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr throw new IllegalArgumentException(activeAlert.toString()); } Notification notification = new Notification(); - notification.setDate(dateUtil._now()); + notification.setDate(dateUtil.now()); notification.setId(Notification.COMBO_PUMP_ALARM); notification.setLevel(Notification.NORMAL); if (activeAlert.warningCode == PumpWarningCodes.CARTRIDGE_LOW) { diff --git a/core/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java b/core/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java index 6dae8f7dd0..7f4477e13d 100644 --- a/core/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java +++ b/core/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java @@ -235,7 +235,7 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface { @Override public boolean isValid() { boolean isValid = getProfileObject() != null && getProfileObject().isValid(dateUtil.dateAndTimeString(date)); - ProfileSwitch active = treatmentsPlugin.getProfileSwitchFromHistory(dateUtil._now()); + ProfileSwitch active = treatmentsPlugin.getProfileSwitchFromHistory(dateUtil.now()); long activeProfileSwitchDate = active != null ? active.date : -1L; if (!isValid && date == activeProfileSwitchDate) createNotificationInvalidProfile(dateUtil.dateAndTimeString(date)); diff --git a/core/src/main/java/info/nightscout/androidaps/extensions/DeviceStatusExtension.kt b/core/src/main/java/info/nightscout/androidaps/extensions/DeviceStatusExtension.kt index 00df65d18f..d7496fafe6 100644 --- a/core/src/main/java/info/nightscout/androidaps/extensions/DeviceStatusExtension.kt +++ b/core/src/main/java/info/nightscout/androidaps/extensions/DeviceStatusExtension.kt @@ -43,7 +43,7 @@ fun buildDeviceStatus( var apsResult: JSONObject? = null var iob: JSONObject? = null var enacted: JSONObject? = null - if (lastRun != null && lastRun.lastAPSRun > dateUtil._now() - 300 * 1000L) { + if (lastRun != null && lastRun.lastAPSRun > dateUtil.now() - 300 * 1000L) { // do not send if result is older than 1 min apsResult = lastRun.request?.json()?.also { it.put("timestamp", dateUtil.toISOString(lastRun.lastAPSRun)) @@ -69,11 +69,11 @@ fun buildDeviceStatus( val calcIob = iobCobCalculatorPlugin.calculateIobArrayInDia(profile) if (calcIob.isNotEmpty()) { iob = calcIob[0].json(dateUtil) - iob.put("time", dateUtil.toISOString(dateUtil._now())) + iob.put("time", dateUtil.toISOString(dateUtil.now())) } } return DeviceStatus( - timestamp = dateUtil._now(), + timestamp = dateUtil.now(), suggested = apsResult?.toString(), iob = iob?.toString(), enacted = enacted?.toString(), diff --git a/core/src/main/java/info/nightscout/androidaps/extensions/ExtendedBolusExtension.kt b/core/src/main/java/info/nightscout/androidaps/extensions/ExtendedBolusExtension.kt index 96a8f80e3c..6c75f72cd0 100644 --- a/core/src/main/java/info/nightscout/androidaps/extensions/ExtendedBolusExtension.kt +++ b/core/src/main/java/info/nightscout/androidaps/extensions/ExtendedBolusExtension.kt @@ -22,17 +22,17 @@ import kotlin.math.round import kotlin.math.roundToInt fun ExtendedBolus.isInProgress(dateUtil: DateUtil): Boolean = - dateUtil._now() in timestamp..timestamp + duration + dateUtil.now() in timestamp..timestamp + duration val ExtendedBolus.plannedRemainingMinutes: Int get() = max(round((end - System.currentTimeMillis()) / 1000.0 / 60).toInt(), 0) fun ExtendedBolus.toStringFull(dateUtil: DateUtil): String = "E " + to2Decimal(rate) + "U/h @" + dateUtil.timeString(timestamp) + - " " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + T.msecs(duration).mins() + "min" + " " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "min" fun ExtendedBolus.toStringMedium(dateUtil: DateUtil): String = - to2Decimal(rate) + "U/h " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + T.msecs(duration).mins() + "'" + to2Decimal(rate) + "U/h " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "'" fun ExtendedBolus.toStringTotal(): String = "${to2Decimal(amount)}U ( ${to2Decimal(rate)} U/h )" diff --git a/core/src/main/java/info/nightscout/androidaps/extensions/PumpStateExtension.kt b/core/src/main/java/info/nightscout/androidaps/extensions/PumpStateExtension.kt index f6c6994dfb..beb349d3d6 100644 --- a/core/src/main/java/info/nightscout/androidaps/extensions/PumpStateExtension.kt +++ b/core/src/main/java/info/nightscout/androidaps/extensions/PumpStateExtension.kt @@ -35,13 +35,13 @@ fun PumpSync.PumpState.TemporaryBasal.toStringFull(dateUtil: DateUtil): String { isAbsolute -> { DecimalFormatter.to2Decimal(rate) + "U/h @" + dateUtil.timeString(timestamp) + - " " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + durationInMinutes + "'" + " " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'" } else -> { // percent rate.toString() + "% @" + dateUtil.timeString(timestamp) + - " " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + durationInMinutes + "'" + " " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'" } } } @@ -58,5 +58,5 @@ fun PumpSync.PumpState.ExtendedBolus.getPassedDurationToTimeInMinutes(time: Long fun PumpSync.PumpState.ExtendedBolus.toStringFull(dateUtil: DateUtil): String = "E " + to2Decimal(rate) + "U/h @" + dateUtil.timeString(timestamp) + - " " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + T.msecs(duration).mins() + "min" + " " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "min" diff --git a/core/src/main/java/info/nightscout/androidaps/extensions/TemporaryBasalExtension.kt b/core/src/main/java/info/nightscout/androidaps/extensions/TemporaryBasalExtension.kt index c7706b7609..549792a109 100644 --- a/core/src/main/java/info/nightscout/androidaps/extensions/TemporaryBasalExtension.kt +++ b/core/src/main/java/info/nightscout/androidaps/extensions/TemporaryBasalExtension.kt @@ -45,19 +45,19 @@ fun TemporaryBasal.toStringFull(profile: Profile, dateUtil: DateUtil): String { type == TemporaryBasal.Type.FAKE_EXTENDED -> { to2Decimal(rate) + "U/h (" + to2Decimal(netExtendedRate(profile)) + "E) @" + dateUtil.timeString(timestamp) + - " " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + durationInMinutes + "'" + " " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'" } isAbsolute -> { to2Decimal(rate) + "U/h @" + dateUtil.timeString(timestamp) + - " " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + durationInMinutes + "'" + " " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'" } else -> { // percent rate.toString() + "% @" + dateUtil.timeString(timestamp) + - " " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + durationInMinutes + "'" + " " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'" } } } diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatusProvider.kt b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatusProvider.kt index 8f96965997..544c1b4d9c 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatusProvider.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/GlucoseStatusProvider.kt @@ -27,7 +27,7 @@ class GlucoseStatusProvider @Inject constructor( aapsLogger.debug(LTag.GLUCOSE, "sizeRecords==0") return null } - if (data[0].timestamp < dateUtil._now() - 7 * 60 * 1000L && !allowOldData) { + if (data[0].timestamp < dateUtil.now() - 7 * 60 * 1000L && !allowOldData) { aapsLogger.debug(LTag.GLUCOSE, "oldData") return null } diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt b/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt index 20d4f3a47b..f51cbcedc7 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt @@ -63,8 +63,8 @@ class PumpSyncImplementation @Inject constructor( aapsLogger.debug(LTag.PUMP, "Registering new pump ${type.description} $serialNumber") sp.putString(R.string.key_active_pump_type, type.description) sp.putString(R.string.key_active_pump_serial_number, serialNumber) - sp.putLong(R.string.key_active_pump_change_timestamp, dateUtil._now()) // allow only data newer than register time (ie. ignore older history) - return timestamp > dateUtil._now() - T.mins(1).msecs() // allow first record to be 1 min old + sp.putLong(R.string.key_active_pump_change_timestamp, dateUtil.now()) // allow only data newer than register time (ie. ignore older history) + return timestamp > dateUtil.now() - T.mins(1).msecs() // allow first record to be 1 min old } if (type.description == storedType && serialNumber == storedSerial && timestamp >= storedTimestamp) { @@ -80,8 +80,8 @@ class PumpSyncImplementation @Inject constructor( override fun expectedPumpState(): PumpSync.PumpState { val bolus = repository.getLastBolusRecord() - val temporaryBasal = repository.getTemporaryBasalActiveAt(dateUtil._now()).blockingGet() - val extendedBolus = repository.getExtendedBolusActiveAt(dateUtil._now()).blockingGet() + val temporaryBasal = repository.getTemporaryBasalActiveAt(dateUtil.now()).blockingGet() + val extendedBolus = repository.getExtendedBolusActiveAt(dateUtil.now()).blockingGet() return PumpSync.PumpState( temporaryBasal = @@ -229,7 +229,7 @@ class PumpSyncImplementation @Inject constructor( } override fun insertAnnouncement(error: String, pumpId: Long?, pumpType: PumpType, pumpSerial: String) { - if (!confirmActivePump(dateUtil._now(), pumpType, pumpSerial)) return + if (!confirmActivePump(dateUtil.now(), pumpType, pumpSerial)) return disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(error, pumpId, pumpType.toDbPumpType(), pumpSerial)) .subscribe() } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt b/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt index 51927f7db3..f5ef60d7f1 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt @@ -134,17 +134,17 @@ open class DateUtil @Inject constructor(private val context: Context) { } fun minAgo(resourceHelper: ResourceHelper, time: Long): String { - val mins = ((_now() - time) / 1000 / 60).toInt() + val mins = ((now() - time) / 1000 / 60).toInt() return resourceHelper.gs(R.string.minago, mins) } fun minAgoShort(time: Long): String { - val mins = ((time - _now()) / 1000 / 60).toInt() + val mins = ((time - now()) / 1000 / 60).toInt() return (if (mins > 0) "+" else "") + mins } fun hourAgo(time: Long, resourceHelper: ResourceHelper): String { - val hours = (_now() - time) / 1000.0 / 60 / 60 + val hours = (now() - time) / 1000.0 / 60 / 60 return resourceHelper.gs(R.string.hoursago, hours) } @@ -171,7 +171,7 @@ open class DateUtil @Inject constructor(private val context: Context) { return timeFrameString(timestamp - System.currentTimeMillis(), resourceHelper) } - fun _now(): Long { + fun now(): Long { return System.currentTimeMillis() } @@ -182,12 +182,12 @@ open class DateUtil @Inject constructor(private val context: Context) { } fun isCloseToNow(date: Long): Boolean { - val diff = abs(date - _now()) + val diff = abs(date - now()) return diff < T.mins(2L).msecs() } fun isOlderThan(date: Long, minutes: Long): Boolean { - val diff = _now() - date + val diff = now() - date return diff > T.mins(minutes).msecs() } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt b/core/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt index 962da57a05..d1977090ac 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/TimerUtil.kt @@ -17,7 +17,7 @@ class TimerUtil @Inject constructor( fun scheduleReminder(time: Long, text: String? = null) { Intent(AlarmClock.ACTION_SET_TIMER).apply { - val length: Int = ((time - dateUtil._now()) / 1000).toInt() + 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) diff --git a/core/src/test/java/info/nightscout/androidaps/data/IobTotalTest.kt b/core/src/test/java/info/nightscout/androidaps/data/IobTotalTest.kt index 5f25e4cd97..bfe97bc80a 100644 --- a/core/src/test/java/info/nightscout/androidaps/data/IobTotalTest.kt +++ b/core/src/test/java/info/nightscout/androidaps/data/IobTotalTest.kt @@ -21,7 +21,7 @@ class IobTotalTest { @Before fun prepare() { dateUtil = DateUtil(context) - now = dateUtil._now() + now = dateUtil.now() } @Test fun copyTest() { diff --git a/core/src/test/java/info/nightscout/androidaps/plugins/iob/iobCalculator/GlucoseStatusTest.kt b/core/src/test/java/info/nightscout/androidaps/plugins/iob/iobCalculator/GlucoseStatusTest.kt index 660666ba06..d443f2d603 100644 --- a/core/src/test/java/info/nightscout/androidaps/plugins/iob/iobCalculator/GlucoseStatusTest.kt +++ b/core/src/test/java/info/nightscout/androidaps/plugins/iob/iobCalculator/GlucoseStatusTest.kt @@ -104,7 +104,7 @@ class GlucoseStatusTest : TestBase() { @Before fun initMocking() { - PowerMockito.`when`(dateUtil._now()).thenReturn(1514766900000L + T.mins(1).msecs()) + PowerMockito.`when`(dateUtil.now()).thenReturn(1514766900000L + T.mins(1).msecs()) `when`(iobCobCalculatorPlugin.dataLock).thenReturn(Any()) } diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt b/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt index afc3a92762..1c6e3d152d 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt @@ -91,7 +91,7 @@ class DanaFragment : DaggerFragment() { val profileName = danaPump.createConvertedProfile()?.getDefaultProfileName() ?: return@setOnClickListener val args = Bundle() - args.putLong("time", dateUtil._now()) + args.putLong("time", dateUtil.now()) args.putInt("mode", ProfileViewerDialog.Mode.CUSTOM_PROFILE.ordinal) args.putString("customProfile", profile.data.toString()) args.putString("customProfileUnits", profile.units) diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/DanaPump.kt b/dana/src/main/java/info/nightscout/androidaps/dana/DanaPump.kt index 5713c7788b..09f961eb2a 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/DanaPump.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/DanaPump.kt @@ -132,7 +132,7 @@ class DanaPump @Inject constructor( } get() = T.msecs(tempBasalDuration).mins() var isTempBasalInProgress: Boolean - get() = tempBasalStart != 0L && dateUtil._now() in tempBasalStart..tempBasalStart + tempBasalDuration + get() = tempBasalStart != 0L && dateUtil.now() in tempBasalStart..tempBasalStart + tempBasalDuration set(isRunning) { if (isRunning) throw IllegalArgumentException("Use to cancel TBR only") else { @@ -142,12 +142,12 @@ class DanaPump @Inject constructor( } } val tempBasalRemainingMin: Int - get() = max(T.msecs(tempBasalStart + tempBasalDuration - dateUtil._now()).mins().toInt(), 0) + get() = max(T.msecs(tempBasalStart + tempBasalDuration - dateUtil.now()).mins().toInt(), 0) fun temporaryBasalToString(): String { if (!isTempBasalInProgress) return "" - val passedMin = ((min(dateUtil._now(), tempBasalStart + tempBasalDuration) - tempBasalStart) / 60.0 / 1000).roundToInt() + val passedMin = ((min(dateUtil.now(), tempBasalStart + tempBasalDuration) - tempBasalStart) / 60.0 / 1000).roundToInt() return tempBasalPercent.toString() + "% @" + dateUtil.timeString(tempBasalStart) + " " + passedMin + "/" + T.msecs(tempBasalDuration).mins() + "'" @@ -174,7 +174,7 @@ class DanaPump @Inject constructor( var extendedBolusAmount = 0.0 var isExtendedInProgress: Boolean - get() = extendedBolusStart != 0L && dateUtil._now() in extendedBolusStart..extendedBolusStart + extendedBolusDuration + get() = extendedBolusStart != 0L && dateUtil.now() in extendedBolusStart..extendedBolusStart + extendedBolusDuration set(isRunning) { if (isRunning) throw IllegalArgumentException("Use to cancel EB only") else { @@ -184,9 +184,9 @@ class DanaPump @Inject constructor( } } val extendedBolusPassedMinutes: Int - get() = T.msecs(max(0, dateUtil._now() - extendedBolusStart)).mins().toInt() + get() = T.msecs(max(0, dateUtil.now() - extendedBolusStart)).mins().toInt() val extendedBolusRemainingMinutes: Int - get() = max(T.msecs(extendedBolusStart + extendedBolusDuration - dateUtil._now()).mins().toInt(), 0) + get() = max(T.msecs(extendedBolusStart + extendedBolusDuration - dateUtil.now()).mins().toInt(), 0) private val extendedBolusDurationInMinutes: Int get() = T.msecs(extendedBolusDuration).mins().toInt() var extendedBolusAbsoluteRate: Double diff --git a/danar/src/main/java/info/nightscout/androidaps/danaRKorean/DanaRKoreanPlugin.java b/danar/src/main/java/info/nightscout/androidaps/danaRKorean/DanaRKoreanPlugin.java index 2b5ad8633e..76b614df6e 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danaRKorean/DanaRKoreanPlugin.java +++ b/danar/src/main/java/info/nightscout/androidaps/danaRKorean/DanaRKoreanPlugin.java @@ -185,7 +185,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { detailedBolusInfo.timestamp, detailedBolusInfo.insulin, detailedBolusInfo.getBolusType(), - dateUtil._now(), + dateUtil.now(), PumpType.DANA_R_KOREAN, serialNumber() ); @@ -348,8 +348,8 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { sExecutionService.tempBasalStop(); if (!danaPump.isTempBasalInProgress()) { pumpSync.syncStopTemporaryBasalWithPumpId( - dateUtil._now(), - dateUtil._now(), + dateUtil.now(), + dateUtil.now(), getPumpDescription().getPumpType(), serialNumber() ); diff --git a/danar/src/main/java/info/nightscout/androidaps/danaRKorean/services/DanaRKoreanExecutionService.java b/danar/src/main/java/info/nightscout/androidaps/danaRKorean/services/DanaRKoreanExecutionService.java index 84fa9792b4..02ae08ec28 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danaRKorean/services/DanaRKoreanExecutionService.java +++ b/danar/src/main/java/info/nightscout/androidaps/danaRKorean/services/DanaRKoreanExecutionService.java @@ -184,7 +184,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { if (Math.abs(timeDiff) > 10) { waitForWholeMinute(); // Dana can set only whole minute // add 10sec to be sure we are over minute (will be cut off anyway) - mSerialIOThread.sendMessage(new MsgSetTime(injector, dateUtil._now() + T.secs(10).msecs())); + mSerialIOThread.sendMessage(new MsgSetTime(injector, dateUtil.now() + T.secs(10).msecs())); mSerialIOThread.sendMessage(new MsgSettingPumpTime(injector)); timeDiff = (danaPump.getPumpTime() - System.currentTimeMillis()) / 1000L; aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); diff --git a/danar/src/main/java/info/nightscout/androidaps/danaRv2/DanaRv2Plugin.java b/danar/src/main/java/info/nightscout/androidaps/danaRv2/DanaRv2Plugin.java index c5472ff4cd..72d70a14ab 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danaRv2/DanaRv2Plugin.java +++ b/danar/src/main/java/info/nightscout/androidaps/danaRv2/DanaRv2Plugin.java @@ -175,7 +175,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { speed = 60; break; } - detailedBolusInfo.timestamp = dateUtil._now() + (long) (speed * detailedBolusInfo.insulin * 1000); + detailedBolusInfo.timestamp = dateUtil.now() + (long) (speed * detailedBolusInfo.insulin * 1000); // clean carbs to prevent counting them as twice because they will picked up as another record // I don't think it's necessary to copy DetailedBolusInfo right now for carbs records double carbs = detailedBolusInfo.carbs; @@ -189,7 +189,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { EventOverviewBolusProgress.Treatment t = new EventOverviewBolusProgress.Treatment(0, 0, detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB); boolean connectionOK = false; if (detailedBolusInfo.insulin > 0 || carbs > 0) - connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, dateUtil._now() + T.mins(carbTime).msecs(), t); + connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, dateUtil.now() + T.mins(carbTime).msecs(), t); PumpEnactResult result = new PumpEnactResult(getInjector()); result.success(connectionOK && Math.abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.getBolusStep()) .bolusDelivered(t.insulin) @@ -260,7 +260,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { } } } - temporaryBasalStorage.add(new PumpSync.PumpState.TemporaryBasal(dateUtil._now(), T.mins(durationInMinutes).msecs(), percentRate, false, tbrType, 0L, 0L)); + temporaryBasalStorage.add(new PumpSync.PumpState.TemporaryBasal(dateUtil.now(), T.mins(durationInMinutes).msecs(), percentRate, false, tbrType, 0L, 0L)); // Convert duration from minutes to hours aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " minutes (doLowTemp || doHighTemp)"); if (percentRate == 0 && durationInMinutes > 30) { @@ -299,7 +299,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { aapsLogger.debug(LTag.PUMP, "setTempBasalPercent: Correct value already set"); return result; } - temporaryBasalStorage.add(new PumpSync.PumpState.TemporaryBasal(dateUtil._now(), T.mins(durationInMinutes).msecs(), percent, false, tbrType, 0L, 0L)); + temporaryBasalStorage.add(new PumpSync.PumpState.TemporaryBasal(dateUtil.now(), T.mins(durationInMinutes).msecs(), percent, false, tbrType, 0L, 0L)); boolean connectionOK; if (durationInMinutes == 15 || durationInMinutes == 30) { connectionOK = sExecutionService.tempBasalShortDuration(percent, durationInMinutes); diff --git a/danar/src/main/java/info/nightscout/androidaps/danaRv2/comm/MsgHistoryEvents_v2.kt b/danar/src/main/java/info/nightscout/androidaps/danaRv2/comm/MsgHistoryEvents_v2.kt index 073bea4fe1..0cd213a56a 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danaRv2/comm/MsgHistoryEvents_v2.kt +++ b/danar/src/main/java/info/nightscout/androidaps/danaRv2/comm/MsgHistoryEvents_v2.kt @@ -6,7 +6,6 @@ import info.nightscout.androidaps.danar.comm.MessageBase import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.common.defs.PumpType -import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.T import java.util.* @@ -22,7 +21,7 @@ class MsgHistoryEvents_v2 constructor( init { SetCommand(0xE003) - if (from > dateUtil._now()) { + if (from > dateUtil.now()) { aapsLogger.error("Asked to load from the future") from = 0 } diff --git a/danar/src/main/java/info/nightscout/androidaps/danaRv2/services/DanaRv2ExecutionService.java b/danar/src/main/java/info/nightscout/androidaps/danaRv2/services/DanaRv2ExecutionService.java index 426e3d876d..73532ab9b1 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danaRv2/services/DanaRv2ExecutionService.java +++ b/danar/src/main/java/info/nightscout/androidaps/danaRv2/services/DanaRv2ExecutionService.java @@ -203,7 +203,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { } else { waitForWholeMinute(); // Dana can set only whole minute // add 10sec to be sure we are over minute (will be cutted off anyway) - mSerialIOThread.sendMessage(new MsgSetTime(injector, dateUtil._now() + T.secs(10).msecs())); + mSerialIOThread.sendMessage(new MsgSetTime(injector, dateUtil.now() + T.secs(10).msecs())); mSerialIOThread.sendMessage(new MsgSettingPumpTime(injector)); timeDiff = (danaPump.getPumpTime() - System.currentTimeMillis()) / 1000L; aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java b/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java index 66448bee9c..e6136df269 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java +++ b/danar/src/main/java/info/nightscout/androidaps/danar/AbstractDanaRPlugin.java @@ -5,8 +5,6 @@ import androidx.annotation.NonNull; import org.json.JSONException; import org.json.JSONObject; -import java.util.Date; - import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.dana.DanaFragment; import info.nightscout.androidaps.dana.DanaPump; @@ -328,8 +326,8 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump if (!danaPump.isExtendedInProgress()) { result.success(true).enacted(true).isTempCancel(true); pumpSync.syncStopExtendedBolusWithPumpId( - dateUtil._now(), - dateUtil._now(), + dateUtil.now(), + dateUtil.now(), getPumpDescription().getPumpType(), serialNumber() ); @@ -421,7 +419,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump pumpJson.put("status", status); pumpJson.put("extended", extended); pumpJson.put("reservoir", (int) pump.getReservoirRemainingUnits()); - pumpJson.put("clock", dateUtil.toISOString(dateUtil._now())); + pumpJson.put("clock", dateUtil.toISOString(dateUtil.now())); } catch (JSONException e) { getAapsLogger().error("Unhandled exception", e); } diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/DanaRPlugin.java b/danar/src/main/java/info/nightscout/androidaps/danar/DanaRPlugin.java index a4b20df5bc..3cc4aa1154 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/DanaRPlugin.java +++ b/danar/src/main/java/info/nightscout/androidaps/danar/DanaRPlugin.java @@ -182,7 +182,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { detailedBolusInfo.timestamp, detailedBolusInfo.insulin, detailedBolusInfo.getBolusType(), - dateUtil._now(), + dateUtil.now(), PumpType.DANA_R, serialNumber()); if (detailedBolusInfo.carbs > 0) @@ -342,8 +342,8 @@ public class DanaRPlugin extends AbstractDanaRPlugin { sExecutionService.tempBasalStop(); if (!danaPump.isTempBasalInProgress()) { pumpSync.syncStopTemporaryBasalWithPumpId( - dateUtil._now(), - dateUtil._now(), + dateUtil.now(), + dateUtil.now(), getPumpDescription().getPumpType(), serialNumber() ); diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgStatusTempBasal.kt b/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgStatusTempBasal.kt index 69df6d4157..6196357bce 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgStatusTempBasal.kt +++ b/danar/src/main/java/info/nightscout/androidaps/danar/comm/MsgStatusTempBasal.kt @@ -4,7 +4,6 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.utils.T import kotlin.math.abs -import kotlin.math.ceil import kotlin.math.floor class MsgStatusTempBasal( @@ -49,7 +48,7 @@ class MsgStatusTempBasal( } private fun getDateFromSecAgo(tempBasalAgoSecs: Int): Long { - return (floor(dateUtil._now() / 1000.0) - tempBasalAgoSecs).toLong() * 1000 + return (floor(dateUtil.now() / 1000.0) - tempBasalAgoSecs).toLong() * 1000 } // because there is no fixed timestamp of start allow update of tbr only if tbr start differs more diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/services/AbstractDanaRExecutionService.java b/danar/src/main/java/info/nightscout/androidaps/danar/services/AbstractDanaRExecutionService.java index c16110d36b..2eac4030e9 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/services/AbstractDanaRExecutionService.java +++ b/danar/src/main/java/info/nightscout/androidaps/danar/services/AbstractDanaRExecutionService.java @@ -279,7 +279,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService { protected void waitForWholeMinute() { while (true) { - long time = dateUtil._now(); + long time = dateUtil.now(); long timeToWholeMinute = (60000 - time % 60000); if (timeToWholeMinute > 59800 || timeToWholeMinute < 3000) break; @@ -312,8 +312,8 @@ public abstract class AbstractDanaRExecutionService extends DaggerService { } } else { pumpSync.syncStopTemporaryBasalWithPumpId( - dateUtil._now(), - dateUtil._now(), + dateUtil.now(), + dateUtil.now(), activePlugin.getActivePump().model(), activePlugin.getActivePump().serialNumber() ); @@ -358,8 +358,8 @@ public abstract class AbstractDanaRExecutionService extends DaggerService { } } else { pumpSync.syncStopExtendedBolusWithPumpId( - dateUtil._now(), - dateUtil._now(), + dateUtil.now(), + dateUtil.now(), activePlugin.getActivePump().model(), activePlugin.getActivePump().serialNumber() ); diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/services/DanaRExecutionService.java b/danar/src/main/java/info/nightscout/androidaps/danar/services/DanaRExecutionService.java index a936cbf25b..bd12d27e2d 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/services/DanaRExecutionService.java +++ b/danar/src/main/java/info/nightscout/androidaps/danar/services/DanaRExecutionService.java @@ -61,7 +61,6 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.commands.Command; -import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; @@ -191,7 +190,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { long timeDiff = (danaPump.getPumpTime() - System.currentTimeMillis()) / 1000L; aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); if (Math.abs(timeDiff) > 10) { - mSerialIOThread.sendMessage(new MsgSetTime(injector, dateUtil._now())); + mSerialIOThread.sendMessage(new MsgSetTime(injector, dateUtil.now())); mSerialIOThread.sendMessage(new MsgSettingPumpTime(injector)); timeDiff = (danaPump.getPumpTime() - System.currentTimeMillis()) / 1000L; aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt b/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt index 3c34acda6a..0b9379bfa2 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/DanaRSPlugin.kt @@ -274,7 +274,7 @@ class DanaRSPlugin @Inject constructor( } // RS stores end time for bolus, we need to adjust time // default delivery speed is 12 sec/U - detailedBolusInfo.timestamp = dateUtil._now() + (speed * detailedBolusInfo.insulin * 1000).toLong() + detailedBolusInfo.timestamp = dateUtil.now() + (speed * detailedBolusInfo.insulin * 1000).toLong() // clean carbs to prevent counting them as twice because they will picked up as another record // I don't think it's necessary to copy DetailedBolusInfo right now for carbs records val carbs = detailedBolusInfo.carbs @@ -285,7 +285,7 @@ class DanaRSPlugin @Inject constructor( detailedBolusInfoStorage.add(detailedBolusInfo) // will be picked up on reading history val t = EventOverviewBolusProgress.Treatment(0.0, 0, detailedBolusInfo.bolusType == DetailedBolusInfo.BolusType.SMB) var connectionOK = false - if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = danaRSService?.bolus(detailedBolusInfo.insulin, carbs.toInt(), dateUtil._now() + T.mins(carbTime.toLong()).msecs(), t) + if (detailedBolusInfo.insulin > 0 || carbs > 0) connectionOK = danaRSService?.bolus(detailedBolusInfo.insulin, carbs.toInt(), dateUtil.now() + T.mins(carbTime.toLong()).msecs(), t) ?: false val result = PumpEnactResult(injector) result.success = connectionOK && abs(detailedBolusInfo.insulin - t.insulin) < pumpDescription.bolusStep @@ -368,7 +368,7 @@ class DanaRSPlugin @Inject constructor( } } } - temporaryBasalStorage.add(PumpSync.PumpState.TemporaryBasal(dateUtil._now(), mins(durationInMinutes.toLong()).msecs(), percentRate.toDouble(), false, tbrType, 0L, 0L)) + temporaryBasalStorage.add(PumpSync.PumpState.TemporaryBasal(dateUtil.now(), mins(durationInMinutes.toLong()).msecs(), percentRate.toDouble(), false, tbrType, 0L, 0L)) // Convert duration from minutes to hours aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Setting temp basal $percentRate% for $durationInMinutes minutes (doLowTemp || doHighTemp)") result = if (percentRate == 0 && durationInMinutes > 30) { @@ -415,7 +415,7 @@ class DanaRSPlugin @Inject constructor( aapsLogger.debug(LTag.PUMP, "setTempBasalPercent: Correct value already set") return result } - temporaryBasalStorage.add(PumpSync.PumpState.TemporaryBasal(dateUtil._now(), mins(durationInMinutes.toLong()).msecs(), percent.toDouble(), false, tbrType, 0L, 0L)) + temporaryBasalStorage.add(PumpSync.PumpState.TemporaryBasal(dateUtil.now(), mins(durationInMinutes.toLong()).msecs(), percent.toDouble(), false, tbrType, 0L, 0L)) val connectionOK: Boolean = if (durationInMinutes == 15 || durationInMinutes == 30) { danaRSService?.tempBasalShortDuration(percentAfterConstraint, durationInMinutes) ?: false diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt index 57419fa07a..5e6b49a66a 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRS_Packet_APS_History_Events.kt @@ -12,7 +12,6 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage import info.nightscout.androidaps.plugins.pump.common.defs.PumpType -import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -40,7 +39,7 @@ open class DanaRS_Packet_APS_History_Events( init { opCode = BleEncryption.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS - if (from > dateUtil._now()) { + if (from > dateUtil.now()) { aapsLogger.debug(LTag.PUMPCOMM, "Asked to load from the future") from = 0 } diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/services/BLEComm.kt b/danars/src/main/java/info/nightscout/androidaps/danars/services/BLEComm.kt index bf3c707c04..abd5cf6eb2 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/services/BLEComm.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/services/BLEComm.kt @@ -150,7 +150,7 @@ class BLEComm @Inject internal constructor( danaRSPlugin.changePump() } else if (lastClearRequest == 0L) { aapsLogger.error("Clearing pairing keys postponed") - sp.putLong(R.string.key_rs_last_clear_key_request, dateUtil._now()) + sp.putLong(R.string.key_rs_last_clear_key_request, dateUtil.now()) } } // cancel previous scheduled disconnection to prevent closing upcoming connection diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt b/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt index 85e1660443..f3b6f159d1 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/services/DanaRSService.kt @@ -171,17 +171,17 @@ class DanaRSService : DaggerService() { } else { when { danaPump.usingUTC -> { - sendMessage(DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone(injector, dateUtil._now(), offset)) + sendMessage(DanaRS_Packet_Option_Set_Pump_UTC_And_TimeZone(injector, dateUtil.now(), offset)) } danaPump.protocol >= 6 -> { // can set seconds - sendMessage(DanaRS_Packet_Option_Set_Pump_Time(injector, dateUtil._now())) + sendMessage(DanaRS_Packet_Option_Set_Pump_Time(injector, dateUtil.now())) } else -> { waitForWholeMinute() // Dana can set only whole minute // add 10sec to be sure we are over minute (will be cut off anyway) - sendMessage(DanaRS_Packet_Option_Set_Pump_Time(injector, dateUtil._now() + T.secs(10).msecs())) + sendMessage(DanaRS_Packet_Option_Set_Pump_Time(injector, dateUtil.now() + T.secs(10).msecs())) } } if (danaPump.usingUTC) sendMessage(DanaRS_Packet_Option_Get_Pump_UTC_And_TimeZone(injector)) @@ -255,7 +255,7 @@ class DanaRSService : DaggerService() { danaPump.bolusAmountToBeDelivered = insulin danaPump.bolusStopped = false danaPump.bolusStopForced = false - danaPump.bolusProgressLastTimeStamp = dateUtil._now() + danaPump.bolusProgressLastTimeStamp = dateUtil.now() val start = DanaRS_Packet_Bolus_Set_Step_Bolus_Start(injector, insulin, preferencesSpeed) if (carbs > 0) { // MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbTime, carbs); #### @@ -481,7 +481,7 @@ class DanaRSService : DaggerService() { private fun waitForWholeMinute() { while (true) { - val time = dateUtil._now() + val time = dateUtil.now() val timeToWholeMinute = 60000 - time % 60000 if (timeToWholeMinute > 59800 || timeToWholeMinute < 300) break rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.waitingfortimesynchronization, (timeToWholeMinute / 1000).toInt()))) diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsHistoryEventsTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsHistoryEventsTest.kt index 7b06b236fd..0ec370e381 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsHistoryEventsTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsHistoryEventsTest.kt @@ -10,7 +10,6 @@ import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.common.bolusInfo.TemporaryBasalStorage -import info.nightscout.androidaps.utils.DateUtil import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -48,7 +47,7 @@ class DanaRsPacketApsHistoryEventsTest : DanaRSTestBase() { } @Test fun runTest() { - val now = dateUtil._now() + val now = dateUtil.now() val testPacket = DanaRS_Packet_APS_History_Events(packetInjector, now) // test getRequestedParams diff --git a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsSetEventHistoryTest.kt b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsSetEventHistoryTest.kt index 81059da815..07809e9dc5 100644 --- a/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsSetEventHistoryTest.kt +++ b/danars/src/test/java/info/nightscout/androidaps/danars/comm/DanaRsPacketApsSetEventHistoryTest.kt @@ -3,7 +3,6 @@ package info.nightscout.androidaps.danars.comm import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.danars.DanaRSTestBase -import info.nightscout.androidaps.utils.DateUtil import org.junit.Assert import org.junit.Test import org.junit.runner.RunWith @@ -25,7 +24,7 @@ class DanaRsPacketApsSetEventHistoryTest : DanaRSTestBase() { } @Test fun runTest() { // test for negative carbs - val now = dateUtil._now() + val now = dateUtil.now() var historyTest = DanaRS_Packet_APS_Set_Event_History(packetInjector, info.nightscout.androidaps.dana.DanaPump.CARBS, now, -1, 0) var testParams = historyTest.requestParams Assert.assertEquals(0.toByte(), testParams[8]) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java index de86cdec0f..7023f8f06c 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.java @@ -12,8 +12,6 @@ import androidx.annotation.NonNull; import org.json.JSONException; import org.json.JSONObject; -import java.util.Date; - import dagger.android.HasAndroidInjector; import info.nightscout.androidaps.core.R; import info.nightscout.androidaps.data.DetailedBolusInfo; @@ -355,13 +353,13 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI extended.put("ExtendedBolusRemaining", getPlannedRemainingMinutes(eb)); } - status.put("timestamp", dateUtil.toISOString(dateUtil._now())); + status.put("timestamp", dateUtil.toISOString(dateUtil.now())); pump.put("battery", battery); pump.put("status", status); pump.put("extended", extended); pump.put("reservoir", getPumpStatusData().reservoirRemainingUnits); - pump.put("clock", dateUtil.toISOString(dateUtil._now())); + pump.put("clock", dateUtil.toISOString(dateUtil.now())); } catch (JSONException e) { aapsLogger.error("Unhandled exception", e); } diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java index 2276395491..cecd69564d 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/OmnipodErosPumpPlugin.java @@ -23,7 +23,6 @@ import org.joda.time.Duration; import org.json.JSONException; import org.json.JSONObject; -import java.util.Date; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -726,7 +725,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements PumpInterfa JSONObject extended = new JSONObject(); try { status.put("status", podStateManager.isPodRunning() ? (podStateManager.isSuspended() ? "suspended" : "normal") : "no active Pod"); - status.put("timestamp", dateUtil.toISOString(dateUtil._now())); + status.put("timestamp", dateUtil.toISOString(dateUtil.now())); battery.put("percent", getBatteryLevel()); @@ -749,7 +748,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements PumpInterfa extended.put("ExtendedBolusRemaining", getPlannedRemainingMinutes(eb)); } - status.put("timestamp", dateUtil.toISOString(dateUtil._now())); + status.put("timestamp", dateUtil.toISOString(dateUtil.now())); if (isUseRileyLinkBatteryLevel()) { pump.put("battery", battery);