resolve PH flag, remove sync from NS menu

This commit is contained in:
Milos Kozak 2023-09-22 17:03:53 +02:00
parent 2707ff8ed3
commit ccabee0399
10 changed files with 71 additions and 169 deletions

View file

@ -2,6 +2,7 @@ package info.nightscout.implementation.db
import android.content.Context import android.content.Context
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.BolusCalculatorResult
import info.nightscout.database.entities.Carbs import info.nightscout.database.entities.Carbs
import info.nightscout.database.entities.DeviceStatus import info.nightscout.database.entities.DeviceStatus
import info.nightscout.database.entities.EffectiveProfileSwitch import info.nightscout.database.entities.EffectiveProfileSwitch
@ -76,6 +77,11 @@ class CompatDBHelper @Inject constructor(
rxBus.send(EventTreatmentChange()) rxBus.send(EventTreatmentChange())
rxBus.send(EventNewHistoryData(timestamp, false)) rxBus.send(EventNewHistoryData(timestamp, false))
} }
it.filterIsInstance<BolusCalculatorResult>().minOfOrNull { t -> t.timestamp }?.let { timestamp ->
aapsLogger.debug(LTag.DATABASE, "Firing EventTreatmentChange $timestamp")
rxBus.send(EventTreatmentChange())
rxBus.send(EventNewHistoryData(timestamp, false))
}
it.filterIsInstance<TemporaryBasal>().minOfOrNull { t -> t.timestamp }?.let { timestamp -> it.filterIsInstance<TemporaryBasal>().minOfOrNull { t -> t.timestamp }?.let { timestamp ->
aapsLogger.debug(LTag.DATABASE, "Firing EventTempBasalChange $timestamp") aapsLogger.debug(LTag.DATABASE, "Firing EventTempBasalChange $timestamp")
rxBus.send(EventTempBasalChange()) rxBus.send(EventTempBasalChange())

View file

@ -10,6 +10,7 @@ import info.nightscout.core.extensions.plannedRemainingMinutes
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.fabric.InstanceId import info.nightscout.core.utils.fabric.InstanceId
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.db.PersistenceLayer
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.notifications.Notification import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
@ -64,7 +65,8 @@ open class VirtualPumpPlugin @Inject constructor(
private val pumpSync: PumpSync, private val pumpSync: PumpSync,
private val config: Config, private val config: Config,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val processedDeviceStatusData: ProcessedDeviceStatusData private val processedDeviceStatusData: ProcessedDeviceStatusData,
private val persistenceLayer: PersistenceLayer
) : PumpPluginBase( ) : PumpPluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.PUMP) .mainType(PluginType.PUMP)
@ -207,23 +209,19 @@ open class VirtualPumpPlugin @Inject constructor(
aapsLogger.debug(LTag.PUMP, "Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result) aapsLogger.debug(LTag.PUMP, "Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result)
rxBus.send(EventVirtualPumpUpdateGui()) rxBus.send(EventVirtualPumpUpdateGui())
lastDataTime = System.currentTimeMillis() lastDataTime = System.currentTimeMillis()
if (detailedBolusInfo.insulin > 0) if (detailedBolusInfo.insulin > 0) {
pumpSync.syncBolusWithPumpId( if (config.NSCLIENT) // do not store pump serial (record will not be marked PH)
timestamp = detailedBolusInfo.timestamp, persistenceLayer.insertOrUpdateBolus(detailedBolusInfo.createBolus())
amount = detailedBolusInfo.insulin, else
type = detailedBolusInfo.bolusType, pumpSync.syncBolusWithPumpId(
pumpId = dateUtil.now(), timestamp = detailedBolusInfo.timestamp,
pumpType = pumpType ?: PumpType.GENERIC_AAPS, amount = detailedBolusInfo.insulin,
pumpSerial = serialNumber() type = detailedBolusInfo.bolusType,
) pumpId = dateUtil.now(),
if (detailedBolusInfo.carbs > 0) pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSync.syncCarbsWithTimestamp( pumpSerial = serialNumber()
timestamp = detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp, )
amount = detailedBolusInfo.carbs, }
pumpId = null,
pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber()
)
return result return result
} }

View file

