Show PH values properly

This commit is contained in:
Milos Kozak 2023-09-16 20:52:16 +02:00
parent d379b769d3
commit 275e52a546
3 changed files with 31 additions and 2 deletions

View file

@ -53,6 +53,7 @@ import info.nightscout.ui.R
import info.nightscout.ui.databinding.TreatmentsBolusCarbsFragmentBinding import info.nightscout.ui.databinding.TreatmentsBolusCarbsFragmentBinding
import info.nightscout.ui.databinding.TreatmentsBolusCarbsItemBinding import info.nightscout.ui.databinding.TreatmentsBolusCarbsItemBinding
import info.nightscout.ui.dialogs.WizardInfoDialog import info.nightscout.ui.dialogs.WizardInfoDialog
import info.nightscout.ui.extensions.isPumpHistory
import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign import io.reactivex.rxjava3.kotlin.plusAssign
@ -219,7 +220,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment(), MenuProvider {
holder.binding.bolusTime.text = dateUtil.timeString(bolus.timestamp) holder.binding.bolusTime.text = dateUtil.timeString(bolus.timestamp)
holder.binding.insulin.text = rh.gs(info.nightscout.interfaces.R.string.format_insulin_units, bolus.amount) holder.binding.insulin.text = rh.gs(info.nightscout.interfaces.R.string.format_insulin_units, bolus.amount)
holder.binding.bolusNs.visibility = (bolus.interfaceIDs.nightscoutId != null).toVisibility() holder.binding.bolusNs.visibility = (bolus.interfaceIDs.nightscoutId != null).toVisibility()
holder.binding.bolusPump.visibility = (bolus.interfaceIDs.pumpId != null).toVisibility() holder.binding.bolusPump.visibility = bolus.interfaceIDs.isPumpHistory().toVisibility()
holder.binding.bolusInvalid.visibility = bolus.isValid.not().toVisibility() holder.binding.bolusInvalid.visibility = bolus.isValid.not().toVisibility()
val iob = bolus.iobCalc(activePlugin, System.currentTimeMillis(), profile.dia) val iob = bolus.iobCalc(activePlugin, System.currentTimeMillis(), profile.dia)
if (iob.iobContrib > 0.01) { if (iob.iobContrib > 0.01) {
@ -260,7 +261,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment(), MenuProvider {
holder.binding.carbs.text = rh.gs(info.nightscout.core.graph.R.string.format_carbs, carbs.amount.toInt()) holder.binding.carbs.text = rh.gs(info.nightscout.core.graph.R.string.format_carbs, carbs.amount.toInt())
holder.binding.carbsDuration.text = if (carbs.duration > 0) rh.gs(info.nightscout.core.ui.R.string.format_mins, T.msecs(carbs.duration).mins().toInt()) else "" holder.binding.carbsDuration.text = if (carbs.duration > 0) rh.gs(info.nightscout.core.ui.R.string.format_mins, T.msecs(carbs.duration).mins().toInt()) else ""
holder.binding.carbsNs.visibility = (carbs.interfaceIDs.nightscoutId != null).toVisibility() holder.binding.carbsNs.visibility = (carbs.interfaceIDs.nightscoutId != null).toVisibility()
holder.binding.carbsPump.visibility = (carbs.interfaceIDs.pumpId != null).toVisibility() holder.binding.carbsPump.visibility = carbs.interfaceIDs.isPumpHistory().toVisibility()
holder.binding.carbsInvalid.visibility = carbs.isValid.not().toVisibility() holder.binding.carbsInvalid.visibility = carbs.isValid.not().toVisibility()
holder.binding.cbCarbsRemove.visibility = (ml.carbs.isValid && actionHelper.isRemoving).toVisibility() holder.binding.cbCarbsRemove.visibility = (ml.carbs.isValid && actionHelper.isRemoving).toVisibility()
if (actionHelper.isRemoving) { if (actionHelper.isRemoving) {

View file

@ -0,0 +1,5 @@
package info.nightscout.ui.extensions
import info.nightscout.database.entities.embedments.InterfaceIDs
fun InterfaceIDs.isPumpHistory() = pumpSerial != null && pumpId != null

View file

@ -0,0 +1,23 @@
package info.nightscout.ui.extensions
import com.google.common.truth.Truth.assertThat
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Test
class InterfaceIDsExtensionKtTest : TestBase() {
@Test
fun isPumpHistory() {
val sut = InterfaceIDs()
assertThat(sut.isPumpHistory()).isFalse()
sut.pumpId = 123
assertThat(sut.isPumpHistory()).isFalse()
sut.pumpId = null
sut.pumpSerial = "123"
assertThat(sut.isPumpHistory()).isFalse()
sut.pumpId = 123
sut.pumpSerial = "123"
assertThat(sut.isPumpHistory()).isTrue()
}
}