ktlint. update ktlint gradle plugin

This commit is contained in:
Andrei Vereha 2021-07-11 20:11:46 +02:00
parent 9a009d2f96
commit f289cd50c5
10 changed files with 78 additions and 77 deletions

View file

@ -63,7 +63,7 @@ buildscript {
plugins { plugins {
id "io.gitlab.arturbosch.detekt" version "1.16.0-RC2" id "io.gitlab.arturbosch.detekt" version "1.16.0-RC2"
id "org.jlleitschuh.gradle.ktlint" version "9.4.1" id "org.jlleitschuh.gradle.ktlint" version "10.1.0"
} }
allprojects { allprojects {

View file

@ -53,7 +53,6 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.concurrent.thread import kotlin.concurrent.thread
import kotlin.math.ceil import kotlin.math.ceil
import kotlin.math.exp
import kotlin.random.Random import kotlin.random.Random
@Singleton @Singleton
@ -75,7 +74,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
@Volatile var bolusCanceled = false @Volatile var bolusCanceled = false
private val handler: Handler = Handler(Looper.getMainLooper()) private val handler: Handler = Handler(Looper.getMainLooper())
private lateinit var statusChecker: Runnable private lateinit var statusChecker: Runnable
var nextPodWarningCheck : Long = 0 var nextPodWarningCheck: Long = 0
@Volatile var stopConnecting: CountDownLatch? = null @Volatile var stopConnecting: CountDownLatch? = null
companion object { companion object {
@ -109,7 +108,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
if (!podStateManager.isPodRunning) { if (!podStateManager.isPodRunning) {
val expectedState = pumpSync.expectedPumpState() val expectedState = pumpSync.expectedPumpState()
val tbr = expectedState.temporaryBasal val tbr = expectedState.temporaryBasal
if (tbr == null || tbr.rate!=0.0) { if (tbr == null || tbr.rate != 0.0) {
aapsLogger.info(LTag.PUMP, "createFakeTBRWhenNoActivePod") aapsLogger.info(LTag.PUMP, "createFakeTBRWhenNoActivePod")
pumpSync.syncTemporaryBasalWithPumpId( pumpSync.syncTemporaryBasalWithPumpId(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
@ -147,7 +146,17 @@ class OmnipodDashPumpPlugin @Inject constructor(
rxBus.send(EventNewNotification(notification)) rxBus.send(EventNewNotification(notification))
} else { } else {
rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_SUSPENDED)) rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_SUSPENDED))
// TODO: time out of sync notification? if (!TimeZone.getDefault().equals(podStateManager.timeZone)) {
val notification =
Notification(
Notification.OMNIPOD_TIME_OUT_OF_SYNC,
"Timezone on pod is different from the timezone on phone. " +
"Basal rate is incorrect" +
"Switch profile to fix",
Notification.NORMAL
)
rxBus.send(EventNewNotification(notification))
}
} }
} }
nextPodWarningCheck = DateTimeUtil.getTimeInFutureFromMinutes(15) nextPodWarningCheck = DateTimeUtil.getTimeInFutureFromMinutes(15)
@ -158,7 +167,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
if (podStateManager.isPodRunning && if (podStateManager.isPodRunning &&
podStateManager.activeCommand != null && podStateManager.activeCommand != null &&
commandQueue.size() == 0 && commandQueue.size() == 0 &&
commandQueue.performing() == null) { commandQueue.performing() == null
) {
commandQueue.readStatus("Unconfirmed command", null) commandQueue.readStatus("Unconfirmed command", null)
} }
} }

View file

@ -16,7 +16,7 @@ interface OmnipodDashBleManager {
fun getStatus(): ConnectionState fun getStatus(): ConnectionState
// used for sync connections // used for sync connections
fun connect(timeoutMs: Long = Connection.BASE_CONNECT_TIMEOUT_MS*3): Observable<PodEvent> fun connect(timeoutMs: Long = Connection.BASE_CONNECT_TIMEOUT_MS * 3): Observable<PodEvent>
// used for async connections // used for async connections
fun connect(stopConnectionLatch: CountDownLatch): Observable<PodEvent> fun connect(stopConnectionLatch: CountDownLatch): Observable<PodEvent>

View file

@ -24,15 +24,14 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
import java.lang.IllegalArgumentException import java.lang.IllegalArgumentException
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch
import kotlin.math.absoluteValue
sealed class ConnectionState sealed class ConnectionState
object Connecting: ConnectionState() object Connecting : ConnectionState()
object Connected : ConnectionState() object Connected : ConnectionState()
object NotConnected : ConnectionState() object NotConnected : ConnectionState()
data class ConnectionWaitCondition(var timeoutMs: Long?=null, val stopConnection: CountDownLatch?=null) { data class ConnectionWaitCondition(var timeoutMs: Long? = null, val stopConnection: CountDownLatch? = null) {
init { init {
if (timeoutMs == null && stopConnection == null) { if (timeoutMs == null && stopConnection == null) {
throw IllegalArgumentException("One of timeoutMs or stopConnection has to be non null") throw IllegalArgumentException("One of timeoutMs or stopConnection has to be non null")
@ -68,8 +67,8 @@ class Connection(
podState.bluetoothConnectionState = OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTING podState.bluetoothConnectionState = OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTING
val autoConnect = false val autoConnect = false
val gatt = gattConnection ?: val gatt = gattConnection
podDevice.connectGatt(context, autoConnect, bleCommCallbacks, BluetoothDevice.TRANSPORT_LE) ?: podDevice.connectGatt(context, autoConnect, bleCommCallbacks, BluetoothDevice.TRANSPORT_LE)
gattConnection = gatt gattConnection = gatt
if (!gatt.connect()) { if (!gatt.connect()) {
throw FailedToConnectException("connect() returned false") throw FailedToConnectException("connect() returned false")

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.MessageIOException
import java.util.* import java.util.*

View file

@ -11,7 +11,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.StringLengthPrefixEncoding.Companion.parseKeys import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.StringLengthPrefixEncoding.Companion.parseKeys
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response
import kotlin.reflect.KClass
sealed class CommandSendResult sealed class CommandSendResult
object CommandSendSuccess : CommandSendResult() object CommandSendSuccess : CommandSendResult()
@ -113,10 +112,10 @@ class Session(
// TODO verify length // TODO verify length
//val uniqueId = data.copyOfRange(0, 4) // val uniqueId = data.copyOfRange(0, 4)
//val lenghtAndSequenceNumber = data.copyOfRange(4, 6) // val lenghtAndSequenceNumber = data.copyOfRange(4, 6)
val payload = data.copyOfRange(6, data.size - 2) val payload = data.copyOfRange(6, data.size - 2)
//val crc = data.copyOfRange(data.size - 2, data.size) // val crc = data.copyOfRange(data.size - 2, data.size)
// TODO validate uniqueId, sequenceNumber and crc // TODO validate uniqueId, sequenceNumber and crc

View file

@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state
import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair.PairResult import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair.PairResult
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEvent
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.*
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse
@ -11,10 +10,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.VersionResponse
import io.reactivex.Completable import io.reactivex.Completable
import io.reactivex.Maybe import io.reactivex.Maybe
import io.reactivex.Observable
import io.reactivex.Single import io.reactivex.Single
import org.joda.time.DateTime import org.joda.time.DateTime
import org.joda.time.DateTimeZone
import org.joda.time.Duration import org.joda.time.Duration
import java.io.Serializable import java.io.Serializable
import java.util.* import java.util.*

View file

@ -11,7 +11,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.Id
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair.PairResult import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair.PairResult
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.EapSqn import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session.EapSqn
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEvent
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.*
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.AlarmStatusResponse
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.DefaultStatusResponse
@ -20,10 +19,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import io.reactivex.Completable import io.reactivex.Completable
import io.reactivex.Maybe import io.reactivex.Maybe
import io.reactivex.Observable
import io.reactivex.Single import io.reactivex.Single
import org.joda.time.DateTime import org.joda.time.DateTime
import org.joda.time.DateTimeZone
import org.joda.time.Duration import org.joda.time.Duration
import java.io.Serializable import java.io.Serializable
import java.util.* import java.util.*

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui
import android.content.Intent import android.content.Intent
import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
@ -286,7 +285,8 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
// Update Pod expiry time // Update Pod expiry time
val expiresAt = podStateManager.expiry val expiresAt = podStateManager.expiry
podInfoBinding.podExpiryDate.text = expiresAt?.let { podInfoBinding.podExpiryDate.text = expiresAt?.let {
readableZonedTime(it) } readableZonedTime(it)
}
?: PLACEHOLDER ?: PLACEHOLDER
podInfoBinding.podExpiryDate.setTextColor( podInfoBinding.podExpiryDate.setTextColor(
if (expiresAt != null && DateTime.now().isAfter(expiresAt)) if (expiresAt != null && DateTime.now().isAfter(expiresAt))