@ -39,8 +39,6 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNSClientRestart
import info.nightscout.rx.events.EventNewHistoryData
import info.nightscout.rx.events.EventTreatmentChange import info.nightscout.rx.events.EventTreatmentChange
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -54,10 +52,8 @@ 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 info.nightscout.ui.extensions.isPumpHistory
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
import io.reactivex.rxjava3.kotlin.subscribeBy
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import javax.inject.Inject import javax.inject.Inject
@ -212,6 +208,18 @@ class TreatmentsBolusCarbsFragment : DaggerFragment(), MenuProvider {
holder.binding.metadataLayout.visibility = (ml.bolusCalculatorResult != null && (ml.bolusCalculatorResult.isValid || showInvalidated)).toVisibility() holder.binding.metadataLayout.visibility = (ml.bolusCalculatorResult != null && (ml.bolusCalculatorResult.isValid || showInvalidated)).toVisibility()
ml.bolusCalculatorResult?.let { bolusCalculatorResult -> ml.bolusCalculatorResult?.let { bolusCalculatorResult ->
holder.binding.calcTime.text = dateUtil.timeString(bolusCalculatorResult.timestamp) holder.binding.calcTime.text = dateUtil.timeString(bolusCalculatorResult.timestamp)
holder.binding.metadataNs.visibility = (bolusCalculatorResult.interfaceIDs.nightscoutId != null).toVisibility()
holder.binding.cbMetadataRemove.visibility = (bolusCalculatorResult.isValid && actionHelper.isRemoving).toVisibility()
if (actionHelper.isRemoving) {
holder.binding.cbMetadataRemove.setOnCheckedChangeListener { _, value ->
actionHelper.updateSelection(position, ml, value)
}
holder.binding.root.setOnClickListener {
holder.binding.cbMetadataRemove.toggle()
actionHelper.updateSelection(position, ml, holder.binding.cbMetadataRemove.isChecked)
}
holder.binding.cbMetadataRemove.isChecked = actionHelper.isSelected(position)
}
} }
// Bolus // Bolus
@ -310,8 +318,6 @@ class TreatmentsBolusCarbsFragment : DaggerFragment(), MenuProvider {
this.menu = menu this.menu = menu
inflater.inflate(R.menu.menu_treatments_carbs_bolus, menu) inflater.inflate(R.menu.menu_treatments_carbs_bolus, menu)
updateMenuVisibility() updateMenuVisibility()
val nsUploadOnly = !sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_insulin, false) || !sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_carbs, false) || !config.isEngineeringMode()
menu.findItem(R.id.nav_refresh_ns)?.isVisible = !nsUploadOnly
val hasItems = (binding.recyclerview.adapter?.itemCount ?: 0) > 0 val hasItems = (binding.recyclerview.adapter?.itemCount ?: 0) > 0
menu.findItem(R.id.nav_delete_future)?.isVisible = hasItems menu.findItem(R.id.nav_delete_future)?.isVisible = hasItems
} }
@ -346,38 +352,9 @@ class TreatmentsBolusCarbsFragment : DaggerFragment(), MenuProvider {
true true
} }
R.id.nav_refresh_ns -> {
refreshFromNightscout()
true
}
else -> false else -> false
} }
private fun refreshFromNightscout() {
activity?.let { activity ->
OKDialog.showConfirmation(activity, rh.gs(R.string.refresheventsfromnightscout) + "?") {
uel.log(Action.TREATMENTS_NS_REFRESH, Sources.Treatments)
disposable +=
Completable.fromAction {
repository.deleteAllBolusCalculatorResults()
repository.deleteAllBoluses()
repository.deleteAllCarbs()
}
.subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.main)
.subscribeBy(
onError = { aapsLogger.error("Error removing entries", it) },
onComplete = {
rxBus.send(EventTreatmentChange())
rxBus.send(EventNewHistoryData(0, false))
}
)
rxBus.send(EventNSClientRestart())
}
}
}
private fun deleteFutureTreatments() { private fun deleteFutureTreatments() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, rh.gs(info.nightscout.core.ui.R.string.overview_treatment_label), rh.gs(info.nightscout.core.ui.R.string.delete_future_treatments) + "?", Runnable { OKDialog.showConfirmation(activity, rh.gs(info.nightscout.core.ui.R.string.overview_treatment_label), rh.gs(info.nightscout.core.ui.R.string.delete_future_treatments) + "?", Runnable {
@ -476,6 +453,17 @@ class TreatmentsBolusCarbsFragment : DaggerFragment(), MenuProvider {
{ aapsLogger.error(LTag.DATABASE, "Error while invalidating carbs", it) } { aapsLogger.error(LTag.DATABASE, "Error while invalidating carbs", it) }
) )
} }
ml.bolusCalculatorResult?.let { bolusCalculatorResult ->
uel.log(
Action.BOLUS_CALCULATOR_RESULT_REMOVED, Sources.Treatments,
ValueWithUnit.Timestamp(bolusCalculatorResult.timestamp)
)
disposable += repository.runTransactionForResult(InvalidateBolusCalculatorResultTransaction(bolusCalculatorResult.id))
.subscribe(
{ result -> result.invalidated.forEach { aapsLogger.debug(LTag.DATABASE, "Invalidated bolusCalculatorResult $it") } },
{ aapsLogger.error(LTag.DATABASE, "Error while invalidating bolusCalculatorResult", it) }
)
}
} }
actionHelper.finish() actionHelper.finish()
}) })

