MDT: fix initialization
This commit is contained in:
parent
5d749e121f
commit
77e112471f
5 changed files with 34 additions and 50 deletions
|
@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.medtronic
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
|
@ -16,13 +15,11 @@ import info.nightscout.androidaps.events.EventTempBasalChange
|
|||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||
import info.nightscout.androidaps.interfaces.CommandQueue
|
||||
import info.nightscout.androidaps.interfaces.PumpSync
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.logging.LTag
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState
|
||||
import info.nightscout.androidaps.plugins.pump.common.events.EventRefreshButtonState
|
||||
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
||||
|
@ -42,8 +39,9 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
|||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.WarnColors
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.logging.LTag
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import javax.inject.Inject
|
||||
|
@ -59,7 +57,6 @@ class MedtronicFragment : DaggerFragment() {
|
|||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var medtronicPumpPlugin: MedtronicPumpPlugin
|
||||
@Inject lateinit var warnColors: WarnColors
|
||||
@Inject lateinit var rileyLinkUtil: RileyLinkUtil
|
||||
@Inject lateinit var medtronicUtil: MedtronicUtil
|
||||
@Inject lateinit var medtronicPumpStatus: MedtronicPumpStatus
|
||||
@Inject lateinit var rileyLinkServiceData: RileyLinkServiceData
|
||||
|
@ -92,7 +89,7 @@ class MedtronicFragment : DaggerFragment() {
|
|||
|
||||
binding.rlStatus.text = rh.gs(RileyLinkServiceState.NotStarted.resourceId)
|
||||
|
||||
binding.pumpStatusIcon.setTextColor(rh.gac(context,R.attr.defaultTextColor))
|
||||
binding.pumpStatusIcon.setTextColor(rh.gac(context, R.attr.defaultTextColor))
|
||||
@SuppressLint("SetTextI18n")
|
||||
binding.pumpStatusIcon.text = "{fa-bed}"
|
||||
|
||||
|
@ -200,7 +197,7 @@ class MedtronicFragment : DaggerFragment() {
|
|||
rileyLinkServiceData.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + rh.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
||||
else -> "{fa-bluetooth-b} " + rh.gs(resourceId)
|
||||
}
|
||||
binding.rlStatus.setTextColor(rh.gac( context, if (rileyLinkError != null) R.attr.warningColor else R.attr.defaultTextColor))
|
||||
binding.rlStatus.setTextColor(rh.gac(context, if (rileyLinkError != null) R.attr.warningColor else R.attr.defaultTextColor))
|
||||
|
||||
binding.errors.text =
|
||||
rileyLinkServiceData.rileyLinkError?.let {
|
||||
|
@ -253,8 +250,10 @@ class MedtronicFragment : DaggerFragment() {
|
|||
|
||||
private fun displayNotConfiguredDialog() {
|
||||
context?.let {
|
||||
OKDialog.show(it, rh.gs(R.string.medtronic_warning),
|
||||
rh.gs(R.string.medtronic_error_operation_not_possible_no_configuration), null)
|
||||
OKDialog.show(
|
||||
it, rh.gs(R.string.medtronic_warning),
|
||||
rh.gs(R.string.medtronic_error_operation_not_possible_no_configuration), null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,7 +271,7 @@ class MedtronicFragment : DaggerFragment() {
|
|||
val min = (System.currentTimeMillis() - medtronicPumpStatus.lastConnection) / 1000 / 60
|
||||
if (medtronicPumpStatus.lastConnection + 60 * 1000 > System.currentTimeMillis()) {
|
||||
binding.lastConnection.setText(R.string.medtronic_pump_connected_now)
|
||||
binding.lastConnection.setTextColor(rh.gac(context,R.attr.defaultTextColor))
|
||||
binding.lastConnection.setTextColor(rh.gac(context, R.attr.defaultTextColor))
|
||||
} else if (medtronicPumpStatus.lastConnection + 30 * 60 * 1000 < System.currentTimeMillis()) {
|
||||
|
||||
if (min < 60) {
|
||||
|
@ -288,10 +287,10 @@ class MedtronicFragment : DaggerFragment() {
|
|||
binding.lastConnection.text = (rh.gq(R.plurals.duration_days, d, d) + " "
|
||||
+ rh.gs(R.string.ago))
|
||||
}
|
||||
binding.lastConnection.setTextColor(rh.gac(context,R.attr.warningColor))
|
||||
binding.lastConnection.setTextColor(rh.gac(context, R.attr.warningColor))
|
||||
} else {
|
||||
binding.lastConnection.text = minAgo
|
||||
binding.lastConnection.setTextColor(rh.gac(context,R.attr.defaultTextColor))
|
||||
binding.lastConnection.setTextColor(rh.gac(context, R.attr.defaultTextColor))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,7 +328,8 @@ class MedtronicFragment : DaggerFragment() {
|
|||
if (medtronicPumpStatus.batteryType == BatteryType.None || medtronicPumpStatus.batteryVoltage == null) {
|
||||
binding.pumpStateBattery.text = "{fa-battery-" + medtronicPumpStatus.batteryRemaining / 25 + "} "
|
||||
} else {
|
||||
binding.pumpStateBattery.text = "{fa-battery-" + medtronicPumpStatus.batteryRemaining / 25 + "} " + medtronicPumpStatus.batteryRemaining + "%" + String.format(" (%.2f V)", medtronicPumpStatus.batteryVoltage)
|
||||
binding.pumpStateBattery.text =
|
||||
"{fa-battery-" + medtronicPumpStatus.batteryRemaining / 25 + "} " + medtronicPumpStatus.batteryRemaining + "%" + String.format(" (%.2f V)", medtronicPumpStatus.batteryVoltage)
|
||||
}
|
||||
warnColors.setColorInverse(binding.pumpStateBattery, medtronicPumpStatus.batteryRemaining.toDouble(), 25.0, 10.0)
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ import info.nightscout.androidaps.utils.DateUtil
|
|||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.TimeChangeType
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.logging.LTag
|
||||
|
@ -215,27 +216,13 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
}.start()
|
||||
}
|
||||
|
||||
override val serviceClass: Class<*>
|
||||
get() = RileyLinkMedtronicService::class.java
|
||||
|
||||
override val pumpStatusData: info.nightscout.androidaps.plugins.pump.common.data.PumpStatus
|
||||
get() = medtronicPumpStatus
|
||||
|
||||
override fun deviceID(): String {
|
||||
return "Medtronic"
|
||||
}
|
||||
|
||||
override val isFakingTempsByExtendedBoluses: Boolean
|
||||
get() = false
|
||||
|
||||
override fun canHandleDST(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
// Pump Plugin
|
||||
override val serviceClass: Class<*> = RileyLinkMedtronicService::class.java
|
||||
override val pumpStatusData: PumpStatus get() = medtronicPumpStatus
|
||||
override fun deviceID(): String = "Medtronic"
|
||||
override val isFakingTempsByExtendedBoluses: Boolean = false
|
||||
override fun canHandleDST(): Boolean = false
|
||||
private var isServiceSet: Boolean = false
|
||||
|
||||
override val rileyLinkService: RileyLinkMedtronicService? = rileyLinkMedtronicService
|
||||
override val rileyLinkService: RileyLinkMedtronicService? get() = rileyLinkMedtronicService
|
||||
|
||||
override val pumpInfo: RileyLinkPumpInfo
|
||||
get() = RileyLinkPumpInfo(
|
||||
|
@ -244,7 +231,7 @@ class MedtronicPumpPlugin @Inject constructor(
|
|||
medtronicPumpStatus.serialNumber
|
||||
)
|
||||
|
||||
override val lastConnectionTimeMillis: Long = medtronicPumpStatus.lastConnection
|
||||
override val lastConnectionTimeMillis: Long get() = medtronicPumpStatus.lastConnection
|
||||
|
||||
override fun setLastCommunicationToNow() {
|
||||
medtronicPumpStatus.setLastCommunicationToNow()
|
||||
|
|
|
@ -120,9 +120,8 @@ class RileyLinkBroadcastReceiver : DaggerBroadcastReceiver() {
|
|||
|
||||
RileyLinkConst.Intents.RileyLinkNewAddressSet -> {
|
||||
val rileylinkBLEAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "")
|
||||
if (rileylinkBLEAddress == "") {
|
||||
aapsLogger.error("No Rileylink BLE Address saved in app")
|
||||
} else rileyLinkService?.reconfigureRileyLink(rileylinkBLEAddress)
|
||||
if (rileylinkBLEAddress == "") aapsLogger.error("No Rileylink BLE Address saved in app")
|
||||
else rileyLinkService?.reconfigureRileyLink(rileylinkBLEAddress)
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ abstract class RileyLinkService : DaggerService() {
|
|||
@Inject lateinit var rfSpy: RFSpy // interface for RL xxx Mhz radio.
|
||||
|
||||
private val bluetoothAdapter: BluetoothAdapter? get() = (context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter
|
||||
protected var broadcastReceiver: RileyLinkBroadcastReceiver? = null
|
||||
private var broadcastReceiver: RileyLinkBroadcastReceiver? = null
|
||||
private var bluetoothStateReceiver: RileyLinkBluetoothStateReceiver? = null
|
||||
|
||||
override fun onCreate() {
|
||||
|
|
|
@ -6,9 +6,6 @@ import javax.annotation.Nullable;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import info.nightscout.androidaps.interfaces.ActivePlugin;
|
||||
import info.nightscout.shared.logging.AAPSLogger;
|
||||
import info.nightscout.shared.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
|
@ -18,6 +15,8 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistor
|
|||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
|
||||
import info.nightscout.shared.logging.AAPSLogger;
|
||||
import info.nightscout.shared.logging.LTag;
|
||||
|
||||
/**
|
||||
* Created by andy on 16/05/2018.
|
||||
|
@ -30,7 +29,6 @@ public class RileyLinkServiceData {
|
|||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject RileyLinkUtil rileyLinkUtil;
|
||||
@Inject RxBus rxBus;
|
||||
@Inject ActivePlugin activePlugin;
|
||||
|
||||
boolean tuneUpDone = false;
|
||||
public RileyLinkError rileyLinkError;
|
||||
|
|
Loading…
Reference in a new issue