Skip to content

Commit

Permalink
Merge pull request #3242 from nightscout/dev32
Browse files Browse the repository at this point in the history
3.2.0.4
  • Loading branch information
MilosKozak committed Feb 27, 2024
2 parents bb1a276 + 2798ae6 commit 5d3e33c
Show file tree
Hide file tree
Showing 23 changed files with 67 additions and 61 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.2.0")
classpath("com.android.tools.build:gradle:8.2.1")
classpath("com.google.gms:google-services:4.4.0")
classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.9")

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.gradle.api.JavaVersion

object Versions {

const val appVersion = "3.2.0.3"
const val appVersion = "3.2.0.4"
const val versionCode = 1500

const val ndkVersion = "21.1.6352462"
Expand Down
4 changes: 2 additions & 2 deletions core/ui/src/main/res/drawable/ic_user_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
android:viewportHeight="24">
<path
android:pathData="M13.351,12.926c-0.137,-0.003 -0.283,0.012 -0.337,-0.17c-0.046,-0.155 0.002,-0.266 0.122,-0.366c0.628,-0.523 0.741,-1.232 0.711,-2.042c0,-0.148 0.013,-0.348 -0.002,-0.546c-0.071,-0.91 -0.785,-1.606 -1.718,-1.686c-0.845,-0.073 -1.71,0.485 -1.862,1.344c-0.184,1.039 -0.278,2.111 0.636,2.933c0.115,0.104 0.172,0.206 0.12,0.363c-0.059,0.177 -0.201,0.171 -0.34,0.169c-0.347,-0.005 -0.668,0.083 -0.97,0.249c-0.973,0.535 -1.043,1.404 -0.165,2.061c1.299,0.974 3.949,0.841 5.144,-0.257c0.471,-0.433 0.508,-0.927 0.084,-1.408C14.4,13.146 13.918,12.937 13.351,12.926zM13.572,14.889c-1.202,0.486 -2.407,0.499 -3.555,-0.158c-0.579,-0.331 -0.548,-0.663 0.046,-0.976c0.248,-0.131 0.517,-0.214 0.801,-0.195c0.348,0.024 0.636,-0.047 0.765,-0.414c0.14,-0.399 0.306,-0.823 -0.105,-1.149c-0.661,-0.524 -0.705,-1.225 -0.666,-1.98c0.039,-0.729 0.51,-1.259 1.159,-1.248c0.662,0.011 1.13,0.529 1.146,1.269c0.003,0.119 0,0.239 0,0.456c0.097,0.503 -0.086,0.988 -0.564,1.377c-0.395,0.321 -0.385,0.738 -0.235,1.187c0.15,0.448 0.477,0.542 0.89,0.506c0.039,-0.003 0.08,0.004 0.118,0.014c0.389,0.093 0.879,0.167 0.948,0.599C14.392,14.615 13.901,14.756 13.572,14.889z"
android:fillColor="?attr/userOptionColor"/>
android:fillColor="@color/userOption"/>
<path
android:pathData="M19.107,10.662H17.78c-0.15,-0.648 -0.406,-1.253 -0.749,-1.801l0.941,-0.941c0.239,-0.239 0.239,-0.626 0,-0.864l-1.027,-1.027c-0.239,-0.239 -0.626,-0.239 -0.864,0l-0.941,0.941c-0.548,-0.343 -1.154,-0.599 -1.801,-0.749V4.893c0,-0.338 -0.274,-0.611 -0.611,-0.611h-1.453c-0.338,0 -0.611,0.274 -0.611,0.611V6.22c-0.648,0.15 -1.253,0.406 -1.801,0.749L7.92,6.028c-0.239,-0.239 -0.626,-0.239 -0.864,0L6.028,7.056c-0.239,0.239 -0.239,0.626 0,0.864l0.941,0.941C6.626,9.409 6.37,10.015 6.22,10.662H4.893c-0.338,0 -0.611,0.274 -0.611,0.611v1.453c0,0.338 0.274,0.611 0.611,0.611H6.22c0.15,0.648 0.406,1.253 0.749,1.801L6.028,16.08c-0.239,0.239 -0.239,0.626 0,0.864l1.027,1.027c0.239,0.239 0.626,0.239 0.864,0l0.941,-0.941c0.548,0.343 1.154,0.599 1.801,0.749v1.328c0,0.338 0.274,0.611 0.611,0.611h1.453c0.338,0 0.611,-0.274 0.611,-0.611V17.78c0.648,-0.15 1.254,-0.406 1.801,-0.749l0.941,0.941c0.239,0.239 0.626,0.239 0.864,0l1.027,-1.027c0.239,-0.239 0.239,-0.626 0,-0.864l-0.941,-0.941c0.343,-0.548 0.599,-1.154 0.749,-1.801h1.328c0.338,0 0.611,-0.274 0.611,-0.611v-1.453C19.719,10.936 19.445,10.662 19.107,10.662zM12,16.938c-2.723,0 -4.938,-2.215 -4.938,-4.938S9.277,7.063 12,7.063S16.938,9.277 16.938,12S14.723,16.938 12,16.938z"
android:fillColor="?attr/userOptionColor"/>
android:fillColor="@color/userOption"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ data class GlucoseValue(
DEXCOM_G6_NATIVE_XDRIP("G6 Native"),
DEXCOM_G5_NATIVE_XDRIP("G5 Native"),
DEXCOM_G6_G5_NATIVE_XDRIP("G6 Native / G5 Native"),
DEXCOM_G7_NATIVE_XDRIP("G7"),
LIBRE_1_OTHER("Other App"),
LIBRE_1_NET("Network libre"),
LIBRE_1_BLUE("BlueReader"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,14 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
}
it.setCompoundDrawablesWithIntrinsicBounds(null, rh.gd(app.aaps.core.ui.R.drawable.ic_user_options), null, null)
it.text = event.title

it.setOnClickListener {
OKDialog.showConfirmation(context, rh.gs(R.string.run_question, event.title), { handler.post { automation.processEvent(event) } })
}
binding.buttonsLayout.userButtonsLayout.addView(it)
for (drawable in it.compoundDrawables ) {
drawable?.mutate()
drawable?.colorFilter = PorterDuffColorFilter(rh.gac(context, app.aaps.core.ui.R.attr.userOptionColor), PorterDuff.Mode.SRC_IN)
}
}
}
binding.buttonsLayout.userButtonsLayout.visibility = events.isNotEmpty().toVisibility()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class XdripSourcePlugin @Inject constructor(
GlucoseValue.SourceSensor.DEXCOM_G5_NATIVE,
GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE_XDRIP,
GlucoseValue.SourceSensor.DEXCOM_G5_NATIVE_XDRIP,
GlucoseValue.SourceSensor.DEXCOM_G6_G5_NATIVE_XDRIP
GlucoseValue.SourceSensor.DEXCOM_G6_G5_NATIVE_XDRIP,
GlucoseValue.SourceSensor.DEXCOM_G7_NATIVE_XDRIP
).any { it == glucoseValue.sourceSensor }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class NsIncomingDataProcessor @Inject constructor(
*/
@Suppress("SpellCheckingInspection")
fun processSgvs(sgvs: Any): Boolean {
// Objective0
sp.putBoolean(app.aaps.core.utils.R.string.key_objectives_bg_is_available_in_ns, true)

if (!nsClientSource.isEnabled() && !sp.getBoolean(app.aaps.core.utils.R.string.key_ns_receive_cgm, false)) return false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,6 @@ class NSClientService : DaggerService() {
val sgvs = data.getJSONArray("sgvs")
if (sgvs.length() > 0) {
rxBus.send(EventNSClientNewLog("◄ DATA", "received " + sgvs.length() + " sgvs"))
// Objective0
sp.putBoolean(app.aaps.core.utils.R.string.key_objectives_bg_is_available_in_ns, true)
nsIncomingDataProcessor.processSgvs(sgvs)
storeDataForDb.storeGlucoseValuesToDb()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ class LoadBgWorker(
if (sgvs.isNotEmpty()) {
val action = if (isFirstLoad) "RCV-F" else "RCV"
rxBus.send(EventNSClientNewLog("$action", "${sgvs.size} SVGs from ${dateUtil.dateAndTimeAndSecondsString(lastLoaded)}"))
// Objective0
sp.putBoolean(app.aaps.core.utils.R.string.key_objectives_bg_is_available_in_ns, true)
// Schedule processing of fetched data and continue of loading
continueLoading = response.code != 304 && nsIncomingDataProcessor.processSgvs(sgvs)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import app.aaps.core.ui.toast.ToastUtils
import app.aaps.core.validators.ValidatingEditTextPreference
import dagger.android.HasAndroidInjector
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
import info.nightscout.pump.medtrum.comm.enums.ModelType
import info.nightscout.pump.medtrum.services.MedtrumService
import info.nightscout.pump.medtrum.ui.MedtrumOverviewFragment
import info.nightscout.pump.medtrum.util.MedtrumSnUtil
Expand Down Expand Up @@ -153,7 +154,7 @@ import kotlin.math.abs
override fun afterTextChanged(newValue: Editable?) {
val newSN = newValue?.toString()?.toLongOrNull(radix = 16) ?: 0
val newDeviceType = MedtrumSnUtil().getDeviceTypeFromSerial(newSN)
editText.error = if (newDeviceType == MedtrumSnUtil.INVALID) {
editText.error = if (newDeviceType == ModelType.INVALID) {
rh.gs(R.string.sn_input_invalid)
} else {
null
Expand All @@ -174,7 +175,7 @@ import kotlin.math.abs
val newDeviceType = MedtrumSnUtil().getDeviceTypeFromSerial(newSN)

when {
newDeviceType == MedtrumSnUtil.INVALID -> {
newDeviceType == ModelType.INVALID -> {
preferenceFragment.activity?.let { activity ->
OKDialog.show(activity, rh.gs(R.string.sn_input_title), rh.gs(R.string.sn_input_invalid))
}
Expand All @@ -183,7 +184,7 @@ import kotlin.math.abs

medtrumPump.pumpType(newDeviceType) == PumpType.MEDTRUM_UNTESTED -> {
preferenceFragment.activity?.let { activity ->
OKDialog.show(activity, rh.gs(R.string.sn_input_title), rh.gs(R.string.pump_unsupported, newDeviceType))
OKDialog.show(activity, rh.gs(R.string.sn_input_title), rh.gs(R.string.pump_unsupported, newDeviceType.toString()))
}
false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import info.nightscout.pump.medtrum.comm.enums.AlarmSetting
import info.nightscout.pump.medtrum.comm.enums.AlarmState
import info.nightscout.pump.medtrum.comm.enums.BasalType
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
import info.nightscout.pump.medtrum.comm.enums.ModelType
import info.nightscout.pump.medtrum.extension.toByteArray
import info.nightscout.pump.medtrum.extension.toInt
import info.nightscout.pump.medtrum.util.MedtrumSnUtil
Expand Down Expand Up @@ -291,13 +292,13 @@ class MedtrumPump @Inject constructor(
var desiredPumpWarning = true
var desiredPumpWarningExpiryThresholdHours = 72L

fun pumpType(): PumpType = pumpType(deviceType)
fun pumpType(): PumpType = pumpType(ModelType.fromValue(deviceType))

fun pumpType(type: Int): PumpType =
fun pumpType(type: ModelType): PumpType =
when (type) {
MedtrumSnUtil.MD_0201, MedtrumSnUtil.MD_8201 -> PumpType.MEDTRUM_NANO
MedtrumSnUtil.MD_8301 -> PumpType.MEDTRUM_300U
else -> PumpType.MEDTRUM_UNTESTED
ModelType.MD0201, ModelType.MD8201 -> PumpType.MEDTRUM_NANO
ModelType.MD8301 -> PumpType.MEDTRUM_300U
else -> PumpType.MEDTRUM_UNTESTED
}

fun loadVarsFromSP() {
Expand Down Expand Up @@ -569,7 +570,7 @@ class MedtrumPump @Inject constructor(
AlarmState.EXPIRED -> R.string.alarm_expired
AlarmState.RESERVOIR_EMPTY -> R.string.alarm_reservoir_empty
AlarmState.PATCH_FAULT -> R.string.alarm_patch_fault
AlarmState.PATCH_FAULT2 -> R.string.alarm_patch_fault2
AlarmState.PATCH_FAULT2 -> R.string.alarm_patch_fault // To avoid confusion, medtrum app also doesn't show patch fault 2
AlarmState.BASE_FAULT -> R.string.alarm_base_fault
AlarmState.BATTERY_OUT -> R.string.alarm_battery_out
AlarmState.NO_CALIBRATION -> R.string.alarm_no_calibration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ enum class PatchStep {
ACTIVATE_COMPLETE,
RETRY_ACTIVATION,
RETRY_ACTIVATION_CONNECT,
ERROR,
CANCEL,
COMPLETE;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package info.nightscout.pump.medtrum.comm.enums

enum class ModelType(val value: Int) {
INVALID(-1),
MD0201(80),
MD5201(81),
MD0202(82),
MD5202(83),
MD8201(88),
MD8301(98);

companion object {
fun fromValue(value: Int): ModelType {
return values().find { it.value == value } ?: INVALID
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class MedtrumService : DaggerService(), BLECommCallback {
if (event.isChanged(rh.gs(R.string.key_sn_input))) {
aapsLogger.debug(LTag.PUMPCOMM, "Serial number changed, reporting new pump!")
medtrumPump.loadUserSettingsFromSP()
medtrumPump.deviceType = MedtrumSnUtil().getDeviceTypeFromSerial(medtrumPump.pumpSN)
medtrumPump.deviceType = MedtrumSnUtil().getDeviceTypeFromSerial(medtrumPump.pumpSN).value
medtrumPump.resetPatchParameters()
pumpSync.connectNewPump()
medtrumPump.setFakeTBRIfNotSet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class MedtrumActivateFragment : MedtrumBaseFragment<FragmentMedtrumActivateBindi
MedtrumViewModel.SetupStep.ACTIVATED -> moveStep(PatchStep.ACTIVATE_COMPLETE)

MedtrumViewModel.SetupStep.ERROR -> {
moveStep(PatchStep.ERROR)
updateSetupStep(MedtrumViewModel.SetupStep.PRIMED) // Reset setup step
binding.textActivatingPump.text = rh.gs(R.string.activating_error)
binding.btnPositive.visibility = View.VISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class MedtrumActivity : MedtrumBaseActivity<ActivityMedtrumBinding>() {
PatchStep.ATTACH_PATCH -> setupViewFragment(MedtrumAttachPatchFragment.newInstance())
PatchStep.ACTIVATE -> setupViewFragment(MedtrumActivateFragment.newInstance())
PatchStep.ACTIVATE_COMPLETE -> setupViewFragment(MedtrumActivateCompleteFragment.newInstance())
PatchStep.ERROR -> Unit // Do nothing, let activity handle this
PatchStep.RETRY_ACTIVATION -> setupViewFragment(MedtrumRetryActivationFragment.newInstance())
PatchStep.RETRY_ACTIVATION_CONNECT -> setupViewFragment(MedtrumRetryActivationConnectFragment.newInstance())
PatchStep.START_DEACTIVATION -> setupViewFragment(MedtrumStartDeactivationFragment.newInstance())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class MedtrumDeactivatePatchFragment : MedtrumBaseFragment<FragmentMedtrumDeacti
}

MedtrumViewModel.SetupStep.ERROR -> {
moveStep(PatchStep.ERROR)
updateSetupStep(MedtrumViewModel.SetupStep.START_DEACTIVATION) // Reset setup step
binding.textDeactivatingPump.text = rh.gs(R.string.deactivating_error)
binding.btnNegative.visibility = View.VISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class MedtrumPrimingFragment : MedtrumBaseFragment<FragmentMedtrumPrimingBinding
MedtrumViewModel.SetupStep.PRIMED -> moveStep(PatchStep.PRIME_COMPLETE)

MedtrumViewModel.SetupStep.ERROR -> {
moveStep(PatchStep.ERROR)
updateSetupStep(MedtrumViewModel.SetupStep.FILLED) // Reset setup step
binding.textWaitForPriming.text = rh.gs(R.string.priming_error)
binding.btnNegative.visibility = View.VISIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import info.nightscout.pump.medtrum.R
import info.nightscout.pump.medtrum.code.ConnectionState
import info.nightscout.pump.medtrum.code.EventType
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
import info.nightscout.pump.medtrum.comm.enums.ModelType
import info.nightscout.pump.medtrum.ui.MedtrumBaseNavigator
import info.nightscout.pump.medtrum.ui.event.SingleLiveEvent
import info.nightscout.pump.medtrum.ui.event.UIEvent
Expand Down Expand Up @@ -199,7 +200,7 @@ class MedtrumOverviewViewModel @Inject constructor(

val activeAlarmStrings = medtrumPump.activeAlarms.map { medtrumPump.alarmStateToString(it) }
_activeAlarms.postValue(activeAlarmStrings.joinToString("\n"))
_pumpType.postValue(medtrumPump.deviceType.toString())
_pumpType.postValue(ModelType.fromValue(medtrumPump.deviceType).toString())
_fwVersion.postValue(medtrumPump.swVersion)
_patchNo.postValue(medtrumPump.patchId.toString())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ class MedtrumViewModel @Inject constructor(
PatchStep.CANCEL,
PatchStep.COMPLETE,
PatchStep.ACTIVATE_COMPLETE,
PatchStep.ERROR,
PatchStep.START_DEACTIVATION,
PatchStep.DEACTIVATE,
PatchStep.FORCE_DEACTIVATION,
Expand Down Expand Up @@ -307,7 +306,6 @@ class MedtrumViewModel @Inject constructor(

PatchStep.COMPLETE,
PatchStep.FORCE_DEACTIVATION,
PatchStep.ERROR,
PatchStep.CANCEL -> _title.value
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
package info.nightscout.pump.medtrum.util

import info.nightscout.pump.medtrum.comm.enums.ModelType
import info.nightscout.pump.medtrum.encryption.Crypt

class MedtrumSnUtil {

companion object {

const val INVALID = -1
const val MD_0201 = 80
const val MD_5201 = 81
const val MD_0202 = 82
const val MD_5202 = 83
const val MD_8201 = 88
const val MD_8301 = 98
}

fun getDeviceTypeFromSerial(serial: Long): Int {
fun getDeviceTypeFromSerial(serial: Long): ModelType {
if (serial in 106000000..106999999) {
return INVALID
return ModelType.INVALID
}

return when (Crypt().simpleDecrypt(serial)) {
in 126000000..126999999 -> MD_0201
in 127000000..127999999 -> MD_5201
in 128000000..128999999 -> MD_8201
in 130000000..130999999 -> MD_0202
in 131000000..131999999 -> MD_5202
in 148000000..148999999 -> MD_8301
else -> INVALID
in 126000000..126999999 -> ModelType.MD0201
in 127000000..127999999 -> ModelType.MD5201
in 128000000..128999999 -> ModelType.MD8201
in 130000000..130999999 -> ModelType.MD0202
in 131000000..131999999 -> ModelType.MD5202
in 148000000..148999999 -> ModelType.MD8301
else -> ModelType.INVALID
}
}
}
3 changes: 1 addition & 2 deletions pump/medtrum/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
<string name="alarm_expired">Expired</string>
<string name="alarm_reservoir_empty">Reservoir empty</string>
<string name="alarm_patch_fault">Patch fault</string>
<string name="alarm_patch_fault2">Patch fault 2</string>
<string name="alarm_base_fault">Base fault</string>
<string name="alarm_battery_out">Battery out</string>
<string name="alarm_no_calibration">No calibration</string>
Expand Down Expand Up @@ -142,7 +141,7 @@
<string name="sn_input_title">Serial Number</string>
<string name="sn_input_summary">Enter the serial number of your pump base.</string>
<string name="sn_input_invalid">Invalid serial number!</string>
<string name="pump_unsupported">Pump untested: %1$d! Please contact us at discord or github for support</string>
<string name="pump_unsupported">Pump untested: %1$s! Please contact us at discord or github for support</string>
<string name="alarm_setting_title">Alarm Settings</string>
<string name="alarm_setting_summary">Select your preferred pump alarm settings.</string>
<string name="pump_warning_notification_title">Notification on pump warning</string>
Expand Down

0 comments on commit 5d3e33c

Please sign in to comment.