From 374e2518015460b89a4537e2384bbdf118bbff37 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 20 Sep 2021 17:20:09 +0200 Subject: [PATCH] remove @Jvm directives where possible --- .../plugins/general/nsclient/acks/NSAddAck.kt | 4 ++-- .../androidaps/utils/wizard/BolusWizard.kt | 1 - .../plugins/pump/combo/ComboPlugin.java | 8 ++++---- .../info/nightscout/androidaps/Constants.java | 7 ++----- .../androidaps/data/DetailedBolusInfo.kt | 4 ++-- .../androidaps/data/InMemoryGlucoseValue.kt | 2 +- .../androidaps/dialogs/BolusProgressDialog.kt | 4 ---- .../info/nightscout/androidaps/utils/DateUtil.kt | 7 +++---- .../nightscout/androidaps/utils/JsonHelper.kt | 8 -------- .../java/info/nightscout/androidaps/utils/T.kt | 14 +++++++------- .../androidaps/utils/alertDialogs/OKDialog.kt | 8 -------- .../utils/protection/ProtectionCheck.kt | 1 - .../services/DanaRKoreanExecutionService.java | 4 ++-- .../androidaps/danaRv2/DanaRv2Plugin.java | 6 +++--- .../services/DanaRv2ExecutionService.java | 10 +++++----- .../danar/services/DanaRExecutionService.java | 2 +- .../danars/comm/DanaRSPacketHistoryBasal.kt | 2 +- .../danars/comm/DanaRSPacketHistoryPrime.kt | 2 +- .../interfaces/DBEntryWithTimeAndDuration.kt | 1 - .../plugins/pump/insight/LocalInsightPlugin.java | 10 +++++----- .../comm/history/cgms/CGMSHistoryEntryType.kt | 3 +-- .../pump/medtronic/data/dto/BasalProfile.kt | 2 -- .../pump/medtronic/defs/MedtronicCommandType.kt | 1 - .../pump/medtronic/defs/MedtronicDeviceType.kt | 1 - .../pump/medtronic/util/MedtronicConst.kt | 16 ++++++++-------- .../plugins/pump/medtronic/util/MedtronicUtil.kt | 3 --- .../pump/omnipod/eros/OmnipodErosPumpPlugin.java | 2 +- .../eros/manager/AapsOmnipodErosManager.java | 6 +----- .../omnipod/eros/ui/ErosPodHistoryActivity.java | 6 +++--- .../plugins/pump/common/PumpPluginAbstract.kt | 8 ++++---- .../pump/common/defs/PumpHistoryEntryGroup.kt | 1 - .../plugins/pump/common/utils/ProfileUtil.kt | 2 -- 32 files changed, 57 insertions(+), 99 deletions(-) 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/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/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/utils/DateUtil.kt b/core/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt index 5ec6da3238..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) } 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/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/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/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/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/cgms/CGMSHistoryEntryType.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/cgms/CGMSHistoryEntryType.kt index bf56899830..4e993c1249 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/cgms/CGMSHistoryEntryType.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/cgms/CGMSHistoryEntryType.kt @@ -27,7 +27,6 @@ enum class CGMSHistoryEntryType(val code: Int, val description: String, val head private val opCodeMap: MutableMap = 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 04f52fc52d..6bcd7e9ba0 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 e6677519eb..d286ebfc74 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; @@ -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) {