Medtrum: Prevent activation when no serial number is entered
This commit is contained in:
parent
98daf4b12f
commit
f2021c7baa
4 changed files with 14 additions and 2 deletions
|
@ -3,5 +3,6 @@ package info.nightscout.pump.medtrum.code
|
|||
enum class EventType {
|
||||
CHANGE_PATCH_CLICKED,
|
||||
PROFILE_NOT_SET,
|
||||
SERIAL_NOT_SET
|
||||
;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.pump.medtrum.ui
|
|||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import info.nightscout.core.ui.toast.ToastUtils
|
||||
import info.nightscout.core.ui.dialogs.OKDialog
|
||||
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||
import info.nightscout.pump.medtrum.MedtrumPump
|
||||
import info.nightscout.pump.medtrum.databinding.FragmentMedtrumOverviewBinding
|
||||
|
@ -14,6 +14,7 @@ import info.nightscout.pump.medtrum.code.PatchStep
|
|||
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -23,6 +24,7 @@ class MedtrumOverviewFragment : MedtrumBaseFragment<FragmentMedtrumOverviewBindi
|
|||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var medtrumPump: MedtrumPump
|
||||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
|
@ -64,7 +66,13 @@ class MedtrumOverviewFragment : MedtrumBaseFragment<FragmentMedtrumOverviewBindi
|
|||
)
|
||||
}
|
||||
|
||||
EventType.PROFILE_NOT_SET -> ToastUtils.infoToast(requireContext(), R.string.no_profile_selected)
|
||||
EventType.PROFILE_NOT_SET -> {
|
||||
OKDialog.show(requireActivity(), rh.gs(info.nightscout.core.ui.R.string.message), rh.gs(R.string.no_profile_selected))
|
||||
}
|
||||
|
||||
EventType.SERIAL_NOT_SET -> {
|
||||
OKDialog.show(requireActivity(), rh.gs(info.nightscout.core.ui.R.string.message), rh.gs(R.string.no_sn_in_settings))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,6 +167,8 @@ class MedtrumOverviewViewModel @Inject constructor(
|
|||
val profile = profileFunction.getProfile()
|
||||
if (profile == null) {
|
||||
_eventHandler.postValue(UIEvent(EventType.PROFILE_NOT_SET))
|
||||
} else if (medtrumPump.pumpSN == 0L){
|
||||
_eventHandler.postValue(UIEvent(EventType.SERIAL_NOT_SET))
|
||||
} else {
|
||||
_eventHandler.postValue(UIEvent(EventType.CHANGE_PATCH_CLICKED))
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@
|
|||
<string name="step_retry_activation">Activation in progress</string>
|
||||
<string name="unexpected_state">Unexpected state: %1$s</string>
|
||||
<string name="no_profile_selected">No profile selected. Please select a profile and try again.</string>
|
||||
<string name="no_sn_in_settings">No serial number known. Please enter pumpbase serial number in settings and try again.</string>
|
||||
|
||||
<string name="base_serial">Pump Base Serial: %1$X</string>
|
||||
<string name="patch_begin_activation">No active patch. Press <b>Next</b> to begin the activation process.</string>
|
||||
|
|
Loading…
Reference in a new issue