Update combov2 code to match recent changes in dev branch

Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
Carlos Rafael Giani 2022-11-21 19:35:47 +01:00
parent 0621d1c1d1
commit 5745e95244
8 changed files with 83 additions and 79 deletions

View file

@ -4,15 +4,19 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/core/android_dependencies.gradle"
apply from: "${project.rootDir}/core/android_module_dependencies.gradle"
apply from: "${project.rootDir}/core/test_dependencies.gradle"
apply from: "${project.rootDir}/core/jacoco_global.gradle"
apply from: "${project.rootDir}/core/core-main//android_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main//android_module_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main//test_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main//jacoco_global.gradle"
dependencies {
implementation project(':core')
implementation project(':shared')
implementation project(':libraries')
implementation project(':core:core-main')
implementation project(':core:ui')
implementation project(':core:fabric')
implementation project(':app-wear-shared:rx')
implementation project(':app-wear-shared:shared')
implementation project(':interfaces')
implementation(project(":pump:combov2:comboctl"))
implementation("org.jetbrains.kotlinx:kotlinx-datetime:$kotlinx_datetime_version")
// This is necessary to avoid errors like these which otherwise come up often at runtime:

View file

@ -1,7 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply from: "${project.rootDir}/core/android_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/android_dependencies.gradle"
android {
namespace 'info.nightscout.comboctl'

View file

@ -1,10 +1,10 @@
package info.nightscout.androidaps.plugins.pump.combov2
import android.util.Log
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.comboctl.base.LogLevel
import info.nightscout.comboctl.base.LoggerBackend as ComboCtlLoggerBackend
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
internal class AAPSComboCtlLogger(private val aapsLogger: AAPSLogger) : ComboCtlLoggerBackend {
override fun log(tag: String, level: LogLevel, throwable: Throwable?, message: String?) {

View file

@ -10,8 +10,6 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.combov2.R
import info.nightscout.androidaps.combov2.databinding.Combov2FragmentBinding
import info.nightscout.comboctl.base.NullDisplayFrame
@ -19,13 +17,15 @@ import info.nightscout.comboctl.main.Pump as ComboCtlPump
import info.nightscout.comboctl.base.Tbr as ComboCtlTbr
import info.nightscout.comboctl.parser.BatteryState
import info.nightscout.comboctl.parser.ReservoirState
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.shared.interfaces.ResourceHelper
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlin.math.max
import java.util.Locale
import javax.inject.Inject
import kotlin.math.max
class ComboV2Fragment : DaggerFragment() {
@Inject lateinit var combov2Plugin: ComboV2Plugin
@ -235,7 +235,7 @@ class ComboV2Fragment : DaggerFragment() {
}
in 60..(30 * 60) -> {
binding.combov2LastConnection.text = rh.gs(info.nightscout.androidaps.core.R.string.minago, secondsPassed / 60)
binding.combov2LastConnection.text = rh.gs(R.string.minago, secondsPassed / 60)
binding.combov2LastConnection.setTextColor(Color.WHITE)
}
@ -262,7 +262,7 @@ class ComboV2Fragment : DaggerFragment() {
rh.gs(R.string.combov2_less_than_one_minute_ago)
else ->
rh.gs(info.nightscout.androidaps.core.R.string.minago, secondsPassed / 60)
rh.gs(R.string.minago, secondsPassed / 60)
}
binding.combov2LastBolus.text =

View file

@ -2,101 +2,101 @@ package info.nightscout.androidaps.plugins.pump.combov2
import android.content.Context
import android.content.Intent
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.coroutineScope
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.combov2.R
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.extensions.convertedToAbsolute
import info.nightscout.androidaps.extensions.plannedRemainingMinutes
import info.nightscout.androidaps.extensions.toStringFull
import info.nightscout.androidaps.interfaces.CommandQueue
import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.interfaces.Constraints
import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.Pump
import info.nightscout.androidaps.interfaces.PumpDescription
import info.nightscout.androidaps.interfaces.PumpPluginBase
import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.interfaces.ResourceHelper
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.common.ManufacturerType
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress.Treatment
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.TimeChangeType
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.comboctl.android.AndroidBluetoothInterface
import info.nightscout.comboctl.base.BasicProgressStage
import info.nightscout.comboctl.base.BluetoothAddress as ComboCtlBluetoothAddress
import info.nightscout.comboctl.base.BluetoothException
import info.nightscout.comboctl.base.ComboException
import info.nightscout.comboctl.base.DisplayFrame
import info.nightscout.comboctl.base.NullDisplayFrame
import info.nightscout.comboctl.base.LogLevel as ComboCtlLogLevel
import info.nightscout.comboctl.base.Logger as ComboCtlLogger
import info.nightscout.comboctl.base.LogLevel as ComboCtlLogLevel
import info.nightscout.comboctl.base.NullDisplayFrame
import info.nightscout.comboctl.base.PairingPIN
import info.nightscout.comboctl.main.Pump as ComboCtlPump
import info.nightscout.comboctl.main.PumpManager as ComboCtlPumpManager
import info.nightscout.comboctl.base.Tbr as ComboCtlTbr
import info.nightscout.comboctl.main.BasalProfile
import info.nightscout.comboctl.main.Pump as ComboCtlPump
import info.nightscout.comboctl.main.PumpManager as ComboCtlPumpManager
import info.nightscout.comboctl.main.QuantityNotChangingException
import info.nightscout.comboctl.main.RTCommandProgressStage
import info.nightscout.comboctl.parser.AlertScreenContent
import info.nightscout.comboctl.parser.AlertScreenException
import info.nightscout.comboctl.parser.BatteryState
import info.nightscout.comboctl.parser.ReservoirState
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.logging.LTag
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.defs.ManufacturerType
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.pump.PumpPluginBase
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.utils.TimeChangeType
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventOverviewBolusProgress
import info.nightscout.rx.events.EventOverviewBolusProgress.Treatment
import info.nightscout.rx.events.EventPumpStatusChanged
import info.nightscout.rx.events.EventRefreshOverview
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.async
import kotlinx.coroutines.cancel
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedSendChannelException
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import org.joda.time.DateTime
import org.json.JSONException
import org.json.JSONObject
import info.nightscout.shared.utils.DateUtil
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.math.max
import kotlin.math.min
import kotlin.math.roundToInt
import kotlinx.coroutines.async
import kotlinx.coroutines.cancel
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ClosedSendChannelException
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.delay
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.SupervisorJob
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import org.joda.time.DateTime
import org.json.JSONException
import org.json.JSONObject
@Singleton
class ComboV2Plugin @Inject constructor (

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.combov2
import info.nightscout.comboctl.main.BasalProfile
import info.nightscout.comboctl.main.NUM_COMBO_BASAL_PROFILE_FACTORS
import info.nightscout.androidaps.interfaces.Profile as AAPSProfile
import info.nightscout.interfaces.profile.Profile as AAPSProfile
// Utility extension functions for clearer conversion between
// ComboCtl units and AAPS units. ComboCtl uses integer-encoded

View file

@ -14,10 +14,10 @@ import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.combov2.R
import info.nightscout.androidaps.combov2.databinding.Combov2PairingActivityBinding
import info.nightscout.androidaps.plugins.pump.combov2.ComboV2Plugin
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.shared.logging.LTag
import info.nightscout.comboctl.base.BasicProgressStage
import info.nightscout.comboctl.base.PairingPIN
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.rx.logging.LTag
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch

View file

@ -313,7 +313,7 @@
android:layout_weight="1.5"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/basebasalrate_label"
android:text="@string/base_basal_rate_label"
android:textSize="14sp" />
<TextView
@ -437,7 +437,7 @@
android:layout_alignParentBottom="true"
android:orientation="vertical">
<info.nightscout.androidaps.utils.ui.SingleClickButton
<info.nightscout.core.ui.elements.SingleClickButton
android:id="@+id/combov2_refresh_button"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"