View file

@ -30,7 +30,6 @@ import info.nightscout.interfaces.Translator
import info.nightscout.interfaces.logging.UserEntryLogger import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNSClientRestart
import info.nightscout.rx.events.EventTherapyEventChange import info.nightscout.rx.events.EventTherapyEventChange
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -43,10 +42,8 @@ import info.nightscout.ui.R
import info.nightscout.ui.activities.fragments.TreatmentsCareportalFragment.RecyclerViewAdapter.TherapyEventsViewHolder import info.nightscout.ui.activities.fragments.TreatmentsCareportalFragment.RecyclerViewAdapter.TherapyEventsViewHolder
import info.nightscout.ui.databinding.TreatmentsCareportalFragmentBinding import info.nightscout.ui.databinding.TreatmentsCareportalFragmentBinding
import info.nightscout.ui.databinding.TreatmentsCareportalItemBinding import info.nightscout.ui.databinding.TreatmentsCareportalItemBinding
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
import io.reactivex.rxjava3.kotlin.subscribeBy
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import javax.inject.Inject import javax.inject.Inject
@ -89,21 +86,6 @@ class TreatmentsCareportalFragment : DaggerFragment(), MenuProvider {
requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED) requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED)
} }
private fun refreshFromNightscout() {
activity?.let { activity ->
OKDialog.showConfirmation(activity, rh.gs(info.nightscout.core.ui.R.string.careportal), rh.gs(R.string.refresheventsfromnightscout) + " ?", Runnable {
uel.log(Action.CAREPORTAL_NS_REFRESH, Sources.Treatments)
disposable += Completable.fromAction { repository.deleteAllTherapyEventsEntries() }
.subscribeOn(aapsSchedulers.io)
.subscribeBy(
onError = { aapsLogger.error("Error removing entries", it) },
onComplete = { rxBus.send(EventTherapyEventChange()) }
)
rxBus.send(EventNSClientRestart())
})
}
}
private fun removeStartedEvents() { private fun removeStartedEvents() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, rh.gs(info.nightscout.core.ui.R.string.careportal), rh.gs(R.string.careportal_remove_started_events), Runnable { OKDialog.showConfirmation(activity, rh.gs(info.nightscout.core.ui.R.string.careportal), rh.gs(R.string.careportal_remove_started_events), Runnable {
@ -200,8 +182,6 @@ class TreatmentsCareportalFragment : DaggerFragment(), MenuProvider {
this.menu = menu this.menu = menu
inflater.inflate(R.menu.menu_treatments_careportal, menu) inflater.inflate(R.menu.menu_treatments_careportal, menu)
updateMenuVisibility() updateMenuVisibility()
val nsUploadOnly = !sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_therapy_events, false) || !config.isEngineeringMode()
menu.findItem(R.id.nav_refresh_ns)?.isVisible = !nsUploadOnly
} }
private fun updateMenuVisibility() { private fun updateMenuVisibility() {
@ -234,11 +214,6 @@ class TreatmentsCareportalFragment : DaggerFragment(), MenuProvider {
true true
} }
R.id.nav_refresh_ns -> {
refreshFromNightscout()
true
}
else -> false else -> false
} }

View file

@ -36,8 +36,6 @@ import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventEffectiveProfileSwitchChanged import info.nightscout.rx.events.EventEffectiveProfileSwitchChanged
import info.nightscout.rx.events.EventLocalProfileChanged import info.nightscout.rx.events.EventLocalProfileChanged
import info.nightscout.rx.events.EventNSClientRestart
import info.nightscout.rx.events.EventNewHistoryData
import info.nightscout.rx.events.EventProfileSwitchChanged import info.nightscout.rx.events.EventProfileSwitchChanged
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -51,10 +49,8 @@ import info.nightscout.ui.activities.fragments.TreatmentsProfileSwitchFragment.R
import info.nightscout.ui.databinding.TreatmentsProfileswitchFragmentBinding import info.nightscout.ui.databinding.TreatmentsProfileswitchFragmentBinding
import info.nightscout.ui.databinding.TreatmentsProfileswitchItemBinding import info.nightscout.ui.databinding.TreatmentsProfileswitchItemBinding
import info.nightscout.ui.dialogs.ProfileViewerDialog import info.nightscout.ui.dialogs.ProfileViewerDialog
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
import io.reactivex.rxjava3.kotlin.subscribeBy
import javax.inject.Inject import javax.inject.Inject
class TreatmentsProfileSwitchFragment : DaggerFragment(), MenuProvider { class TreatmentsProfileSwitchFragment : DaggerFragment(), MenuProvider {
@ -98,30 +94,6 @@ class TreatmentsProfileSwitchFragment : DaggerFragment(), MenuProvider {
requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED) requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED)
} }
private fun refreshFromNightscout() {
activity?.let { activity ->
OKDialog.showConfirmation(activity, rh.gs(R.string.refresheventsfromnightscout) + "?") {
uel.log(Action.TREATMENTS_NS_REFRESH, Sources.Treatments)
disposable +=
Completable.fromAction {
repository.deleteAllEffectiveProfileSwitches()
repository.deleteAllProfileSwitches()
}
.subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.main)
.subscribeBy(
onError = { aapsLogger.error("Error removing entries", it) },
onComplete = {
rxBus.send(EventProfileSwitchChanged())
rxBus.send(EventEffectiveProfileSwitchChanged(0L))
rxBus.send(EventNewHistoryData(0, false))
}
)
rxBus.send(EventNSClientRestart())
}
}
}
private fun profileSwitchWithInvalid(now: Long) = repository private fun profileSwitchWithInvalid(now: Long) = repository
.getProfileSwitchDataIncludingInvalidFromTime(now - millsToThePast, false) .getProfileSwitchDataIncludingInvalidFromTime(now - millsToThePast, false)
.map { bolus -> bolus.map { ProfileSealed.PS(it) } } .map { bolus -> bolus.map { ProfileSealed.PS(it) } }
@ -286,8 +258,6 @@ class TreatmentsProfileSwitchFragment : DaggerFragment(), MenuProvider {
this.menu = menu this.menu = menu
inflater.inflate(R.menu.menu_treatments_profile_switch, menu) inflater.inflate(R.menu.menu_treatments_profile_switch, menu)
updateMenuVisibility() updateMenuVisibility()
val nsUploadOnly = !sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_profile_switch, false) || !config.isEngineeringMode()
menu.findItem(R.id.nav_refresh_ns)?.isVisible = !nsUploadOnly
} }
private fun updateMenuVisibility() { private fun updateMenuVisibility() {
@ -315,18 +285,15 @@ class TreatmentsProfileSwitchFragment : DaggerFragment(), MenuProvider {
true true
} }
R.id.nav_refresh_ns -> {
refreshFromNightscout()
true
}
else -> false else -> false
} }
private fun getConfirmationText(selectedItems: SparseArray<ProfileSealed>): String { private fun getConfirmationText(selectedItems: SparseArray<ProfileSealed>): String {
if (selectedItems.size() == 1) { if (selectedItems.size() == 1) {
val profileSwitch = selectedItems.valueAt(0) val profileSwitch = selectedItems.valueAt(0)
return rh.gs(info.nightscout.core.ui.R.string.careportal_profileswitch) + ": " + profileSwitch.profileName + "\n" + rh.gs(info.nightscout.core.ui.R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.timestamp) return rh.gs(info.nightscout.core.ui.R.string.careportal_profileswitch) + ": " + profileSwitch.profileName + "\n" + rh.gs(info.nightscout.core.ui.R.string.date) + ": " + dateUtil.dateAndTimeString(
profileSwitch.timestamp
)
} }
return rh.gs(info.nightscout.core.ui.R.string.confirm_remove_multiple_items, selectedItems.size()) return rh.gs(info.nightscout.core.ui.R.string.confirm_remove_multiple_items, selectedItems.size())
} }

