diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumActivateCompleteFragment.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumActivateCompleteFragment.kt index ef9a94ca16..7334fee5fb 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumActivateCompleteFragment.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumActivateCompleteFragment.kt @@ -5,18 +5,17 @@ import android.view.View import androidx.lifecycle.ViewModelProvider import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.pump.medtrum.R -import info.nightscout.pump.medtrum.code.PatchStep -import info.nightscout.pump.medtrum.databinding.FragmentMedtrumActivateBinding import info.nightscout.pump.medtrum.databinding.FragmentMedtrumActivateCompleteBinding -import info.nightscout.pump.medtrum.ui.MedtrumBaseFragment import info.nightscout.pump.medtrum.ui.viewmodel.MedtrumViewModel import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag +import info.nightscout.shared.interfaces.ResourceHelper import javax.inject.Inject class MedtrumActivateCompleteFragment : MedtrumBaseFragment() { @Inject lateinit var aapsLogger: AAPSLogger + @Inject lateinit var rh: ResourceHelper companion object { @@ -36,13 +35,8 @@ class MedtrumActivateCompleteFragment : MedtrumBaseFragment Unit // Nothing to do here, previous state MedtrumViewModel.SetupStep.ACTIVATED -> btnPositive.visibility = View.VISIBLE - MedtrumViewModel.SetupStep.ERROR -> { - ToastUtils.errorToast(requireContext(), "Error Activating") // TODO: String resource and show error message - moveStep(PatchStep.CANCEL) - } - else -> { - ToastUtils.errorToast(requireContext(), "Unexpected state: $it") // TODO: String resource and show error message + ToastUtils.errorToast(requireContext(), rh.gs(R.string.unexpected_state, it.toString())) aapsLogger.error(LTag.PUMP, "Unexpected state: $it") } } diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumActivateFragment.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumActivateFragment.kt index 2af09f86a5..fe417c338d 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumActivateFragment.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumActivateFragment.kt @@ -7,7 +7,6 @@ import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.pump.medtrum.R import info.nightscout.pump.medtrum.code.PatchStep import info.nightscout.pump.medtrum.databinding.FragmentMedtrumActivateBinding -import info.nightscout.pump.medtrum.ui.MedtrumBaseFragment import info.nightscout.pump.medtrum.ui.viewmodel.MedtrumViewModel import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumActivity.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumActivity.kt index 2534cb253b..458f1ee13e 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumActivity.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumActivity.kt @@ -1,27 +1,12 @@ package info.nightscout.pump.medtrum.ui -import android.app.Dialog import android.content.Context import android.content.Intent import android.content.pm.ActivityInfo -import android.media.MediaPlayer -import android.media.RingtoneManager import android.os.Bundle import android.view.MotionEvent import android.view.WindowManager -import androidx.appcompat.app.AlertDialog import androidx.lifecycle.ViewModelProvider -import info.nightscout.pump.medtrum.ui.MedtrumActivateCompleteFragment -import info.nightscout.pump.medtrum.ui.MedtrumActivateFragment -import info.nightscout.pump.medtrum.ui.MedtrumAttachPatchFragment -import info.nightscout.pump.medtrum.ui.MedtrumDeactivatePatchFragment -import info.nightscout.pump.medtrum.ui.MedtrumDeactivationCompleteFragment -import info.nightscout.pump.medtrum.ui.MedtrumPreparePatchConnectFragment -import info.nightscout.pump.medtrum.ui.MedtrumPreparePatchFragment -import info.nightscout.pump.medtrum.ui.MedtrumPrimeCompleteFragment -import info.nightscout.pump.medtrum.ui.MedtrumPrimeFragment -import info.nightscout.pump.medtrum.ui.MedtrumPrimingFragment -import info.nightscout.pump.medtrum.ui.MedtrumStartDeactivationFragment import info.nightscout.core.utils.extensions.safeGetSerializableExtra import info.nightscout.pump.medtrum.R import info.nightscout.pump.medtrum.code.PatchStep @@ -35,10 +20,6 @@ class MedtrumActivity : MedtrumBaseActivity() { override fun getLayoutId(): Int = R.layout.activity_medtrum override fun dispatchTouchEvent(event: MotionEvent): Boolean { - if (event.actionMasked == MotionEvent.ACTION_UP) { - // TODO - } - return super.dispatchTouchEvent(event) } @@ -106,12 +87,11 @@ class MedtrumActivity : MedtrumBaseActivity() { override fun onDestroy() { super.onDestroy() - // TODO } override fun onBackPressed() { binding.viewModel?.apply { - // TODO DEACTIVATION ? + // Do nothing } } diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumAttachPatchFragment.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumAttachPatchFragment.kt index 97baead2b1..04c38c25df 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumAttachPatchFragment.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumAttachPatchFragment.kt @@ -5,17 +5,17 @@ import android.view.View import androidx.lifecycle.ViewModelProvider import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.pump.medtrum.R -import info.nightscout.pump.medtrum.code.PatchStep import info.nightscout.pump.medtrum.databinding.FragmentMedtrumAttachPatchBinding -import info.nightscout.pump.medtrum.ui.MedtrumBaseFragment import info.nightscout.pump.medtrum.ui.viewmodel.MedtrumViewModel import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag +import info.nightscout.shared.interfaces.ResourceHelper import javax.inject.Inject class MedtrumAttachPatchFragment : MedtrumBaseFragment() { @Inject lateinit var aapsLogger: AAPSLogger + @Inject lateinit var rh: ResourceHelper companion object { @@ -34,13 +34,9 @@ class MedtrumAttachPatchFragment : MedtrumBaseFragment Unit // Nothing to do here, previous state - MedtrumViewModel.SetupStep.ERROR -> { - ToastUtils.errorToast(requireContext(), "Error attach patch") // TODO: String resource and show error message - moveStep(PatchStep.CANCEL) - } else -> { - ToastUtils.errorToast(requireContext(), "Unexpected state: $it") // TODO: String resource and show error message + ToastUtils.errorToast(requireContext(), rh.gs(R.string.unexpected_state, it.toString())) aapsLogger.error(LTag.PUMP, "Unexpected state: $it") } } diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumBaseActivity.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumBaseActivity.kt index 65b570f5c8..7861346883 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumBaseActivity.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumBaseActivity.kt @@ -10,7 +10,6 @@ import androidx.lifecycle.ViewModelProvider import dagger.android.support.DaggerAppCompatActivity import info.nightscout.core.ui.R import info.nightscout.pump.medtrum.di.MedtrumPluginQualifier -import info.nightscout.pump.medtrum.ui.MedtrumBaseNavigator import info.nightscout.rx.AapsSchedulers import io.reactivex.rxjava3.disposables.CompositeDisposable import javax.inject.Inject diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumDeactivatePatchFragment.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumDeactivatePatchFragment.kt index b996fa778e..cf55d18e4c 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumDeactivatePatchFragment.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumDeactivatePatchFragment.kt @@ -3,11 +3,9 @@ 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.pump.medtrum.R import info.nightscout.pump.medtrum.code.PatchStep import info.nightscout.pump.medtrum.databinding.FragmentMedtrumDeactivatePatchBinding -import info.nightscout.pump.medtrum.ui.MedtrumBaseFragment import info.nightscout.pump.medtrum.ui.viewmodel.MedtrumViewModel import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumDeactivationCompleteFragment.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumDeactivationCompleteFragment.kt index b433a0fad8..ab2ae588c3 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumDeactivationCompleteFragment.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumDeactivationCompleteFragment.kt @@ -3,11 +3,8 @@ 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.pump.medtrum.R -import info.nightscout.pump.medtrum.code.PatchStep import info.nightscout.pump.medtrum.databinding.FragmentMedtrumDeactivationCompleteBinding -import info.nightscout.pump.medtrum.ui.MedtrumBaseFragment import info.nightscout.pump.medtrum.ui.viewmodel.MedtrumViewModel import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumOverviewFragment.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumOverviewFragment.kt index 81567bfa42..650de82ede 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumOverviewFragment.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumOverviewFragment.kt @@ -1,10 +1,7 @@ package info.nightscout.pump.medtrum.ui -import android.content.Intent import android.os.Bundle import android.view.View -import androidx.activity.result.ActivityResultLauncher -import androidx.activity.result.contract.ActivityResultContracts import androidx.lifecycle.ViewModelProvider import info.nightscout.pump.medtrum.MedtrumPump import info.nightscout.pump.medtrum.databinding.FragmentMedtrumOverviewBinding @@ -15,7 +12,6 @@ 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.rx.logging.LTag import io.reactivex.rxjava3.disposables.CompositeDisposable import javax.inject.Inject @@ -24,8 +20,6 @@ class MedtrumOverviewFragment : MedtrumBaseFragment - private lateinit var resultLauncherForPause: ActivityResultLauncher private var disposable: CompositeDisposable = CompositeDisposable() @@ -55,29 +49,15 @@ class MedtrumOverviewFragment : MedtrumBaseFragment Unit } } - - resultLauncherForResume = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { - when (it.resultCode) { - // TODO Handle events here, see eopatch eventhandler - } - } - - resultLauncherForPause = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { - when (it.resultCode) { - // TODO Handle events here, see eopatch eventhandler - } - } } } } override fun onPause() { super.onPause() - // TODO } override fun onResume() { super.onResume() - // TODO } } \ No newline at end of file diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPreparePatchConnectFragment.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPreparePatchConnectFragment.kt index 0664d27ead..2c79372f9d 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPreparePatchConnectFragment.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPreparePatchConnectFragment.kt @@ -7,15 +7,16 @@ import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.pump.medtrum.R import info.nightscout.pump.medtrum.code.PatchStep import info.nightscout.pump.medtrum.databinding.FragmentMedtrumPreparePatchConnectBinding -import info.nightscout.pump.medtrum.ui.MedtrumBaseFragment import info.nightscout.pump.medtrum.ui.viewmodel.MedtrumViewModel import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag +import info.nightscout.shared.interfaces.ResourceHelper import javax.inject.Inject class MedtrumPreparePatchConnectFragment : MedtrumBaseFragment() { @Inject lateinit var aapsLogger: AAPSLogger + @Inject lateinit var rh: ResourceHelper companion object { @@ -33,11 +34,10 @@ class MedtrumPreparePatchConnectFragment : MedtrumBaseFragment btnPositive.visibility = View.GONE - // TODO: Confirmation dialog MedtrumViewModel.SetupStep.FILLED -> btnPositive.visibility = View.VISIBLE MedtrumViewModel.SetupStep.ERROR -> { - ToastUtils.errorToast(requireContext(), "Error preparing patch") // TODO: String resource and show error message + ToastUtils.errorToast(requireContext(), rh.gs(R.string.unexpected_state, it.toString())) moveStep(PatchStep.CANCEL) } diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPreparePatchFragment.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPreparePatchFragment.kt index 7c0c319025..6823027a6e 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPreparePatchFragment.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPreparePatchFragment.kt @@ -3,9 +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.pump.medtrum.R -import info.nightscout.pump.medtrum.code.PatchStep import info.nightscout.pump.medtrum.databinding.FragmentMedtrumPreparePatchBinding import info.nightscout.pump.medtrum.ui.MedtrumBaseFragment import info.nightscout.pump.medtrum.ui.viewmodel.MedtrumViewModel diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPrimeCompleteFragment.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPrimeCompleteFragment.kt index 38be727974..092cfce1a7 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPrimeCompleteFragment.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPrimeCompleteFragment.kt @@ -5,17 +5,18 @@ import android.view.View import androidx.lifecycle.ViewModelProvider import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.pump.medtrum.R -import info.nightscout.pump.medtrum.code.PatchStep import info.nightscout.pump.medtrum.databinding.FragmentMedtrumPrimeCompleteBinding import info.nightscout.pump.medtrum.ui.MedtrumBaseFragment import info.nightscout.pump.medtrum.ui.viewmodel.MedtrumViewModel import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag +import info.nightscout.shared.interfaces.ResourceHelper import javax.inject.Inject class MedtrumPrimeCompleteFragment : MedtrumBaseFragment() { @Inject lateinit var aapsLogger: AAPSLogger + @Inject lateinit var rh: ResourceHelper companion object { @@ -33,13 +34,9 @@ class MedtrumPrimeCompleteFragment : MedtrumBaseFragment Unit // Nothing to do here, previous state - MedtrumViewModel.SetupStep.ERROR -> { - ToastUtils.errorToast(requireContext(), "Error priming") // TODO: String resource and show error message - moveStep(PatchStep.CANCEL) - } else -> { - ToastUtils.errorToast(requireContext(), "Unexpected state: $it") // TODO: String resource and show error message + ToastUtils.errorToast(requireContext(), rh.gs(R.string.unexpected_state, it.toString())) aapsLogger.error(LTag.PUMP, "Unexpected state: $it") } } diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPrimeFragment.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPrimeFragment.kt index 49839bee3f..3603c8a2fd 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPrimeFragment.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPrimeFragment.kt @@ -5,17 +5,18 @@ import android.view.View import androidx.lifecycle.ViewModelProvider import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.pump.medtrum.R -import info.nightscout.pump.medtrum.code.PatchStep import info.nightscout.pump.medtrum.databinding.FragmentMedtrumPrimeBinding import info.nightscout.pump.medtrum.ui.MedtrumBaseFragment import info.nightscout.pump.medtrum.ui.viewmodel.MedtrumViewModel import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag +import info.nightscout.shared.interfaces.ResourceHelper import javax.inject.Inject class MedtrumPrimeFragment : MedtrumBaseFragment() { @Inject lateinit var aapsLogger: AAPSLogger + @Inject lateinit var rh: ResourceHelper companion object { @@ -33,13 +34,9 @@ class MedtrumPrimeFragment : MedtrumBaseFragment() when (it) { MedtrumViewModel.SetupStep.INITIAL, MedtrumViewModel.SetupStep.FILLED -> Unit // Nothing to do here, previous state - MedtrumViewModel.SetupStep.ERROR -> { - ToastUtils.errorToast(requireContext(), "Error priming") // TODO: String resource and show error message - moveStep(PatchStep.CANCEL) - } else -> { - ToastUtils.errorToast(requireContext(), "Unexpected state: $it") // TODO: String resource and show error message + ToastUtils.errorToast(requireContext(), rh.gs(R.string.unexpected_state, it.toString())) aapsLogger.error(LTag.PUMP, "Unexpected state: $it") } } diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPrimingFragment.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPrimingFragment.kt index 6e2defca85..52a4b1622f 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPrimingFragment.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumPrimingFragment.kt @@ -41,11 +41,12 @@ class MedtrumPrimingFragment : MedtrumBaseFragment { - ToastUtils.errorToast(requireContext(), "Unexpected state: $it") // TODO: String resource and show error message + ToastUtils.errorToast(requireContext(), rh.gs(R.string.unexpected_state, it.toString())) aapsLogger.error(LTag.PUMP, "Unexpected state: $it") } } diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumStartDeactivationFragment.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumStartDeactivationFragment.kt index 6d4e168306..dea85b9e7f 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumStartDeactivationFragment.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/MedtrumStartDeactivationFragment.kt @@ -4,7 +4,6 @@ import android.os.Bundle import android.view.View import androidx.lifecycle.ViewModelProvider import info.nightscout.core.ui.dialogs.OKDialog -import info.nightscout.core.ui.toast.ToastUtils import info.nightscout.pump.medtrum.R import info.nightscout.pump.medtrum.code.PatchStep import info.nightscout.pump.medtrum.databinding.FragmentMedtrumStartDeactivationBinding diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/viewmodel/BaseViewModel.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/viewmodel/BaseViewModel.kt index 0b69688829..9b2a3bbbde 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/viewmodel/BaseViewModel.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/viewmodel/BaseViewModel.kt @@ -1,8 +1,6 @@ package info.nightscout.pump.medtrum.ui.viewmodel import androidx.lifecycle.ViewModel -import info.nightscout.pump.medtrum.code.PatchStep -import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState import info.nightscout.pump.medtrum.ui.MedtrumBaseNavigator import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.Disposable diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/viewmodel/MedtrumOverviewViewModel.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/viewmodel/MedtrumOverviewViewModel.kt index d86a3efb25..4327f7c2ff 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/viewmodel/MedtrumOverviewViewModel.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/viewmodel/MedtrumOverviewViewModel.kt @@ -10,7 +10,6 @@ import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.pump.medtrum.MedtrumPump import info.nightscout.pump.medtrum.R import info.nightscout.pump.medtrum.code.ConnectionState -import info.nightscout.pump.medtrum.comm.enums.AlarmState import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag diff --git a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/viewmodel/MedtrumViewModel.kt b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/viewmodel/MedtrumViewModel.kt index c22f41e2ba..5a520f330c 100644 --- a/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/viewmodel/MedtrumViewModel.kt +++ b/pump/medtrum/src/main/java/info/nightscout/pump/medtrum/ui/viewmodel/MedtrumViewModel.kt @@ -2,7 +2,6 @@ package info.nightscout.pump.medtrum.ui.viewmodel import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.pump.medtrum.MedtrumPlugin @@ -17,13 +16,8 @@ import info.nightscout.pump.medtrum.encryption.Crypt import info.nightscout.pump.medtrum.ui.MedtrumBaseNavigator import info.nightscout.pump.medtrum.ui.event.SingleLiveEvent import info.nightscout.pump.medtrum.ui.event.UIEvent -import info.nightscout.shared.interfaces.ResourceHelper -import info.nightscout.rx.AapsSchedulers -import info.nightscout.rx.bus.RxBus -import info.nightscout.rx.events.EventPumpStatusChanged import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag -import info.nightscout.shared.sharedPreferences.SP import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.cancel @@ -31,15 +25,10 @@ import kotlinx.coroutines.launch import javax.inject.Inject class MedtrumViewModel @Inject constructor( - private val rh: ResourceHelper, private val aapsLogger: AAPSLogger, - private val rxBus: RxBus, - private val aapsSchedulers: AapsSchedulers, - private val fabricPrivacy: FabricPrivacy, private val medtrumPlugin: MedtrumPlugin, private val commandQueue: CommandQueue, - val medtrumPump: MedtrumPump, - private val sp: SP + val medtrumPump: MedtrumPump ) : BaseViewModel() { val patchStep = MutableLiveData() @@ -70,16 +59,14 @@ class MedtrumViewModel @Inject constructor( medtrumPump.lastConnection = System.currentTimeMillis() } - ConnectionState.DISCONNECTED -> { // TODO: This is getting ridiciolous, refactor - if (patchStep.value != PatchStep.START_DEACTIVATION - && patchStep.value != PatchStep.DEACTIVATE - && patchStep.value != PatchStep.FORCE_DEACTIVATION - && patchStep.value != PatchStep.DEACTIVATION_COMPLETE - && patchStep.value != PatchStep.ACTIVATE_COMPLETE - && patchStep.value != PatchStep.CANCEL - && patchStep.value != PatchStep.ERROR - && patchStep.value != PatchStep.PREPARE_PATCH - && patchStep.value != PatchStep.PREPARE_PATCH_CONNECT + ConnectionState.DISCONNECTED -> { + if (patchStep.value in listOf( + PatchStep.PRIME, + PatchStep.PRIMING, + PatchStep.PRIME_COMPLETE, + PatchStep.ATTACH_PATCH, + PatchStep.ACTIVATE + ) ) { medtrumService?.connect("Try reconnect from viewModel") } @@ -117,8 +104,7 @@ class MedtrumViewModel @Inject constructor( } MedtrumPumpState.PRIMING -> { - // updateSetupStep(SetupStep.PRIMING) - // TODO: What to do here? start prime counter? + // Do Nothing, wait for priming to complete } MedtrumPumpState.PRIMED, MedtrumPumpState.EJECTED -> { @@ -153,8 +139,15 @@ class MedtrumViewModel @Inject constructor( if (oldPatchStep != newPatchStep) { when (newPatchStep) { PatchStep.CANCEL -> { - // TODO: Are you sure? - // TODO: Dont disconnect when deactivating + if (oldPatchStep !in listOf( + PatchStep.START_DEACTIVATION, + PatchStep.DEACTIVATE, + PatchStep.FORCE_DEACTIVATION, + PatchStep.DEACTIVATION_COMPLETE + ) + ) { + medtrumService?.disconnect("Cancel") + } medtrumService?.disconnect("Cancel") } @@ -173,7 +166,6 @@ class MedtrumViewModel @Inject constructor( PatchStep.PREPARE_PATCH_CONNECT -> { // Make sure we are disconnected, else dont move step if (medtrumService?.isConnected == true) { - // TODO, replace with error message aapsLogger.info(LTag.PUMP, "moveStep: connected, not moving step") return } else { diff --git a/pump/medtrum/src/main/res/layout/fragment_medtrum_deactivate_patch.xml b/pump/medtrum/src/main/res/layout/fragment_medtrum_deactivate_patch.xml index 1d615cb29d..5006bb8428 100644 --- a/pump/medtrum/src/main/res/layout/fragment_medtrum_deactivate_patch.xml +++ b/pump/medtrum/src/main/res/layout/fragment_medtrum_deactivate_patch.xml @@ -65,8 +65,8 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="6dp" - android:contentDescription="@string/next" - android:text="@string/next" + android:contentDescription="@string/discard" + android:text="@string/discard" android:visibility="gone" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/btn_negative" diff --git a/pump/medtrum/src/main/res/values/strings.xml b/pump/medtrum/src/main/res/values/strings.xml index 32afceb27c..879869d85b 100644 --- a/pump/medtrum/src/main/res/values/strings.xml +++ b/pump/medtrum/src/main/res/values/strings.xml @@ -90,6 +90,7 @@ Deactivate Patch Deactivating... Patch deactivated + Unexpected state: %1$s Pump Base Serial: %1$X No active patch. Press Next to begin the activation process. @@ -112,7 +113,7 @@ Are you sure? This action cannot be reversed!! Press Next to deactivate or Cancel to return to main screen. Deactivating patch. Please Wait. - Failed to deactivate, press Next to forget patch. + Failed to deactivate, press Discard to forget patch. Retract needle. Remove patch from body. Remove pump base and dispose of used patch appropriately. Press OK to return to main screen. Press Next to start activation of new patch.