diff --git a/.idea/dictionaries/project_dictionary.xml b/.idea/dictionaries/project_dictionary.xml index 3639be9c59..49af19275e 100644 --- a/.idea/dictionaries/project_dictionary.xml +++ b/.idea/dictionaries/project_dictionary.xml @@ -2,6 +2,7 @@ aaps + abcdef acked actionstring allowednumbers @@ -14,8 +15,10 @@ basals bgcheck bgsource + boluscalc bolusing carb + carbratio carbs carbsreq careportal @@ -46,6 +49,7 @@ medtronic mgdl mmol + motol multiwave netinsulin netratio @@ -55,9 +59,14 @@ okcancel omnipod openaps + openhumans oref + otpauth passcode + pdus + philoul poctech + pred profileswitch pumpbtcomm quickwizard @@ -66,14 +75,18 @@ refresheventsfromnightscout rileylink roboelectric + sgvs sitechange smscommunicator + sntp sooil soundid splitted + ssid superbolus targethigh targetlow + tbrs tdds tempbasal tempbasals @@ -82,9 +95,11 @@ tidepool timeshift tirs + totp uart wizzardpage xdrip + xstream ypso ypsomed ypsopump diff --git a/app/build.gradle b/app/build.gradle index e9bcae3e17..ba038fbfce 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,7 +109,7 @@ android { defaultConfig { multiDexEnabled true versionCode 1500 - version "2.8.2.2-dev" + version "2.8.2.3-dev" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"' diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.kt b/app/src/main/java/info/nightscout/androidaps/MainApp.kt index 8fb88a9963..f3a0f03ec4 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.kt @@ -32,6 +32,7 @@ import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver import info.nightscout.androidaps.utils.ActivityMonitor import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.locale.LocaleHelper.update +import info.nightscout.androidaps.utils.protection.PasswordCheck import info.nightscout.androidaps.utils.sharedPreferences.SP import io.reactivex.disposables.CompositeDisposable import io.reactivex.rxkotlin.plusAssign @@ -56,6 +57,7 @@ class MainApp : DaggerApplication() { @Inject lateinit var dateUtil: DateUtil @Inject lateinit var staticInjector: StaticInjector// TODO avoid , here fake only to initialize @Inject lateinit var uel: UserEntryLogger + @Inject lateinit var passwordCheck: PasswordCheck override fun onCreate() { super.onCreate() @@ -87,6 +89,7 @@ class MainApp : DaggerApplication() { keepAliveManager.setAlarm(this) doMigrations() uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps) + passwordCheck.passwordResetCheck(this) } private fun doMigrations() { diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ObjectivesModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ObjectivesModule.kt index d9524092dc..e64ef47302 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ObjectivesModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/ObjectivesModule.kt @@ -17,7 +17,6 @@ abstract class ObjectivesModule { @ContributesAndroidInjector abstract fun objective5Injector(): Objective5 @ContributesAndroidInjector abstract fun objective6Injector(): Objective6 @ContributesAndroidInjector abstract fun objective7Injector(): Objective7 - @ContributesAndroidInjector abstract fun objective8Injector(): Objective8 @ContributesAndroidInjector abstract fun objective9Injector(): Objective9 @ContributesAndroidInjector abstract fun objective10Injector(): Objective10 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 670d164503..224a89a888 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 @@ -54,9 +54,8 @@ class ObjectivesPlugin @Inject constructor( const val MAXIOB_ZERO_CL_OBJECTIVE = 5 @Suppress("unused") const val MAXIOB_OBJECTIVE = 6 const val AUTOSENS_OBJECTIVE = 7 - const val AMA_OBJECTIVE = 8 - const val SMB_OBJECTIVE = 9 - const val AUTO_OBJECTIVE = 10 + const val SMB_OBJECTIVE = 8 + const val AUTO_OBJECTIVE = 9 } public override fun onStart() { @@ -64,9 +63,8 @@ class ObjectivesPlugin @Inject constructor( setupObjectives() } - override fun specialEnableCondition(): Boolean { - return activePlugin.activePump.pumpDescription.isTempBasalCapable - } + override fun specialEnableCondition(): Boolean = + activePlugin.activePump.pumpDescription.isTempBasalCapable private fun setupObjectives() { objectives.clear() @@ -78,9 +76,9 @@ class ObjectivesPlugin @Inject constructor( objectives.add(Objective5(injector)) objectives.add(Objective6(injector)) objectives.add(Objective7(injector)) - objectives.add(Objective8(injector)) objectives.add(Objective9(injector)) objectives.add(Objective10(injector)) + // edit companion object if you remove/add Objective } fun reset() { @@ -116,8 +114,6 @@ class ObjectivesPlugin @Inject constructor( 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()) @@ -143,49 +139,43 @@ class ObjectivesPlugin @Inject constructor( */ override fun isLoopInvocationAllowed(value: Constraint): Constraint { if (!objectives[FIRST_OBJECTIVE].isStarted) - value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), FIRST_OBJECTIVE + 1), this) + value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, FIRST_OBJECTIVE + 1), this) return value } override fun isLgsAllowed(value: Constraint): Constraint { if (!objectives[MAXBASAL_OBJECTIVE].isStarted) - value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), MAXBASAL_OBJECTIVE + 1), this) + value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, MAXBASAL_OBJECTIVE + 1), this) return value } override fun isClosedLoopAllowed(value: Constraint): Constraint { if (!objectives[MAXIOB_ZERO_CL_OBJECTIVE].isStarted) - value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), MAXIOB_ZERO_CL_OBJECTIVE + 1), this) + value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, MAXIOB_ZERO_CL_OBJECTIVE + 1), this) return value } override fun isAutosensModeEnabled(value: Constraint): Constraint { if (!objectives[AUTOSENS_OBJECTIVE].isStarted) - value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), AUTOSENS_OBJECTIVE + 1), this) - return value - } - - override fun isAMAModeEnabled(value: Constraint): Constraint { - if (!objectives[AMA_OBJECTIVE].isStarted) - value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), AMA_OBJECTIVE + 1), this) + value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, AUTOSENS_OBJECTIVE + 1), this) return value } override fun isSMBModeEnabled(value: Constraint): Constraint { if (!objectives[SMB_OBJECTIVE].isStarted) - value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), SMB_OBJECTIVE + 1), this) + value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, SMB_OBJECTIVE + 1), this) return value } override fun applyMaxIOBConstraints(maxIob: Constraint): Constraint { if (objectives[MAXIOB_ZERO_CL_OBJECTIVE].isStarted && !objectives[MAXIOB_ZERO_CL_OBJECTIVE].isAccomplished) - maxIob.set(aapsLogger, 0.0, String.format(resourceHelper.gs(R.string.objectivenotfinished), MAXIOB_ZERO_CL_OBJECTIVE + 1), this) + maxIob.set(aapsLogger, 0.0, resourceHelper.gs(R.string.objectivenotfinished, MAXIOB_ZERO_CL_OBJECTIVE + 1), this) return maxIob } override fun isAutomationEnabled(value: Constraint): Constraint { if (!objectives[AUTO_OBJECTIVE].isStarted) - value.set(aapsLogger, false, String.format(resourceHelper.gs(R.string.objectivenotstarted), AUTO_OBJECTIVE + 1), this) + value.set(aapsLogger, false, resourceHelper.gs(R.string.objectivenotstarted, AUTO_OBJECTIVE + 1), this) return value } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective8.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective8.kt deleted file mode 100644 index 27b2f8b4d2..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/objectives/Objective8.kt +++ /dev/null @@ -1,12 +0,0 @@ -package info.nightscout.androidaps.plugins.constraints.objectives.objectives - -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.R -import info.nightscout.androidaps.utils.T - -class Objective8(injector: HasAndroidInjector) : Objective(injector, "ama", R.string.objectives_ama_objective, 0) { - - init { - tasks.add(MinimumDurationTask(this, T.days(28).msecs())) - } -} \ No newline at end of file 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 ada8f9eab0..3688f1a55f 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 @@ -156,7 +156,7 @@ class ActionsFragment : DaggerFragment() { pbLevelLabel = view.findViewById(R.id.pb_level_label) profileSwitch?.setOnClickListener { - ProfileSwitchDialog().show(childFragmentManager, "Actions") + ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog") } tempTarget?.setOnClickListener { TempTargetDialog().show(childFragmentManager, "Actions") diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/acks/NSAddAck.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/acks/NSAddAck.kt index 930defad05..78bded1d0d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/acks/NSAddAck.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/acks/NSAddAck.kt @@ -16,8 +16,8 @@ class NSAddAck( ) : Event(), Ack { var id: String? = null - @JvmField var nsClientID: String? = null - @JvmField var json: JSONObject? = null + var nsClientID: String? = null + var json: JSONObject? = null override fun call(vararg args: Any) { // Regular response try { 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 e000c9ff44..9da0246b70 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 @@ -377,7 +377,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } R.id.temp_target -> v.performClick() - R.id.active_profile -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "Overview") }) } + R.id.active_profile -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog") }) } } return false @@ -680,14 +680,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList activity?.let { OKDialog.show(it, resourceHelper.gs(R.string.iob), overviewData.iobDialogText) } } // cob - var cobText: String = resourceHelper.gs(R.string.value_unavailable_short) - overviewData.cobInfo?.let { cobInfo -> - if (cobInfo.displayCob != null) { - cobText = resourceHelper.gs(R.string.format_carbs, cobInfo.displayCob!!.toInt()) - if (cobInfo.futureCarbs > 0) cobText += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")" - } - } - binding.infoLayout.cob.text = cobText + var cobText = overviewData.cobInfo?.displayText(resourceHelper, dateUtil, buildHelper.isDev()) ?: resourceHelper.gs(R.string.value_unavailable_short) val constraintsProcessed = loopPlugin.lastRun?.constraintsProcessed val lastRun = loopPlugin.lastRun @@ -695,7 +688,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList if (constraintsProcessed.carbsReq > 0) { //only display carbsreq when carbs have not been entered recently if (overviewData.lastCarbsTime < lastRun.lastAPSRun) { - cobText = cobText + " | " + constraintsProcessed.carbsReq + " " + resourceHelper.gs(R.string.required) + cobText += " | " + constraintsProcessed.carbsReq + " " + resourceHelper.gs(R.string.required) } if (carbAnimation?.isRunning == false) carbAnimation?.start() @@ -704,6 +697,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList carbAnimation?.selectDrawable(0) } } + binding.infoLayout.cob.text = cobText } OverviewData.Property.TEMPORARY_TARGET -> { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt index 97fbb823a1..003dc89440 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewPlugin.kt @@ -23,7 +23,6 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventBucke import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.utils.Translator import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -45,8 +44,6 @@ class OverviewPlugin @Inject constructor( resourceHelper: ResourceHelper, private val config: Config, private val dateUtil: DateUtil, - private val translator: Translator, -// private val profiler: Profiler, private val profileFunction: ProfileFunction, private val iobCobCalculator: IobCobCalculator, private val repository: AppRepository, @@ -234,7 +231,6 @@ class OverviewPlugin @Inject constructor( overviewBus.send(EventUpdateOverview(from, OverviewData.Property.TIME)) overviewBus.send(EventUpdateOverview(from, OverviewData.Property.TEMPORARY_BASAL)) overviewBus.send(EventUpdateOverview(from, OverviewData.Property.EXTENDED_BOLUS)) - overviewBus.send(EventUpdateOverview(from, OverviewData.Property.IOB_COB)) overviewBus.send(EventUpdateOverview(from, OverviewData.Property.TEMPORARY_TARGET)) overviewBus.send(EventUpdateOverview(from, OverviewData.Property.SENSITIVITY)) loadAsData(from) @@ -244,6 +240,7 @@ class OverviewPlugin @Inject constructor( overviewData.prepareTreatmentsData(from) overviewData.prepareIobAutosensData(from) overviewBus.send(EventUpdateOverview(from, OverviewData.Property.GRAPH)) + overviewBus.send(EventUpdateOverview(from, OverviewData.Property.IOB_COB)) aapsLogger.debug(LTag.UI, "refreshLoop finished") runningRefresh = false } @@ -305,7 +302,7 @@ class OverviewPlugin @Inject constructor( private fun loadIobCobResults(from: String) { overviewData.bolusIob = iobCobCalculator.calculateIobFromBolus().round() overviewData.basalIob = iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended().round() - overviewData.cobInfo = iobCobCalculator.getCobInfo(false, "Overview COB") + overviewData.cobInfo = iobCobCalculator.getCobInfo(true, "Overview COB") val lastCarbs = repository.getLastCarbsRecordWrapped().blockingGet() overviewData.lastCarbsTime = if (lastCarbs is ValueWrapper.Existing) lastCarbs.value.timestamp else 0L diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt index 917ff84630..2fd42278d5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt @@ -74,7 +74,7 @@ class StatusLightHandler @Inject constructor( private fun handleAge(view: TextView?, type: TherapyEvent.Type, @StringRes warnSettings: Int, defaultWarnThreshold: Double, @StringRes urgentSettings: Int, defaultUrgentThreshold: Double) { val warn = sp.getDouble(warnSettings, defaultWarnThreshold) val urgent = sp.getDouble(urgentSettings, defaultUrgentThreshold) - val therapyEvent = repository.getLastTherapyRecord(type).blockingGet() + val therapyEvent = repository.getLastTherapyRecordUpToNow(type).blockingGet() if (therapyEvent is ValueWrapper.Existing) { warnColors.setColorByAge(view, therapyEvent.value, warn, urgent) view?.text = therapyEvent.value.age(resourceHelper.shortTextMode(), resourceHelper, dateUtil) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java index d18d9e96bb..1e5c4364e6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java @@ -29,12 +29,9 @@ import java.util.stream.Collectors; import javax.inject.Inject; import dagger.android.AndroidInjection; -import info.nightscout.androidaps.interfaces.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.IobTotal; -import info.nightscout.androidaps.interfaces.GlucoseUnit; -import info.nightscout.androidaps.interfaces.Profile; import info.nightscout.androidaps.database.AppRepository; import info.nightscout.androidaps.database.entities.Bolus; import info.nightscout.androidaps.database.entities.GlucoseValue; @@ -42,8 +39,11 @@ import info.nightscout.androidaps.database.entities.TemporaryBasal; import info.nightscout.androidaps.extensions.GlucoseValueExtensionKt; import info.nightscout.androidaps.extensions.TemporaryBasalExtensionKt; import info.nightscout.androidaps.interfaces.ActivePlugin; +import info.nightscout.androidaps.interfaces.Config; +import info.nightscout.androidaps.interfaces.GlucoseUnit; import info.nightscout.androidaps.interfaces.IobCobCalculator; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.interfaces.Profile; import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; @@ -59,7 +59,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProv import info.nightscout.androidaps.receivers.ReceiverStatusStore; import info.nightscout.androidaps.utils.DecimalFormatter; import info.nightscout.androidaps.utils.DefaultValueHelper; -import info.nightscout.androidaps.utils.ToastUtils; +import info.nightscout.androidaps.utils.TrendCalculator; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; @@ -79,6 +79,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog @Inject public AppRepository repository; @Inject ReceiverStatusStore receiverStatusStore; @Inject Config config; + @Inject public TrendCalculator trendCalculator; public static final String ACTION_RESEND = WatchUpdaterService.class.getName().concat(".Resend"); public static final String ACTION_OPEN_SETTINGS = WatchUpdaterService.class.getName().concat(".OpenSettings"); @@ -322,7 +323,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog dataMap.putString("delta", "--"); dataMap.putString("avgDelta", "--"); } else { - dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.getDelta())); + dataMap.putString("slopeArrow", trendCalculator.getTrendArrow(lastBG).getSymbol()); dataMap.putString("delta", deltastring(glucoseStatus.getDelta(), glucoseStatus.getDelta() * Constants.MGDL_TO_MMOLL, units)); dataMap.putString("avgDelta", deltastring(glucoseStatus.getShortAvgDelta(), glucoseStatus.getShortAvgDelta() * Constants.MGDL_TO_MMOLL, units)); } @@ -358,25 +359,6 @@ public class WatchUpdaterService extends WearableListenerService implements Goog return deltastring; } - private String slopeArrow(double delta) { - if (delta <= (-3.5 * 5)) { - return "\u21ca"; - } else if (delta <= (-2 * 5)) { - return "\u2193"; - } else if (delta <= (-1 * 5)) { - return "\u2198"; - } else if (delta <= (1 * 5)) { - return "\u2192"; - } else if (delta <= (2 * 5)) { - return "\u2197"; - } else if (delta <= (3.5 * 5)) { - return "\u2191"; - } else { - return "\u21c8"; - } - } - - private void resendData() { if (googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) { googleApiConnect(); @@ -391,16 +373,10 @@ public class WatchUpdaterService extends WearableListenerService implements Goog if (!graph_bgs.isEmpty()) { DataMap entries = dataMapSingleBG(last_bg, glucoseStatus); - if (entries == null) { - ToastUtils.showToastInUiThread(this, resourceHelper.gs(R.string.noprofile)); - return; - } final ArrayList dataMaps = new ArrayList<>(graph_bgs.size()); for (GlucoseValue bg : graph_bgs) { DataMap dataMap = dataMapSingleBG(bg, glucoseStatus); - if (dataMap != null) { - dataMaps.add(dataMap); - } + dataMaps.add(dataMap); } entries.putDataMapArrayList("entries", dataMaps); (new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, entries); @@ -505,7 +481,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog tb2 = iobCobCalculator.getTempBasalIncludingConvertedExtended(now); //use "now" to express current situation if (tb2 == null) { //express the cancelled temp by painting it down one minute early - temps.add(tempDatamap(tb_start, tb_before, now - 1 * 60 * 1000, endBasalValue, tb_amount)); + temps.add(tempDatamap(tb_start, tb_before, now - 60 * 1000, endBasalValue, tb_amount)); } else { //express currently running temp by painting it a bit into the future Profile profileNow = profileFunction.getProfile(now); @@ -523,7 +499,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog //onset at the end Profile profileTB = profileFunction.getProfile(runningTime); double currentAmount = TemporaryBasalExtensionKt.convertedToAbsolute(tb2, runningTime, profileTB); - temps.add(tempDatamap(now - 1 * 60 * 1000, endBasalValue, runningTime + 5 * 60 * 1000, currentAmount, currentAmount)); + temps.add(tempDatamap(now - 60 * 1000, endBasalValue, runningTime + 5 * 60 * 1000, currentAmount, currentAmount)); } } 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 bd1817db2b..4cad7c1f92 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 @@ -270,18 +270,19 @@ class IobCobCalculatorPlugin @Inject constructor( var displayCob: Double? = null var futureCarbs = 0.0 val now = dateUtil.now() - val carbs = repository.getCarbsDataFromTimeExpanded(now, true).blockingGet() + var timestamp = now + val carbs = repository.getCarbsDataFromTimeExpanded(autosensData?.time ?: now, true).blockingGet() if (autosensData != null) { displayCob = autosensData.cob carbs.forEach { carb -> - if (ads.roundUpTime(carb.timestamp) > ads.roundUpTime(autosensData.time) && carb.timestamp <= now) { + if (carb.timestamp > autosensData.time && carb.timestamp <= now) displayCob += carb.amount - } } + timestamp = autosensData.time } // Future carbs carbs.forEach { carb -> if (carb.timestamp > now) futureCarbs += carb.amount } - return CobInfo(displayCob, futureCarbs) + return CobInfo(timestamp, displayCob, futureCarbs) } override fun getMealDataWithWaitingForCalculationFinish(): MealData { @@ -579,7 +580,7 @@ class IobCobCalculatorPlugin @Inject constructor( return total } - open fun getCalculationToTimeTempBasals(toTime: Long, lastAutosensResult: AutosensResult, exercise_mode: Boolean, half_basal_exercise_target: Int, isTempTarget: Boolean): IobTotal { + 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() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index 1d2eb8f84e..989ef9dbdb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -72,7 +72,7 @@ class LocalProfileFragment : DaggerFragment() { } private fun sumLabel(): String { - val profile = localProfilePlugin.profile?.getDefaultProfile() + val profile = localProfilePlugin.getEditProfile() val sum = profile?.let { ProfileSealed.Pure(profile).baseBasalSum() } ?: 0.0 return " ∑" + DecimalFormatter.to2Decimal(sum) + resourceHelper.gs(R.string.insulin_unit_shortname) } @@ -212,7 +212,7 @@ class LocalProfileFragment : DaggerFragment() { binding.profileswitch.setOnClickListener { ProfileSwitchDialog() .also { it.arguments = Bundle().also { bundle -> bundle.putInt("profileIndex", localProfilePlugin.currentProfileIndex) } } - .show(childFragmentManager, "NewNSTreatmentDialog") + .show(childFragmentManager, "ProfileSwitchDialog") } binding.reset.setOnClickListener { @@ -259,7 +259,7 @@ class LocalProfileFragment : DaggerFragment() { updateGUI() } - fun updateGUI() { + private fun updateGUI() { if (_binding == null) return val isValid = localProfilePlugin.isValidEditState() val isEdited = localProfilePlugin.isEdited 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 8b74f760cc..5929d53b77 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 @@ -12,6 +12,7 @@ import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.PureProfile import info.nightscout.androidaps.events.EventProfileStoreChanged import info.nightscout.androidaps.extensions.blockFromJsonArray +import info.nightscout.androidaps.extensions.pureProfileFromJson import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag @@ -21,6 +22,7 @@ import info.nightscout.androidaps.receivers.DataWorker import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.HardLimits +import info.nightscout.androidaps.utils.JsonHelper import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -97,7 +99,7 @@ class LocalProfilePlugin @Inject constructor( var numOfProfiles = 0 internal var currentProfileIndex = 0 - fun currentProfile(): SingleProfile? = if (numOfProfiles > 0) profiles[currentProfileIndex] else null + fun currentProfile(): SingleProfile? = if (numOfProfiles > 0 && currentProfileIndex < numOfProfiles) profiles[currentProfileIndex] else null @Synchronized fun isValidEditState(): Boolean { @@ -123,6 +125,23 @@ class LocalProfilePlugin @Inject constructor( return true } + @Synchronized + fun getEditProfile(): PureProfile? { + val profile = JSONObject() + with(profiles[currentProfileIndex]) { + profile.put("dia", dia) + profile.put("carbratio", ic) + profile.put("sens", isf) + profile.put("basal", basal) + profile.put("target_low", targetLow) + profile.put("target_high", targetHigh) + profile.put("units", if (mgdl) Constants.MGDL else Constants.MMOL) + profile.put("timezone", TimeZone.getDefault().id) + } + val defaultUnits = JsonHelper.safeGetStringAllowNull(profile, "units", null) + return pureProfileFromJson(profile, dateUtil, defaultUnits) + } + @Synchronized fun storeSettings(activity: FragmentActivity? = null) { for (i in 0 until numOfProfiles) { 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 2c014279ef..951a9db839 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 @@ -109,5 +109,6 @@ class VirtualPumpFragment : DaggerFragment() { binding.type.text = pumpType?.description binding.typeDef.text = pumpType?.getFullDescription(resourceHelper.gs(R.string.virtualpump_pump_def), pumpType.hasExtendedBasals(), resourceHelper) + binding.serialNumber.text = virtualPumpPlugin.serialNumber() } } diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt index 8d640afc75..8b526b97bd 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt @@ -267,7 +267,7 @@ class SWDefinition @Inject constructor( .label(R.string.profileswitch_ismissing)) .add(SWButton(injector) .text(R.string.doprofileswitch) - .action { ProfileSwitchDialog().show(activity.supportFragmentManager, "SetupWizard") }) + .action { ProfileSwitchDialog().show(activity.supportFragmentManager, "ProfileSwitchDialog") }) .validator { profileFunction.getProfile() != null } .visibility { profileFunction.getProfile() == null } private val screenPump = SWScreen(injector, R.string.configbuilder_pump) diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt index a1a0a76c5a..71e0703cb0 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt @@ -127,7 +127,7 @@ class SetupWizardActivity : NoSplashAppCompatActivity() { override fun updateButtons() { runOnUiThread { val currentScreen = screens[currentWizardPage] - if (currentScreen.validator == null || currentScreen.validator!!.isValid || currentScreen.skippable) { + if (currentScreen.validator == null || currentScreen.validator?.isValid == true || currentScreen.skippable) { if (currentWizardPage == nextPage(null)) { findViewById(R.id.finish_button).visibility = View.VISIBLE findViewById(R.id.next_button).visibility = View.GONE @@ -184,7 +184,7 @@ class SetupWizardActivity : NoSplashAppCompatActivity() { private fun nextPage(view: View?): Int { var page = currentWizardPage + 1 while (page < screens.size) { - if (screens[page].visibility == null || screens[page].visibility!!.isValid) return page + if (screens[page].visibility == null || screens[page].visibility?.isValid == true) return page page++ } return min(currentWizardPage, screens.size - 1) @@ -194,7 +194,7 @@ class SetupWizardActivity : NoSplashAppCompatActivity() { private fun previousPage(view: View?): Int { var page = currentWizardPage - 1 while (page >= 0) { - if (screens[page].visibility == null || screens[page].visibility!!.isValid) return page + if (screens[page].visibility == null || screens[page].visibility?.isValid == true) return page page-- } return max(currentWizardPage, 0) diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditEncryptedPassword.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditEncryptedPassword.kt index d32a0f4770..60886e0efc 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditEncryptedPassword.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWEditEncryptedPassword.kt @@ -5,11 +5,13 @@ import android.text.Editable import android.text.InputType import android.text.TextWatcher import android.view.View +import android.widget.Button import android.widget.EditText import android.widget.LinearLayout import android.widget.TextView import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R +import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.setupwizard.SWTextValidator import info.nightscout.androidaps.utils.CryptoUtil @@ -17,36 +19,71 @@ class SWEditEncryptedPassword(injector: HasAndroidInjector, private val cryptoUt private var validator: SWTextValidator = SWTextValidator(String::isNotEmpty) private var updateDelay = 0L + private var button: Button? = null + private var editText: EditText? = null + private var editText2: EditText? = null + private var l: TextView? = null + private var c: TextView? = null + private var c2: TextView? = null override fun generateDialog(layout: LinearLayout) { val context = layout.context - val l = TextView(context) - l.id = View.generateViewId() - label?.let { l.setText(it) } - l.setTypeface(l.typeface, Typeface.BOLD) - layout.addView(l) - val c = TextView(context) - c.id = View.generateViewId() - comment?.let { c.setText(it) } - c.setTypeface(c.typeface, Typeface.ITALIC) - layout.addView(c) - val editText = EditText(context) - editText.id = View.generateViewId() - editText.inputType = InputType.TYPE_CLASS_TEXT - editText.maxLines = 1 - editText.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD + val isPasswordSet = sp.contains(R.string.key_master_password) && sp.getString(R.string.key_master_password, "") != "" + + button = Button(context) + button?.setText(R.string.unlock_settings) + button?.setOnClickListener { + scanForActivity(context)?.let { activity -> + passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { + button?.visibility = View.GONE + editText?.visibility = View.VISIBLE + editText2?.visibility = View.VISIBLE + l?.visibility = View.VISIBLE + c?.visibility = View.VISIBLE + c2?.visibility = View.VISIBLE + }) + } + } + button?.visibility = isPasswordSet.toVisibility() + layout.addView(button) + + label?.let { + l = TextView(context) + l?.id = View.generateViewId() + l?.setText(it) + l?.setTypeface(l?.typeface, Typeface.BOLD) + layout.addView(l) + } + + comment?.let { + c = TextView(context) + c?.id = View.generateViewId() + c?.setText(it) + c?.setTypeface(c?.typeface, Typeface.ITALIC) + c?.visibility = isPasswordSet.not().toVisibility() + layout.addView(c) + } + + editText = EditText(context) + editText?.id = View.generateViewId() + editText?.inputType = InputType.TYPE_CLASS_TEXT + editText?.maxLines = 1 + editText?.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD + editText?.visibility = isPasswordSet.not().toVisibility() layout.addView(editText) - val c2 = TextView(context) - c2.id = View.generateViewId() - c2.setText(R.string.confirm) + c2 = TextView(context) + c2?.id = View.generateViewId() + c2?.setText(R.string.confirm) + c2?.visibility = isPasswordSet.not().toVisibility() layout.addView(c2) - val editText2 = EditText(context) - editText2.id = View.generateViewId() - editText2.inputType = InputType.TYPE_CLASS_TEXT - editText2.maxLines = 1 - editText2.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD + editText2 = EditText(context) + editText2?.id = View.generateViewId() + editText2?.inputType = InputType.TYPE_CLASS_TEXT + editText2?.maxLines = 1 + editText2?.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD + editText2?.visibility = isPasswordSet.not().toVisibility() layout.addView(editText2) super.generateDialog(layout) @@ -55,14 +92,14 @@ class SWEditEncryptedPassword(injector: HasAndroidInjector, private val cryptoUt override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { sp.remove(preferenceId) scheduleChange(updateDelay) - if (validator.isValid(editText.text.toString()) && validator.isValid(editText2.text.toString()) && editText.text.toString() == editText2.text.toString()) + if (validator.isValid(editText?.text.toString()) && validator.isValid(editText2?.text.toString()) && editText?.text.toString() == editText2?.text.toString()) save(s.toString(), updateDelay) } override fun afterTextChanged(s: Editable) {} } - editText.addTextChangedListener(watcher) - editText2.addTextChangedListener(watcher) + editText?.addTextChangedListener(watcher) + editText2?.addTextChangedListener(watcher) } fun preferenceId(preferenceId: Int): SWEditEncryptedPassword { diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.kt index 2a25c2ea91..a23619d2ef 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/elements/SWItem.kt @@ -1,14 +1,18 @@ package info.nightscout.androidaps.setupwizard.elements +import android.content.Context +import android.content.ContextWrapper import android.view.View import android.widget.LinearLayout import androidx.annotation.StringRes +import androidx.appcompat.app.AppCompatActivity import dagger.android.HasAndroidInjector import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.setupwizard.events.EventSWUpdate +import info.nightscout.androidaps.utils.protection.PasswordCheck import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP import java.util.concurrent.Executors @@ -22,6 +26,7 @@ open class SWItem(val injector: HasAndroidInjector, var type: Type) { @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var sp: SP + @Inject lateinit var passwordCheck: PasswordCheck private val eventWorker = Executors.newSingleThreadScheduledExecutor() private var scheduledEventPost: ScheduledFuture<*>? = null @@ -33,6 +38,7 @@ open class SWItem(val injector: HasAndroidInjector, var type: Type) { @Suppress("unused") enum class Type { + NONE, TEXT, HTML_LINK, BREAK, LISTENER, URL, STRING, NUMBER, DECIMAL_NUMBER, RADIOBUTTON, PLUGIN, BUTTON, FRAGMENT, UNIT_NUMBER, PREFERENCE } @@ -79,4 +85,13 @@ open class SWItem(val injector: HasAndroidInjector, var type: Type) { val task: Runnable = PostRunnable() scheduledEventPost = eventWorker.schedule(task, updateDelay, TimeUnit.SECONDS) } + + fun scanForActivity(cont: Context?): AppCompatActivity? { + return when (cont) { + null -> null + is AppCompatActivity -> cont + is ContextWrapper -> scanForActivity(cont.baseContext) + else -> null + } + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt index cce8d1b195..29de9c8266 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 @@ -133,7 +133,6 @@ class BolusWizard @Inject constructor( private var carbTime: Int = 0 private var quickWizard: Boolean = true - @JvmOverloads fun doCalc(profile: Profile, profileName: String, tempTarget: TemporaryTarget?, 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 9e9ae6a87a..c1784ca4ff 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 @@ -84,11 +84,9 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec bg = lastBG.valueToUnits(profileFunction.getUnits()) } // COB - var cob = 0.0 - if (useCOB() == YES) { - val cobInfo = iobCobCalculator.getCobInfo(_synchronized, "QuickWizard COB") - if (cobInfo.displayCob != null) cob = cobInfo.displayCob!! - } + val cob = + if (useCOB() == YES) iobCobCalculator.getCobInfo(_synchronized, "QuickWizard COB").displayCob ?: 0.0 + else 0.0 // Bolus IOB var bolusIOB = false if (useBolusIOB() == YES) { @@ -121,7 +119,7 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec trend = true } val percentage = sp.getInt(R.string.key_boluswizard_percentage, 100) - return BolusWizard(injector).doCalc(profile, profileName, tempTarget, carbs(), cob, bg, 0.0, percentage, true, useCOB() == YES, bolusIOB, basalIOB, superBolus, useTempTarget() == YES, trend, false, buttonText(), quickWizard = true) //tbc, ok if only quickwizard, but if other sources elsewhere use Sources.QuickWiard + return BolusWizard(injector).doCalc(profile, profileName, tempTarget, carbs(), cob, bg, 0.0, percentage, true, useCOB() == YES, bolusIOB, basalIOB, superBolus, useTempTarget() == YES, trend, false, buttonText(), quickWizard = true) //tbc, ok if only quickwizard, but if other sources elsewhere use Sources.QuickWizard } fun buttonText(): String = safeGetString(storage, "buttonText", "") diff --git a/app/src/main/res/layout/virtualpump_fragment.xml b/app/src/main/res/layout/virtualpump_fragment.xml index 9ec99fad5d..4129d2e050 100644 --- a/app/src/main/res/layout/virtualpump_fragment.xml +++ b/app/src/main/res/layout/virtualpump_fragment.xml @@ -234,6 +234,51 @@ + + + + + + + + + + + + + - + Run for a few days, and at least one night with no low BG alarms, before dropping BG Adjust basals and ratios if needed, and then enable auto-sens 1 week successful daytime looping with regular carb entry - Enabling additional features for daytime use, such as advanced meal assist Enabling additional features for daytime use, such as SMB Enabling automation You must read the wiki and rise maxIOB to get SMBs working fine! A good start is maxIOB=average mealbolus + 3 x max daily basal diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt index 3235a110c0..874175a2be 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt @@ -198,16 +198,6 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { Assert.assertEquals(java.lang.Boolean.FALSE, c.value()) } - // Objectives - @Test - fun isAMAModeEnabledTest() { - objectivesPlugin.objectives[ObjectivesPlugin.AMA_OBJECTIVE].startedOn = 0 - val c = constraintChecker.isAMAModeEnabled() - Assert.assertEquals(true, c.reasonList.size == 1) // Objectives - Assert.assertEquals(true, c.mostLimitedReasonList.size == 1) // Objectives - Assert.assertEquals(java.lang.Boolean.FALSE, c.value()) - } - // Safety @Test fun isAdvancedFilteringEnabledTest() { 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 270753e9a4..c08f4c9033 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 @@ -74,14 +74,6 @@ class ObjectivesPluginTest : TestBase() { Assert.assertEquals(false, c.value()) } - @Test fun notStartedObjective9ShouldLimitAMAMode() { - objectivesPlugin.objectives[ObjectivesPlugin.AMA_OBJECTIVE].startedOn = 0 - var c = Constraint(true) - c = objectivesPlugin.isAMAModeEnabled(c) - Assert.assertEquals(true, c.getReasons(aapsLogger).contains("Objective 9 not started")) - Assert.assertEquals(false, c.value()) - } - @Test fun notStartedObjective10ShouldLimitSMBMode() { objectivesPlugin.objectives[ObjectivesPlugin.SMB_OBJECTIVE].startedOn = 0 var c = Constraint(true) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index fe2197fc1f..a2c6d32a08 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 @@ -98,7 +98,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { val bgList: MutableList = ArrayList() bgList.add(reading) - `when`(iobCobCalculator.getCobInfo(false, "SMS COB")).thenReturn(CobInfo(10.0, 2.0)) + `when`(iobCobCalculator.getCobInfo(false, "SMS COB")).thenReturn(CobInfo(0, 10.0, 2.0)) `when`(iobCobCalculator.ads).thenReturn(autosensDataStore) `when`(autosensDataStore.lastBg()).thenReturn(reading) 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 f0e8bffd89..b02dfb0dd3 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 @@ -72,7 +72,6 @@ class AutomationEvent(private val injector: HasAndroidInjector) { readOnly = d.optBoolean("readOnly", false) autoRemove = d.optBoolean("autoRemove", false) trigger = TriggerDummy(injector).instantiate(JSONObject(d.getString("trigger"))) - ?: TriggerConnector(injector) val array = d.getJSONArray("actions") actions.clear() for (i in 0 until array.length()) { diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt index a410ca3902..a20bff3c2a 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.kt @@ -43,6 +43,7 @@ abstract class Trigger(val injector: HasAndroidInjector) { @Inject lateinit var dateUtil: DateUtil init { + @Suppress("LeakingThis") injector.androidInjector().inject(this) } @@ -55,16 +56,12 @@ abstract class Trigger(val injector: HasAndroidInjector) { abstract fun icon(): Optional abstract fun duplicate(): Trigger - companion object { - - @JvmStatic - fun scanForActivity(cont: Context?): AppCompatActivity? { - return when (cont) { - null -> null - is AppCompatActivity -> cont - is ContextWrapper -> scanForActivity(cont.baseContext) - else -> null - } + private fun scanForActivity(cont: Context?): AppCompatActivity? { + return when (cont) { + null -> null + is AppCompatActivity -> cont + is ContextWrapper -> scanForActivity(cont.baseContext) + else -> null } } @@ -80,26 +77,34 @@ abstract class Trigger(val injector: HasAndroidInjector) { .put("data", dataJSON()) .toString() - fun instantiate(obj: JSONObject): Trigger? { + fun instantiate(obj: JSONObject): Trigger { val type = obj.getString("type") val data = obj.getJSONObject("data") //val clazz = Class.forName(type).kotlin //return (clazz.primaryConstructor?.call(injector) as Trigger).fromJSON(data?.toString() ?: "") return when (type) { TriggerAutosensValue::class.java.name, // backward compatibility - TriggerAutosensValue::class.java.simpleName -> TriggerAutosensValue(injector).fromJSON(data.toString()) + TriggerAutosensValue::class.java.simpleName -> TriggerAutosensValue(injector).fromJSON( + data.toString() + ) TriggerBg::class.java.name, TriggerBg::class.java.simpleName -> TriggerBg(injector).fromJSON(data.toString()) TriggerBolusAgo::class.java.name, - TriggerBolusAgo::class.java.simpleName -> TriggerBolusAgo(injector).fromJSON(data.toString()) + TriggerBolusAgo::class.java.simpleName -> TriggerBolusAgo(injector).fromJSON( + data.toString() + ) TriggerBTDevice::class.java.name, - TriggerBTDevice::class.java.simpleName -> TriggerBTDevice(injector).fromJSON(data.toString()) + TriggerBTDevice::class.java.simpleName -> TriggerBTDevice(injector).fromJSON( + data.toString() + ) TriggerIob::class.java.name, TriggerIob::class.java.simpleName -> TriggerIob(injector).fromJSON(data.toString()) TriggerCOB::class.java.name, TriggerCOB::class.java.simpleName -> TriggerCOB(injector).fromJSON(data.toString()) TriggerConnector::class.java.name, - TriggerConnector::class.java.simpleName -> TriggerConnector(injector).fromJSON(data.toString()) + TriggerConnector::class.java.simpleName -> TriggerConnector(injector).fromJSON( + data.toString() + ) TriggerDelta::class.java.name, TriggerDelta::class.java.simpleName -> TriggerDelta(injector).fromJSON(data.toString()) TriggerDummy::class.java.name, @@ -107,21 +112,35 @@ abstract class Trigger(val injector: HasAndroidInjector) { TriggerIob::class.java.name, TriggerIob::class.java.simpleName -> TriggerIob(injector).fromJSON(data.toString()) TriggerLocation::class.java.name, - TriggerLocation::class.java.simpleName -> TriggerLocation(injector).fromJSON(data.toString()) + TriggerLocation::class.java.simpleName -> TriggerLocation(injector).fromJSON( + data.toString() + ) TriggerProfilePercent::class.java.name, - TriggerProfilePercent::class.java.simpleName -> TriggerProfilePercent(injector).fromJSON(data.toString()) + TriggerProfilePercent::class.java.simpleName -> TriggerProfilePercent(injector).fromJSON( + data.toString() + ) TriggerPumpLastConnection::class.java.name, - TriggerPumpLastConnection::class.java.simpleName -> TriggerPumpLastConnection(injector).fromJSON(data.toString()) + TriggerPumpLastConnection::class.java.simpleName -> TriggerPumpLastConnection(injector).fromJSON( + data.toString() + ) TriggerRecurringTime::class.java.name, - TriggerRecurringTime::class.java.simpleName -> TriggerRecurringTime(injector).fromJSON(data.toString()) + TriggerRecurringTime::class.java.simpleName -> TriggerRecurringTime(injector).fromJSON( + data.toString() + ) TriggerTempTarget::class.java.name, - TriggerTempTarget::class.java.simpleName -> TriggerTempTarget(injector).fromJSON(data.toString()) + TriggerTempTarget::class.java.simpleName -> TriggerTempTarget(injector).fromJSON( + data.toString() + ) TriggerTime::class.java.name, TriggerTime::class.java.simpleName -> TriggerTime(injector).fromJSON(data.toString()) TriggerTimeRange::class.java.name, - TriggerTimeRange::class.java.simpleName -> TriggerTimeRange(injector).fromJSON(data.toString()) + TriggerTimeRange::class.java.simpleName -> TriggerTimeRange(injector).fromJSON( + data.toString() + ) TriggerWifiSsid::class.java.name, - TriggerWifiSsid::class.java.simpleName -> TriggerWifiSsid(injector).fromJSON(data.toString()) + TriggerWifiSsid::class.java.simpleName -> TriggerWifiSsid(injector).fromJSON( + data.toString() + ) else -> throw ClassNotFoundException(type) } } diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt index 105f91fe3b..91311a84da 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt @@ -95,7 +95,7 @@ class TriggerConnector(injector: HasAndroidInjector) : Trigger(injector) { val array = d.getJSONArray("triggerList") list.clear() for (i in 0 until array.length()) { - instantiate(JSONObject(array.getString(i)))?.let { + instantiate(JSONObject(array.getString(i))).let { list.add(it) } } 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 d67fb0a109..d125ee5655 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 @@ -28,7 +28,7 @@ class TriggerCOBTest : TriggerTestBase() { @Test fun shouldRunTest() { // COB value is 6 - PowerMockito.`when`(iobCobCalculator.getCobInfo(false, "AutomationTriggerCOB")).thenReturn(CobInfo(6.0, 2.0)) + PowerMockito.`when`(iobCobCalculator.getCobInfo(false, "AutomationTriggerCOB")).thenReturn(CobInfo(0, 6.0, 2.0)) var t: TriggerCOB = TriggerCOB(injector).setValue(1.0).comparator(Comparator.Compare.IS_EQUAL) Assert.assertFalse(t.shouldRun()) t = TriggerCOB(injector).setValue(6.0).comparator(Comparator.Compare.IS_EQUAL) @@ -72,6 +72,6 @@ class TriggerCOBTest : TriggerTestBase() { } fun generateCobInfo(): CobInfo { - return CobInfo(6.0, 0.0) + return CobInfo(0, 6.0, 0.0) } } \ No newline at end of file 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 a42bcaafde..b50e85a5bc 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 @@ -768,7 +768,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints { pumpSync.syncTemporaryBasalWithPumpId( state.timestamp, state.tbrPercent, - T.mins(state.tbrRemainingDuration).msecs(), + T.Companion.mins(state.tbrRemainingDuration).msecs(), false, tbrType, // There are no IDs for TBRs on the pump and none is calculated (in contrast to boluses). @@ -974,7 +974,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints { pumpSync.syncTemporaryBasalWithPumpId( now, 0.0, - T.mins(15).msecs(), + T.Companion.mins(15).msecs(), false, PumpSync.TemporaryBasalType.PUMP_SUSPEND, // Combo doesn't have nor uses IDs for TBRs, see note in #setTempBasalPercent @@ -1107,7 +1107,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints { pumpSync.syncTemporaryBasalWithPumpId( now, state.tbrPercent, - T.mins(state.tbrRemainingDuration).msecs(), + T.Companion.mins(state.tbrRemainingDuration).msecs(), false, PumpSync.TemporaryBasalType.NORMAL, tbrId, @@ -1140,7 +1140,7 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints { pumpSync.syncTemporaryBasalWithPumpId( now, state.tbrPercent, - T.mins(state.tbrRemainingDuration).msecs(), + T.Companion.mins(state.tbrRemainingDuration).msecs(), false, PumpSync.TemporaryBasalType.NORMAL, tbrId, diff --git a/core/src/main/java/info/nightscout/androidaps/Constants.java b/core/src/main/java/info/nightscout/androidaps/Constants.java index f8748d2639..e8388b6178 100644 --- a/core/src/main/java/info/nightscout/androidaps/Constants.java +++ b/core/src/main/java/info/nightscout/androidaps/Constants.java @@ -23,9 +23,6 @@ public class Constants { public static final Integer notificationID = 556677; - public static final int hoursToKeepInDatabase = 72; - public static final int daysToKeepHistoryInDatabase = 30; - // SMS COMMUNICATOR public static final long remoteBolusMinDistance = 15 * 60 * 1000L; @@ -72,7 +69,7 @@ public class Constants { public static final int MIN_WATCHDOG_INTERVAL_IN_SECONDS = 12 * 60; //SMS Communicator - public static final long SMS_CONFIRM_TIMEOUT = T.mins(5L).msecs(); + public static final long SMS_CONFIRM_TIMEOUT = T.Companion.mins(5L).msecs(); //Storage [MB] public static final long MINIMUM_FREE_SPACE = 200; @@ -106,7 +103,7 @@ public class Constants { /** * How many old TOTP tokens still accept. - * Each token is 30s valid, but copying and SMS transmision of it can take additional seconds, + * Each token is 30s valid, but copying and SMS transmission of it can take additional seconds, * so we add leeway to still accept given amount of older tokens */ public static final int OTP_ACCEPT_OLD_TOKENS_COUNT = 1; diff --git a/core/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.kt b/core/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.kt index 3316f00ece..07be899e6d 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.kt +++ b/core/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.kt @@ -20,8 +20,8 @@ class DetailedBolusInfo { // Additional requesting parameters @JvmField var timestamp = System.currentTimeMillis() - @JvmField var lastKnownBolusTime: Long = 0 // for SMB check - @JvmField var deliverAtTheLatest: Long = 0 // SMB should be delivered within 1 min from this time + var lastKnownBolusTime: Long = 0 // for SMB check + var deliverAtTheLatest: Long = 0 // SMB should be delivered within 1 min from this time @Transient var context: Context? = null // context for progress dialog // Prefilled info for storing to db diff --git a/core/src/main/java/info/nightscout/androidaps/data/InMemoryGlucoseValue.kt b/core/src/main/java/info/nightscout/androidaps/data/InMemoryGlucoseValue.kt index 5c80f6767c..00a89d48db 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/InMemoryGlucoseValue.kt +++ b/core/src/main/java/info/nightscout/androidaps/data/InMemoryGlucoseValue.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.data import info.nightscout.androidaps.database.entities.GlucoseValue -class InMemoryGlucoseValue @JvmOverloads constructor(var timestamp: Long = 0L, var value: Double = 0.0, var interpolated: Boolean = false) { +class InMemoryGlucoseValue constructor(var timestamp: Long = 0L, var value: Double = 0.0, var interpolated: Boolean = false) { constructor(gv: GlucoseValue) : this(gv.timestamp, gv.value) // var generated : value doesn't correspond to real value with timestamp close to real BG diff --git a/core/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt b/core/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt index 5ab17221c5..9d9e323930 100644 --- a/core/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt +++ b/core/src/main/java/info/nightscout/androidaps/dialogs/BolusProgressDialog.kt @@ -40,11 +40,7 @@ class BolusProgressDialog : DaggerDialogFragment() { private val disposable = CompositeDisposable() companion object { - - @JvmField var bolusEnded = false - - @JvmField var stopPressed = false } diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/Constraints.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/Constraints.kt index 95a901f626..709b4c037b 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/Constraints.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/Constraints.kt @@ -17,7 +17,6 @@ interface Constraints { fun isClosedLoopAllowed(value: Constraint): Constraint = value fun isLgsAllowed(value: Constraint): Constraint = value fun isAutosensModeEnabled(value: Constraint): Constraint = value - fun isAMAModeEnabled(value: Constraint): Constraint = value fun isSMBModeEnabled(value: Constraint): Constraint = value fun isUAMEnabled(value: Constraint): Constraint = value fun isAdvancedFilteringEnabled(value: Constraint): Constraint = value diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt index 99476dff8f..718956c90b 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt @@ -24,9 +24,6 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug fun isAutosensModeEnabled(): Constraint = isAutosensModeEnabled(Constraint(true)) - fun isAMAModeEnabled(): Constraint = - isAMAModeEnabled(Constraint(true)) - fun isSMBModeEnabled(): Constraint = isSMBModeEnabled(Constraint(true)) @@ -100,16 +97,6 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug return value } - override fun isAMAModeEnabled(value: Constraint): Constraint { - val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) - for (p in constraintsPlugins) { - val constrain = p as Constraints - if (!p.isEnabled(PluginType.CONSTRAINTS)) continue - constrain.isAMAModeEnabled(value) - } - return value - } - override fun isSMBModeEnabled(value: Constraint): Constraint { val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(Constraints::class.java) for (p in constraintsPlugins) { diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/CobInfo.kt b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/CobInfo.kt index 2676fde7b6..59d9bc1111 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/CobInfo.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/CobInfo.kt @@ -1,9 +1,12 @@ package info.nightscout.androidaps.plugins.iob.iobCobCalculator +import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DecimalFormatter +import info.nightscout.androidaps.utils.resources.ResourceHelper /** All COB up to now, including carbs not yet processed by IobCob calculation. */ -class CobInfo(val displayCob: Double?, val futureCarbs: Double) { +class CobInfo(val timestamp: Long, val displayCob: Double?, val futureCarbs: Double) { fun generateCOBString(): String { var cobStringResult = "--g" @@ -15,4 +18,13 @@ class CobInfo(val displayCob: Double?, val futureCarbs: Double) { } return cobStringResult } -} \ No newline at end of file + + fun displayText(resourceHelper: ResourceHelper, dateUtil: DateUtil, isDev: Boolean): String? = + if (displayCob != null) { + var cobText = resourceHelper.gs(R.string.format_carbs, displayCob.toInt()) + if (futureCarbs > 0) cobText += "(" + DecimalFormatter.to0Decimal(futureCarbs) + ")" + // This is only temporary for debugging + if (isDev) cobText += "\n" + dateUtil.timeStringWithSeconds(timestamp) + cobText + } else null +} 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 6d7f79d3f6..6f0a2f6655 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt @@ -58,10 +58,9 @@ class DateUtil @Inject constructor(private val context: Context) { * @param tz - tz to set to, if not specified uses local timezone * @return the iso-formatted date string */ - @JvmOverloads - fun toISOString(date: Long, format: String = FORMAT_DATE_ISO_OUT, tz: TimeZone = TimeZone.getTimeZone("UTC")): String { - val f: DateFormat = SimpleDateFormat(format, Locale.getDefault()) - f.timeZone = tz + fun toISOString(date: Long): String { + val f: DateFormat = SimpleDateFormat(FORMAT_DATE_ISO_OUT, Locale.getDefault()) + f.timeZone = TimeZone.getTimeZone("UTC") return f.format(date) } @@ -119,7 +118,7 @@ class DateUtil @Inject constructor(private val context: Context) { return DateTime(mills).toString(DateTimeFormat.forPattern(format)) } - private fun timeStringWithSeconds(mills: Long): String { + fun timeStringWithSeconds(mills: Long): String { var format = "hh:mm:ssa" if (android.text.format.DateFormat.is24HourFormat(context)) { format = "HH:mm:ss" diff --git a/core/src/main/java/info/nightscout/androidaps/utils/JsonHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/JsonHelper.kt index a7c78fa0bb..d592a180b7 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/JsonHelper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/JsonHelper.kt @@ -27,7 +27,6 @@ object JsonHelper { return result } - @JvmStatic fun safeGetString(json: JSONObject?, fieldName: String): String? { var result: String? = null if (json != null && json.has(fieldName)) { @@ -39,7 +38,6 @@ object JsonHelper { return result } - @JvmStatic fun safeGetString(json: JSONObject?, fieldName: String, defaultValue: String): String { var result = defaultValue if (json != null && json.has(fieldName)) { @@ -51,7 +49,6 @@ object JsonHelper { return result } - @JvmStatic fun safeGetStringAllowNull(json: JSONObject?, fieldName: String, defaultValue: String?): String? { var result = defaultValue if (json != null && json.has(fieldName)) { @@ -63,7 +60,6 @@ object JsonHelper { return result } - @JvmStatic fun safeGetDouble(json: JSONObject?, fieldName: String): Double { var result = 0.0 if (json != null && json.has(fieldName)) { @@ -97,7 +93,6 @@ object JsonHelper { return result } - @JvmStatic fun safeGetInt(json: JSONObject?, fieldName: String): Int = safeGetInt(json, fieldName, 0) @@ -123,7 +118,6 @@ object JsonHelper { return result } - @JvmStatic fun safeGetLong(json: JSONObject?, fieldName: String): Long { var result: Long = 0 if (json != null && json.has(fieldName)) { @@ -146,8 +140,6 @@ object JsonHelper { return result } - @JvmStatic - @JvmOverloads fun safeGetBoolean(json: JSONObject?, fieldName: String, defaultValue: Boolean = false): Boolean { var result = defaultValue if (json != null && json.has(fieldName)) { diff --git a/core/src/main/java/info/nightscout/androidaps/utils/T.kt b/core/src/main/java/info/nightscout/androidaps/utils/T.kt index 29915386f1..6a0f540b28 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/T.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/T.kt @@ -14,12 +14,12 @@ class T(val time: Long = 0L) { companion object { - @JvmStatic fun now(): T = T(System.currentTimeMillis()) - @JvmStatic fun msecs(msec: Long): T = T(msec) - @JvmStatic fun secs(sec: Long): T = T(sec * 1000L) - @JvmStatic fun mins(min: Long): T = T(min * 60 * 1000L) - @JvmStatic fun hours(hour: Long): T = T(hour * 60 * 60 * 1000L) - @JvmStatic fun days(day: Long): T = T(day * 24 * 60 * 60 * 1000L) - @JvmStatic fun months(month: Long): T = T(month * 31 * 24 * 60 * 60 * 1000L) + fun now(): T = T(System.currentTimeMillis()) + fun msecs(msec: Long): T = T(msec) + fun secs(sec: Long): T = T(sec * 1000L) + fun mins(min: Long): T = T(min * 60 * 1000L) + fun hours(hour: Long): T = T(hour * 60 * 60 * 1000L) + fun days(day: Long): T = T(day * 24 * 60 * 60 * 1000L) + fun months(month: Long): T = T(month * 31 * 24 * 60 * 60 * 1000L) } } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/utils/alertDialogs/OKDialog.kt b/core/src/main/java/info/nightscout/androidaps/utils/alertDialogs/OKDialog.kt index 76e64ebaf3..4182538781 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/alertDialogs/OKDialog.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/alertDialogs/OKDialog.kt @@ -55,12 +55,10 @@ object OKDialog { .setCanceledOnTouchOutside(false) } - @JvmStatic fun showConfirmation(activity: FragmentActivity, message: String, ok: Runnable?) { showConfirmation(activity, activity.getString(R.string.confirmation), message, ok, null) } - @JvmStatic fun showConfirmation(activity: FragmentActivity, message: Spanned, ok: Runnable?) { showConfirmation(activity, activity.getString(R.string.confirmation), message, ok, null) } @@ -153,15 +151,11 @@ object OKDialog { .setCanceledOnTouchOutside(false) } - @JvmStatic - @JvmOverloads fun showConfirmation(context: Context, message: String, ok: Runnable?, cancel: Runnable? = null) { showConfirmation(context, context.getString(R.string.confirmation), message, ok, cancel) } @SuppressLint("InflateParams") - @JvmStatic - @JvmOverloads fun showConfirmation(context: Context, title: String, message: String, ok: Runnable?, cancel: Runnable? = null) { var okClicked = false AlertDialogHelper.Builder(context) @@ -190,8 +184,6 @@ object OKDialog { } @SuppressLint("InflateParams") - @JvmStatic - @JvmOverloads fun showConfirmation(context: Context, title: String, message: String, ok: DialogInterface.OnClickListener?, cancel: DialogInterface.OnClickListener? = null) { var okClicked = false AlertDialogHelper.Builder(context) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/protection/PasswordCheck.kt b/core/src/main/java/info/nightscout/androidaps/utils/protection/PasswordCheck.kt index 6e36c3a659..83090741e0 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/protection/PasswordCheck.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/protection/PasswordCheck.kt @@ -8,10 +8,13 @@ import android.widget.EditText import android.widget.TextView import androidx.annotation.StringRes import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.interfaces.ActivePlugin +import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider import info.nightscout.androidaps.utils.CryptoUtil import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.alertDialogs.AlertDialogHelper import info.nightscout.androidaps.utils.sharedPreferences.SP +import java.io.File import javax.inject.Inject import javax.inject.Singleton @@ -20,8 +23,10 @@ const val AUTOFILL_HINT_NEW_PASSWORD = "newPassword" @Singleton class PasswordCheck @Inject constructor( - val sp: SP, - private val cryptoUtil: CryptoUtil + private val sp: SP, + private val cryptoUtil: CryptoUtil, + private val fileListProvider: PrefFileListProvider, + private val activePlugin: ActivePlugin ) { /** @@ -159,4 +164,18 @@ class PasswordCheck @Inject constructor( alertDialogBuilder.create().show() } + + /** + * Check for existing PasswordReset file and + * reset password to SN of active pump if file exists + */ + fun passwordResetCheck(context: Context) { + val passwordReset = File(fileListProvider.ensureExtraDirExists(), "PasswordReset") + if (passwordReset.exists()) { + val sn = activePlugin.activePump.serialNumber() + sp.putString(R.string.key_master_password, cryptoUtil.hashPassword(sn)) + passwordReset.delete() + ToastUtils.okToast(context, context.getString(R.string.password_set)) + } + } } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/protection/ProtectionCheck.kt b/core/src/main/java/info/nightscout/androidaps/utils/protection/ProtectionCheck.kt index ca0a3402a6..9bc9a18fe4 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/protection/ProtectionCheck.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/protection/ProtectionCheck.kt @@ -49,7 +49,6 @@ class ProtectionCheck @Inject constructor( } } - @JvmOverloads fun queryProtection(activity: FragmentActivity, protection: Protection, ok: Runnable?, cancel: Runnable? = null, fail: Runnable? = null) { when (ProtectionType.values()[sp.getInt(protectionTypeResourceIDs[protection.ordinal], ProtectionType.NONE.ordinal)]) { diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 2b813deedc..51db838cbe 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -144,7 +144,6 @@ Extended bolus Pump time updated Exit - Serial number Remove record Loop is disabled Alarm 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 b3417e0080..2295373d35 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.Companion.secs(10).msecs())); mSerialIOThread.sendMessage(new MsgSettingPumpTime(injector)); timeDiff = (danaPump.getPumpTime() - System.currentTimeMillis()) / 1000L; aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); @@ -258,7 +258,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { public boolean bolus(double amount, int carbs, long carbTimeStamp, final EventOverviewBolusProgress.Treatment t) { if (!isConnected()) return false; - if (BolusProgressDialog.stopPressed) return false; + if (BolusProgressDialog.Companion.getStopPressed()) return false; danaPump.setBolusingTreatment(t); danaPump.setBolusDone(false); 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 578eb28537..22f9c9a069 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danaRv2/DanaRv2Plugin.java +++ b/danar/src/main/java/info/nightscout/androidaps/danaRv2/DanaRv2Plugin.java @@ -181,7 +181,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { double carbs = detailedBolusInfo.carbs; detailedBolusInfo.carbs = 0; long carbTimeStamp = detailedBolusInfo.getCarbsTimestamp() != null ? detailedBolusInfo.getCarbsTimestamp() : detailedBolusInfo.timestamp; - if (carbTimeStamp == detailedBolusInfo.timestamp) carbTimeStamp -= T.mins(1).msecs(); // better set 1 min back to prevents clash with insulin + if (carbTimeStamp == detailedBolusInfo.timestamp) carbTimeStamp -= T.Companion.mins(1).msecs(); // better set 1 min back to prevents clash with insulin detailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history @@ -259,7 +259,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.Companion.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) { @@ -298,7 +298,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.Companion.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/services/DanaRv2ExecutionService.java b/danar/src/main/java/info/nightscout/androidaps/danaRv2/services/DanaRv2ExecutionService.java index 1d93f7b70f..c393bdef2a 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.Companion.secs(10).msecs())); mSerialIOThread.sendMessage(new MsgSettingPumpTime(injector)); timeDiff = (danaPump.getPumpTime() - System.currentTimeMillis()) / 1000L; aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); @@ -327,7 +327,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { public boolean bolus(final double amount, int carbs, long carbtime, final EventOverviewBolusProgress.Treatment t) { if (!isConnected()) return false; - if (BolusProgressDialog.stopPressed) return false; + if (BolusProgressDialog.Companion.getStopPressed()) return false; rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.startingbolus))); danaPump.setBolusingTreatment(t); @@ -346,7 +346,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { mSerialIOThread.sendMessage(msg); MsgSetHistoryEntry_v2 msgSetHistoryEntry_v2 = new MsgSetHistoryEntry_v2(injector, DanaPump.CARBS, carbtime, carbs, 0); mSerialIOThread.sendMessage(msgSetHistoryEntry_v2); - danaPump.lastHistoryFetched = Math.min(danaPump.lastHistoryFetched, carbtime - T.mins(1).msecs()); + danaPump.lastHistoryFetched = Math.min(danaPump.lastHistoryFetched, carbtime - T.Companion.mins(1).msecs()); } final long bolusStart = System.currentTimeMillis(); @@ -415,7 +415,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { mSerialIOThread.sendMessage(msg); MsgSetHistoryEntry_v2 msgSetHistoryEntry_v2 = new MsgSetHistoryEntry_v2(injector, DanaPump.CARBS, time, amount, 0); mSerialIOThread.sendMessage(msgSetHistoryEntry_v2); - danaPump.lastHistoryFetched = Math.min(danaPump.lastHistoryFetched, time - T.mins(1).msecs()); + danaPump.lastHistoryFetched = Math.min(danaPump.lastHistoryFetched, time - T.Companion.mins(1).msecs()); return true; } @@ -439,7 +439,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { } SystemClock.sleep(200); if (danaRv2Plugin.lastEventTimeLoaded != 0) - danaPump.lastHistoryFetched = danaRv2Plugin.lastEventTimeLoaded - T.mins(1).msecs(); + danaPump.lastHistoryFetched = danaRv2Plugin.lastEventTimeLoaded - T.Companion.mins(1).msecs(); else danaPump.lastHistoryFetched = 0; danaPump.setLastConnection(System.currentTimeMillis()); 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 3bff7e49e9..0f4eb0f0e8 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 @@ -264,7 +264,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { public boolean bolus(double amount, int carbs, long carbTimeStamp, final EventOverviewBolusProgress.Treatment t) { if (!isConnected()) return false; - if (BolusProgressDialog.stopPressed) return false; + if (BolusProgressDialog.Companion.getStopPressed()) return false; danaPump.setBolusingTreatment(t); danaPump.setBolusDone(false); diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBasal.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBasal.kt index 7c8a521b88..9f66e8d346 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBasal.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryBasal.kt @@ -4,7 +4,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRSPacketHistoryBasal @JvmOverloads constructor( +class DanaRSPacketHistoryBasal constructor( injector: HasAndroidInjector, from: Long = 0 ) : DanaRSPacketHistory(injector, from) { diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryPrime.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryPrime.kt index b87611ee9b..eab2c923c5 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryPrime.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistoryPrime.kt @@ -4,7 +4,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.danars.encryption.BleEncryption -class DanaRSPacketHistoryPrime @JvmOverloads constructor( +class DanaRSPacketHistoryPrime constructor( injector: HasAndroidInjector, from: Long = 0 ) : DanaRSPacketHistory(injector, from) { diff --git a/database/src/main/java/info/nightscout/androidaps/database/AppRepository.kt b/database/src/main/java/info/nightscout/androidaps/database/AppRepository.kt index bdfaf474b1..458eff722e 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/AppRepository.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/AppRepository.kt @@ -342,8 +342,8 @@ open class AppRepository @Inject internal constructor( fun deleteAllTherapyEventsEntries() = database.therapyEventDao.deleteAllEntries() - fun getLastTherapyRecord(type: TherapyEvent.Type): Single> = - database.therapyEventDao.getLastTherapyRecord(type).toWrappedSingle() + fun getLastTherapyRecordUpToNow(type: TherapyEvent.Type): Single> = + database.therapyEventDao.getLastTherapyRecord(type, System.currentTimeMillis()).toWrappedSingle() .subscribeOn(Schedulers.io()) fun getTherapyEventByTimestamp(type: TherapyEvent.Type, timestamp: Long): TherapyEvent? = diff --git a/database/src/main/java/info/nightscout/androidaps/database/daos/TherapyEventDao.kt b/database/src/main/java/info/nightscout/androidaps/database/daos/TherapyEventDao.kt index cc42b5b922..5e541b6800 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/daos/TherapyEventDao.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/daos/TherapyEventDao.kt @@ -39,8 +39,8 @@ internal interface TherapyEventDao : TraceableDao { @Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE timestamp >= :timestamp AND referenceId IS NULL ORDER BY timestamp ASC") fun getTherapyEventDataIncludingInvalidFromTime(timestamp: Long): Single> - @Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE type = :type AND isValid = 1 ORDER BY id DESC LIMIT 1") - fun getLastTherapyRecord(type: TherapyEvent.Type): Maybe + @Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE type = :type AND isValid = 1 AND timestamp <= :now ORDER BY id DESC LIMIT 1") + fun getLastTherapyRecord(type: TherapyEvent.Type, now: Long): Maybe @Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE timestamp >= :timestamp AND isValid = 1 AND referenceId IS NULL ORDER BY timestamp ASC") fun compatGetTherapyEventDataFromTime(timestamp: Long): Single> diff --git a/database/src/main/java/info/nightscout/androidaps/database/entities/GlucoseValue.kt b/database/src/main/java/info/nightscout/androidaps/database/entities/GlucoseValue.kt index d7140a7900..d101681a7b 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/entities/GlucoseValue.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/entities/GlucoseValue.kt @@ -1,25 +1,31 @@ package info.nightscout.androidaps.database.entities -import com.google.gson.annotations.SerializedName -import androidx.room.* +import androidx.room.Embedded +import androidx.room.Entity +import androidx.room.ForeignKey +import androidx.room.Index +import androidx.room.PrimaryKey import info.nightscout.androidaps.database.TABLE_GLUCOSE_VALUES import info.nightscout.androidaps.database.embedments.InterfaceIDs import info.nightscout.androidaps.database.interfaces.DBEntryWithTime import info.nightscout.androidaps.database.interfaces.TraceableDBEntry -import java.util.TimeZone +import java.util.* -@Entity(tableName = TABLE_GLUCOSE_VALUES, +@Entity( + tableName = TABLE_GLUCOSE_VALUES, foreignKeys = [ForeignKey( entity = GlucoseValue::class, parentColumns = ["id"], - childColumns = ["referenceId"])], + childColumns = ["referenceId"] + )], indices = [ Index("id"), Index("nightscoutId"), Index("sourceSensor"), Index("referenceId"), Index("timestamp") - ]) + ] +) data class GlucoseValue( @PrimaryKey(autoGenerate = true) override var id: Long = 0, @@ -51,53 +57,55 @@ data class GlucoseValue( fun isRecordDeleted(other: GlucoseValue): Boolean = isValid && !other.isValid - enum class TrendArrow (val text:String, val symbol:String){ - @SerializedName("NONE") NONE("NONE", "??"), - @SerializedName("TripleUp")TRIPLE_UP("TripleUp", "X"), - @SerializedName("DoubleUp")DOUBLE_UP("DoubleUp", "\u21c8"), - @SerializedName("SingleUp")SINGLE_UP("SingleUp", "\u2191"), - @SerializedName("FortyFiveUp")FORTY_FIVE_UP("FortyFiveUp", "\u2197"), - @SerializedName("Flat")FLAT("Flat", "\u2192"), - @SerializedName("FortyFiveDown")FORTY_FIVE_DOWN("FortyFiveDown", "\u2198"), - @SerializedName("SingleDown")SINGLE_DOWN("SingleDown", "\u2193"), - @SerializedName("DoubleDown")DOUBLE_DOWN("DoubleDown", "\u21ca"), - @SerializedName("TripleDown")TRIPLE_DOWN("TripleDown", "X") + enum class TrendArrow(val text: String, val symbol: String) { + NONE("NONE", "??"), + TRIPLE_UP("TripleUp", "X"), + DOUBLE_UP("DoubleUp", "\u21c8"), + SINGLE_UP("SingleUp", "\u2191"), + FORTY_FIVE_UP("FortyFiveUp", "\u2197"), + FLAT("Flat", "\u2192"), + FORTY_FIVE_DOWN("FortyFiveDown", "\u2198"), + SINGLE_DOWN("SingleDown", "\u2193"), + DOUBLE_DOWN("DoubleDown", "\u21ca"), + TRIPLE_DOWN("TripleDown", "X") ; companion object { - fun fromString(direction : String?) = values().firstOrNull {it.text == direction} ?: NONE + + fun fromString(direction: String?) = + values().firstOrNull { it.text == direction } ?: NONE } } - enum class SourceSensor(val text : String) { - @SerializedName("AndroidAPS-Dexcom") DEXCOM_NATIVE_UNKNOWN("AndroidAPS-Dexcom"), - @SerializedName("AndroidAPS-DexcomG6") DEXCOM_G6_NATIVE("AndroidAPS-DexcomG6"), - @SerializedName("AndroidAPS-DexcomG5") DEXCOM_G5_NATIVE("AndroidAPS-DexcomG5"), - @SerializedName("Bluetooth Wixel") DEXCOM_G4_WIXEL("Bluetooth Wixel"), - @SerializedName("xBridge Wixel") DEXCOM_G4_XBRIDGE("xBridge Wixel"), - @SerializedName("G4 Share Receiver") DEXCOM_G4_NATIVE("G4 Share Receiver"), - @SerializedName("Medtrum A6") MEDTRUM_A6("Medtrum A6"), - @SerializedName("Network G4") DEXCOM_G4_NET("Network G4"), - @SerializedName("Network G4 and xBridge") DEXCOM_G4_NET_XBRIDGE("Network G4 and xBridge"), - @SerializedName("Network G4 and Classic xDrip") DEXCOM_G4_NET_CLASSIC("Network G4 and Classic xDrip"), - @SerializedName("DexcomG5") DEXCOM_G5_XDRIP("DexcomG5"), - @SerializedName("G6 Native") DEXCOM_G6_NATIVE_XDRIP("G6 Native"), - @SerializedName("G5 Native") DEXCOM_G5_NATIVE_XDRIP("G5 Native"), - @SerializedName("G6 Native / G5 Native") DEXCOM_G6_G5_NATIVE_XDRIP("G6 Native / G5 Native"), - @SerializedName("Network libre") LIBRE_1_NET("Network libre"), - @SerializedName("BlueReader") LIBRE_1_BLUE("BlueReader"), - @SerializedName("Transmiter PL") LIBRE_1_PL("Transmiter PL"), - @SerializedName("Blucon") LIBRE_1_BLUCON("Blucon"), - @SerializedName("Tomato") LIBRE_1_TOMATO("Tomato"), - @SerializedName("Rfduino") LIBRE_1_RF("Rfduino"), - @SerializedName("LimiTTer") LIBRE_1_LIMITTER("LimiTTer"), - @SerializedName("Glimp") GLIMP("Glimp"), - @SerializedName("Libre2") LIBRE_2_NATIVE("Libre2"), - @SerializedName("Poctech") POCTECH_NATIVE("Poctech"), - @SerializedName("MM600Series") MM_600_SERIES("MM600Series"), - @SerializedName("Eversense") EVERSENSE("Eversense"), - @SerializedName("Random") RANDOM("Random"), - @SerializedName("Unknown") UNKNOWN("Unknown"), + enum class SourceSensor(val text: String) { + DEXCOM_NATIVE_UNKNOWN("AndroidAPS-Dexcom"), + DEXCOM_G6_NATIVE("AndroidAPS-DexcomG6"), + DEXCOM_G5_NATIVE("AndroidAPS-DexcomG5"), + DEXCOM_G4_WIXEL("Bluetooth Wixel"), + DEXCOM_G4_XBRIDGE("xBridge Wixel"), + DEXCOM_G4_NATIVE("G4 Share Receiver"), + MEDTRUM_A6("Medtrum A6"), + DEXCOM_G4_NET("Network G4"), + DEXCOM_G4_NET_XBRIDGE("Network G4 and xBridge"), + DEXCOM_G4_NET_CLASSIC("Network G4 and Classic xDrip"), + DEXCOM_G5_XDRIP("DexcomG5"), + DEXCOM_G6_NATIVE_XDRIP("G6 Native"), + DEXCOM_G5_NATIVE_XDRIP("G5 Native"), + DEXCOM_G6_G5_NATIVE_XDRIP("G6 Native / G5 Native"), + LIBRE_1_NET("Network libre"), + LIBRE_1_BLUE("BlueReader"), + LIBRE_1_PL("Transmiter PL"), + LIBRE_1_BLUCON("Blucon"), + LIBRE_1_TOMATO("Tomato"), + LIBRE_1_RF("Rfduino"), + LIBRE_1_LIMITTER("LimiTTer"), + GLIMP("Glimp"), + LIBRE_2_NATIVE("Libre2"), + POCTECH_NATIVE("Poctech"), + MM_600_SERIES("MM600Series"), + EVERSENSE("Eversense"), + RANDOM("Random"), + UNKNOWN("Unknown"), IOB_PREDICTION("IOBPrediction"), A_COB_PREDICTION("aCOBPrediction"), diff --git a/database/src/main/java/info/nightscout/androidaps/database/interfaces/DBEntryWithTimeAndDuration.kt b/database/src/main/java/info/nightscout/androidaps/database/interfaces/DBEntryWithTimeAndDuration.kt index 01f41c7f3f..475cd01f5d 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/interfaces/DBEntryWithTimeAndDuration.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/interfaces/DBEntryWithTimeAndDuration.kt @@ -11,5 +11,4 @@ var DBEntryWithTimeAndDuration.end require(duration > 0) } -@JvmOverloads fun DBEntryWithTimeAndDuration.getRemainingDuration(current: Long = System.currentTimeMillis()) = min(0L, end - current) \ No newline at end of file diff --git a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index e7e4447ba3..56cac1b6c7 100644 --- a/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/insight/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -590,7 +590,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai bolusingEvent.setPercent(0); rxBus.send(bolusingEvent); int trials = 0; - Long now = dateUtil.now(); + long now = dateUtil.now(); String serial = serialNumber(); insightDbHelper.createOrUpdate( new InsightBolusID( now, @@ -1183,8 +1183,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai for (InsightPumpID pumpID : pumpStartedEvents) { InsightPumpID stoppedEvent = insightDbHelper.getPumpStoppedEvent(pumpID.getPumpSerial(), pumpID.getTimestamp()); if (stoppedEvent != null && stoppedEvent.getEventType().equals(EventType.PumpStopped)) { // Search if Stop event is after 15min of Pause - InsightPumpID pauseEvent = insightDbHelper.getPumpStoppedEvent(pumpID.getPumpSerial(), stoppedEvent.getTimestamp() - T.mins(1).msecs()); - if (pauseEvent != null && pauseEvent.getEventType().equals(EventType.PumpPaused) && (stoppedEvent.getTimestamp() - pauseEvent.getTimestamp() < T.mins(16).msecs())) { + InsightPumpID pauseEvent = insightDbHelper.getPumpStoppedEvent(pumpID.getPumpSerial(), stoppedEvent.getTimestamp() - T.Companion.mins(1).msecs()); + if (pauseEvent != null && pauseEvent.getEventType().equals(EventType.PumpPaused) && (stoppedEvent.getTimestamp() - pauseEvent.getTimestamp() < T.Companion.mins(16).msecs())) { stoppedEvent = pauseEvent; stoppedEvent.setEventType(EventType.PumpStopped); } @@ -1343,7 +1343,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai event.getEventPosition())); temporaryBasals.add(new TemporaryBasal( timestamp, - T.mins(event.getDuration()).msecs(), + T.Companion.mins(event.getDuration()).msecs(), event.getAmount(), false, PumpSync.TemporaryBasalType.NORMAL, @@ -1406,7 +1406,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai pumpSync.syncExtendedBolusWithPumpId( bolusID.getTimestamp(), event.getExtendedAmount(), - T.mins(event.getDuration()).msecs(), + T.Companion.mins(event.getDuration()).msecs(), isFakingTempsByExtendedBoluses(), bolusID.getId(), PumpType.ACCU_CHEK_INSIGHT, diff --git a/insight/src/main/res/layout/activity_insight_pairing_information.xml b/insight/src/main/res/layout/activity_insight_pairing_information.xml index 3d6e0d56ed..c6e4ec51db 100644 --- a/insight/src/main/res/layout/activity_insight_pairing_information.xml +++ b/insight/src/main/res/layout/activity_insight_pairing_information.xml @@ -14,7 +14,7 @@ android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="16sp" - android:text="@string/serial_number" /> + android:text="@string/serialnumber" /> = mutableMapOf() - @JvmStatic fun getByCode(opCode: Int): CGMSHistoryEntryType { return if (opCodeMap.containsKey(opCode)) opCodeMap[opCode]!! @@ -42,7 +41,7 @@ enum class CGMSHistoryEntryType(val code: Int, val description: String, val head } } - @JvmField var schemaSet: Boolean + var schemaSet: Boolean val totalLength: Int val dateType: DateType diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfile.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfile.kt index f893c1b2a0..881a7ed6f6 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfile.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfile.kt @@ -300,7 +300,6 @@ class BasalProfile { return if (b < 0) b + 256 else b.toInt() } - @JvmStatic fun getProfilesByHourToString(data: DoubleArray): String { val stringBuilder = StringBuilder() for (value in data) { @@ -310,7 +309,6 @@ class BasalProfile { return stringBuilder.toString() } - @JvmStatic fun isBasalProfileByHourUndefined(basalByHour: DoubleArray): Boolean { for (i in 0..23) { if (basalByHour[i] > 0.0) { diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/defs/MedtronicCommandType.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/defs/MedtronicCommandType.kt index 35c8ec3a7b..b5f7c08764 100755 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/defs/MedtronicCommandType.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/defs/MedtronicCommandType.kt @@ -148,7 +148,6 @@ enum class MedtronicCommandType( } } - @JvmStatic fun getSettings(medtronicPumpModel: MedtronicDeviceType): MedtronicCommandType { return if (isSameDevice(medtronicPumpModel, MedtronicDeviceType.Medtronic_512_712)) Settings_512 diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/defs/MedtronicDeviceType.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/defs/MedtronicDeviceType.kt index 6f8be29bd6..ebf1c0e7c6 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/defs/MedtronicDeviceType.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/defs/MedtronicDeviceType.kt @@ -39,7 +39,6 @@ enum class MedtronicDeviceType { companion object { var mapByDescription: MutableMap = mutableMapOf() - @JvmStatic fun isSameDevice(deviceWeCheck: MedtronicDeviceType, deviceSources: MedtronicDeviceType): Boolean { if (deviceSources.isFamily) { for (mdt in deviceSources.familyMembers!!) { diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicConst.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicConst.kt index 80d284f80a..e88d3de97f 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicConst.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicConst.kt @@ -10,14 +10,14 @@ object MedtronicConst { const val Prefix = "AAPS.Medtronic." object Prefs { - @JvmField val PumpSerial = R.string.key_medtronic_serial - @JvmField val PumpType = R.string.key_medtronic_pump_type - @JvmField val PumpFrequency = R.string.key_medtronic_frequency - @JvmField val MaxBolus = R.string.key_medtronic_max_bolus - @JvmField val MaxBasal = R.string.key_medtronic_max_basal - @JvmField val BolusDelay = R.string.key_medtronic_bolus_delay - @JvmField val Encoding = R.string.key_medtronic_encoding - @JvmField val BatteryType = R.string.key_medtronic_battery_type + val PumpSerial = R.string.key_medtronic_serial + val PumpType = R.string.key_medtronic_pump_type + val PumpFrequency = R.string.key_medtronic_frequency + val MaxBolus = R.string.key_medtronic_max_bolus + val MaxBasal = R.string.key_medtronic_max_basal + val BolusDelay = R.string.key_medtronic_bolus_delay + val Encoding = R.string.key_medtronic_encoding + val BatteryType = R.string.key_medtronic_battery_type val BolusDebugEnabled = R.string.key_medtronic_bolus_debug } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicUtil.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicUtil.kt index 5826a1e0e6..41fe26d79f 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicUtil.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/util/MedtronicUtil.kt @@ -257,7 +257,6 @@ class MedtronicUtil @Inject constructor( return b2 and 0xff shl 8 or b1 and 0xff } - @JvmStatic fun getByteArrayFromUnsignedShort(shortValue: Int, returnFixedSize: Boolean): ByteArray { val highByte = (shortValue shr 8 and 0xFF).toByte() val lowByte = (shortValue and 0xFF).toByte() @@ -272,7 +271,6 @@ class MedtronicUtil @Inject constructor( return data } - @JvmStatic fun createByteArray(data: List): ByteArray { val array = ByteArray(data.size) for (i in data.indices) { @@ -304,7 +302,6 @@ class MedtronicUtil @Inject constructor( return strokes } - @JvmStatic fun isSame(d1: Double, d2: Double): Boolean { val diff = d1 - d2 return Math.abs(diff) <= 0.000001 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 743d5c4ca7..35ef3f0835 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 @@ -678,7 +678,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley if (tbrCurrent != null) { aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute: Current Basal: duration: {} min, rate={}", - T.msecs(tbrCurrent.getDuration()).mins(), tbrCurrent.getRate()); + T.Companion.msecs(tbrCurrent.getDuration()).mins(), tbrCurrent.getRate()); } if (tbrCurrent != null && !enforceNew) { diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsOmnipodErosManager.java b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsOmnipodErosManager.java index e7db508773..2e73d08141 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsOmnipodErosManager.java +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsOmnipodErosManager.java @@ -93,7 +93,6 @@ public class AapsOmnipodErosManager { private final RxBusWrapper rxBus; private final ResourceHelper resourceHelper; private final HasAndroidInjector injector; - private final ActivePlugin activePlugin; private final SP sp; private final OmnipodManager delegate; private final OmnipodAlertUtil omnipodAlertUtil; @@ -125,7 +124,6 @@ public class AapsOmnipodErosManager { SP sp, ResourceHelper resourceHelper, HasAndroidInjector injector, - ActivePlugin activePlugin, OmnipodAlertUtil omnipodAlertUtil, Context context, PumpSync pumpSync) { @@ -137,7 +135,6 @@ public class AapsOmnipodErosManager { this.sp = sp; this.resourceHelper = resourceHelper; this.injector = injector; - this.activePlugin = activePlugin; this.omnipodAlertUtil = omnipodAlertUtil; this.context = context; this.pumpSync = pumpSync; @@ -366,7 +363,7 @@ public class AapsOmnipodErosManager { bolusCommandResult = executeCommand(() -> delegate.bolus(PumpType.OMNIPOD_EROS.determineCorrectBolusSize(detailedBolusInfo.insulin), beepsEnabled, beepsEnabled, detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB ? null : (estimatedUnitsDelivered, percentage) -> { EventOverviewBolusProgress progressUpdateEvent = EventOverviewBolusProgress.INSTANCE; - progressUpdateEvent.setStatus(getStringResource(R.string.bolusdelivering, detailedBolusInfo.insulin)); + progressUpdateEvent.setStatus(getStringResource(R.string.goingtodeliver, detailedBolusInfo.insulin)); progressUpdateEvent.setPercent(percentage); sendEvent(progressUpdateEvent); })); @@ -779,7 +776,6 @@ public class AapsOmnipodErosManager { // Cancels current TBR and adds a new TBR for the remaining duration private void splitActiveTbr() { - PumpSync.PumpState pumpState = pumpSync.expectedPumpState(); PumpSync.PumpState.TemporaryBasal previouslyRunningTempBasal = pumpSync.expectedPumpState().getTemporaryBasal(); if (previouslyRunningTempBasal != null) { // Cancel the previously running TBR and start a NEW TBR here for the remaining duration, @@ -810,7 +806,7 @@ public class AapsOmnipodErosManager { pumpSync.syncTemporaryBasalWithPumpId( time, tempBasalPair.getInsulinRate(), - T.mins(tempBasalPair.getDurationMinutes()).msecs(), + T.Companion.mins(tempBasalPair.getDurationMinutes()).msecs(), true, PumpSync.TemporaryBasalType.NORMAL, pumpId, diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/ui/ErosPodHistoryActivity.java b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/ui/ErosPodHistoryActivity.java index e74215e8a8..0f9ea02d9f 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/ui/ErosPodHistoryActivity.java +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/ui/ErosPodHistoryActivity.java @@ -146,7 +146,7 @@ public class ErosPodHistoryActivity extends NoSplashAppCompatActivity { statusView.setVisibility(View.GONE); - typeListFull = getTypeList(PumpHistoryEntryGroup.getTranslatedList(resourceHelper)); + typeListFull = getTypeList(PumpHistoryEntryGroup.Companion.getTranslatedList(resourceHelper)); ArrayAdapter spinnerAdapter = new ArrayAdapter<>(this, R.layout.spinner_centered, typeListFull); historyTypeSpinner.setAdapter(spinnerAdapter); @@ -306,7 +306,7 @@ public class ErosPodHistoryActivity extends NoSplashAppCompatActivity { try { Profile.ProfileValue[] profileValuesArray = aapsOmnipodUtil.getGsonInstance().fromJson(data, Profile.ProfileValue[].class); - valueView.setText(ProfileUtil.getBasalProfilesDisplayable(profileValuesArray, PumpType.OMNIPOD_EROS)); + valueView.setText(ProfileUtil.INSTANCE.getBasalProfilesDisplayable(profileValuesArray, PumpType.OMNIPOD_EROS)); } catch (Exception e) { aapsLogger.error(LTag.PUMP, "Problem parsing Profile json. Ex: {}, Data:\n{}", e.getMessage(), data); valueView.setText(""); @@ -321,7 +321,7 @@ public class ErosPodHistoryActivity extends NoSplashAppCompatActivity { @Override - public void onAttachedToRecyclerView(RecyclerView recyclerView) { + public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) { super.onAttachedToRecyclerView(recyclerView); } diff --git a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt index 814e950f03..6314f5e668 100644 --- a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt +++ b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/PumpPluginAbstract.kt @@ -63,10 +63,10 @@ abstract class PumpPluginAbstract protected constructor( final override var pumpDescription = PumpDescription() //protected set - @JvmField protected var serviceConnection: ServiceConnection? = null - @JvmField protected var serviceRunning = false - @JvmField protected var pumpState = PumpDriverState.NotInitialized - @JvmField protected var displayConnectionMessages = false + protected var serviceConnection: ServiceConnection? = null + protected var serviceRunning = false + protected var pumpState = PumpDriverState.NotInitialized + protected var displayConnectionMessages = false var pumpType: PumpType = PumpType.GENERIC_AAPS get() = field diff --git a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.kt index 081c76c8db..21b95367ea 100644 --- a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.kt +++ b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpHistoryEntryGroup.kt @@ -43,7 +43,6 @@ enum class PumpHistoryEntryGroup(val resourceId: Int) { } } - @JvmStatic fun getTranslatedList(resourceHelper: ResourceHelper): List { if (translatedList == null) doTranslation(resourceHelper) return translatedList!! diff --git a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ProfileUtil.kt b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ProfileUtil.kt index 6559d80f80..8997e02482 100644 --- a/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ProfileUtil.kt +++ b/pump-common/src/main/java/info/nightscout/androidaps/plugins/pump/common/utils/ProfileUtil.kt @@ -19,7 +19,6 @@ object ProfileUtil { return if (stringBuilder.length > 3) stringBuilder.substring(0, stringBuilder.length - 2) else stringBuilder.toString() } - @JvmStatic fun getBasalProfilesDisplayable(profiles: Array, pumpType: PumpType): String { val stringBuilder = StringBuilder() for (basalValue in profiles) { @@ -32,7 +31,6 @@ object ProfileUtil { return if (stringBuilder.length > 3) stringBuilder.substring(0, stringBuilder.length - 2) else stringBuilder.toString() } - @JvmStatic fun getBasalProfilesDisplayableAsStringOfArray(profile: Profile, pumpType: PumpType): String? { val stringBuilder = java.lang.StringBuilder() // for (basalValue in profiles) {