View file

@ -36,10 +36,6 @@ import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventEffectiveProfileSwitchChanged
import info.nightscout.rx.events.EventNSClientRestart
import info.nightscout.rx.events.EventNewHistoryData
import info.nightscout.rx.events.EventProfileSwitchChanged
import info.nightscout.rx.events.EventTempTargetChange import info.nightscout.rx.events.EventTempTargetChange
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag import info.nightscout.rx.logging.LTag
@ -53,10 +49,8 @@ import info.nightscout.ui.R
import info.nightscout.ui.activities.fragments.TreatmentsTempTargetFragment.RecyclerViewAdapter.TempTargetsViewHolder import info.nightscout.ui.activities.fragments.TreatmentsTempTargetFragment.RecyclerViewAdapter.TempTargetsViewHolder
import info.nightscout.ui.databinding.TreatmentsTemptargetFragmentBinding import info.nightscout.ui.databinding.TreatmentsTemptargetFragmentBinding
import info.nightscout.ui.databinding.TreatmentsTemptargetItemBinding import info.nightscout.ui.databinding.TreatmentsTemptargetItemBinding
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
import io.reactivex.rxjava3.kotlin.subscribeBy
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import javax.inject.Inject import javax.inject.Inject
@ -101,29 +95,6 @@ class TreatmentsTempTargetFragment : DaggerFragment(), MenuProvider {
requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED) requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED)
} }
private fun refreshFromNightscout() {
activity?.let { activity ->
OKDialog.showConfirmation(activity, rh.gs(R.string.refresheventsfromnightscout) + "?") {
uel.log(Action.TREATMENTS_NS_REFRESH, Sources.Treatments)
disposable +=
Completable.fromAction {
repository.deleteAllTempTargetEntries()
}
.subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.main)
.subscribeBy(
onError = { aapsLogger.error("Error removing entries", it) },
onComplete = {
rxBus.send(EventProfileSwitchChanged())
rxBus.send(EventEffectiveProfileSwitchChanged(0L))
rxBus.send(EventNewHistoryData(0, false))
}
)
rxBus.send(EventNSClientRestart())
}
}
}
private fun swapAdapter() { private fun swapAdapter() {
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
binding.recyclerview.isLoading = true binding.recyclerview.isLoading = true
@ -220,8 +191,6 @@ class TreatmentsTempTargetFragment : DaggerFragment(), MenuProvider {
this.menu = menu this.menu = menu
inflater.inflate(R.menu.menu_treatments_temp_target, menu) inflater.inflate(R.menu.menu_treatments_temp_target, menu)
updateMenuVisibility() updateMenuVisibility()
val nsUploadOnly = !sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_temp_target, false) || !config.isEngineeringMode()
menu.findItem(R.id.nav_refresh_ns)?.isVisible = !nsUploadOnly
} }
private fun updateMenuVisibility() { private fun updateMenuVisibility() {
@ -249,11 +218,6 @@ class TreatmentsTempTargetFragment : DaggerFragment(), MenuProvider {
true true
} }
R.id.nav_refresh_ns -> {
refreshFromNightscout()
true
}
else -> false else -> false
} }

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
style="@style/Widget.MaterialComponents.CardView" style="@style/Widget.MaterialComponents.CardView"
@ -66,12 +65,33 @@
android:id="@+id/calculation" android:id="@+id/calculation"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text="@string/calculation_short" android:text="@string/calculation_short"
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:textColor="@color/colorCalculatorButton" android:textColor="@color/colorCalculatorButton"
tools:ignore="RtlSymmetry" /> tools:ignore="RtlSymmetry" />
<TextView
android:id="@+id/metadata_ns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:textColor="?attr/setTempButton"
android:text="NS"
tools:ignore="HardcodedText" />
<CheckBox
android:id="@+id/cb_metadata_remove"
android:layout_width="wrap_content"
android:layout_height="19dp"
android:contentDescription="@string/select_for_removal"
android:minWidth="0dp"
android:visibility="gone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

View file

@ -23,10 +23,4 @@
android:id="@+id/nav_delete_future" android:id="@+id/nav_delete_future"
android:title="@string/delete_future_treatments" android:title="@string/delete_future_treatments"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/nav_refresh_ns"
android:title="@string/refresh_from_nightscout"
app:showAsAction="never" />
</menu> </menu>

View file

@ -19,11 +19,6 @@
android:title="@string/hide_invalidated" android:title="@string/hide_invalidated"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item
android:id="@+id/nav_refresh_ns"
android:title="@string/refresh_from_nightscout"
app:showAsAction="never" />
<item <item
android:id="@+id/nav_remove_started_events" android:id="@+id/nav_remove_started_events"
android:title="@string/careportal_remove_started_events" android:title="@string/careportal_remove_started_events"

View file

@ -19,9 +19,4 @@
android:icon="@drawable/ic_visibility_off" android:icon="@drawable/ic_visibility_off"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item
android:id="@+id/nav_refresh_ns"
android:title="@string/refresh_from_nightscout"
app:showAsAction="never" />
</menu> </menu>