diff --git a/app/libs/eopatch_core.aar b/app/libs/eopatch_core.aar index 938f227251..7c48b147a2 100644 Binary files a/app/libs/eopatch_core.aar and b/app/libs/eopatch_core.aar differ diff --git a/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt b/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt index 3f61fff560..6650bcdf1b 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt +++ b/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt @@ -22,7 +22,6 @@ import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.HardLimits import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.interfaces.ResourceHelper -import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import org.json.JSONArray import org.json.JSONObject import java.text.DecimalFormat @@ -99,7 +98,6 @@ sealed class ProfileSealed( override fun isValid(from: String, pump: Pump, config: Config, rh: ResourceHelper, rxBus: RxBus, hardLimits: HardLimits, sendNotifications: Boolean): Profile.ValidityCheck { val validityCheck = Profile.ValidityCheck() val description = pump.pumpDescription - val notSupportedBasalRate = StringBuffer() for (basal in basalBlocks) { val basalAmount = basal.amount * percentage / 100.0 @@ -144,20 +142,6 @@ sealed class ProfileSealed( validityCheck.reasons.add(rh.gs(R.string.maximumbasalvaluereplaced, from)) break } - - if(pump.model() == PumpType.EOFLOW_EOPATCH2 && pct == 100){ - val mod = (basalAmount * 1000) % (PumpType.EOFLOW_EOPATCH2.baseBasalStep * 1000) - if(!mod.nearlyEqual(0.0, 0.00000001)){ - notSupportedBasalRate.append( - if(notSupportedBasalRate.isEmpty()) String.format("%.2f", basalAmount) else String.format(", %.2f", basalAmount) - ) - } - } - } - - if(notSupportedBasalRate.isNotEmpty()){ - validityCheck.isValid = false - validityCheck.reasons.add(rh.gs(R.string.unsupportedBasalRate, "$notSupportedBasalRate U/h")) } if (!hardLimits.isInRange(dia, hardLimits.minDia(), hardLimits.maxDia())) { diff --git a/core/src/main/java/info/nightscout/androidaps/extensions/ProfileSwitchExtension.kt b/core/src/main/java/info/nightscout/androidaps/extensions/ProfileSwitchExtension.kt index 4bf0626089..d77090bc2d 100644 --- a/core/src/main/java/info/nightscout/androidaps/extensions/ProfileSwitchExtension.kt +++ b/core/src/main/java/info/nightscout/androidaps/extensions/ProfileSwitchExtension.kt @@ -14,7 +14,6 @@ import info.nightscout.androidaps.utils.JsonHelper import info.nightscout.androidaps.utils.T import org.json.JSONObject import java.util.* -import kotlin.math.abs fun List.isPSEvent5minBack(time: Long): Boolean { for (event in this) { @@ -159,16 +158,3 @@ fun ProfileSwitch.getCustomizedName(): String { fun ProfileSwitch.GlucoseUnit.Companion.fromConstant(units: GlucoseUnit): ProfileSwitch.GlucoseUnit = if (units == GlucoseUnit.MGDL) ProfileSwitch.GlucoseUnit.MGDL else ProfileSwitch.GlucoseUnit.MMOL - -fun Double.nearlyEqual(b: Double, epsilon: Double): Boolean { - val absA = abs(this) - val absB = abs(b) - val diff = abs(this - b) - return if (this == b) { - true - } else if (this == 0.0 || b == 0.0 || absA + absB < java.lang.Float.MIN_NORMAL) { - diff < epsilon * java.lang.Double.MIN_NORMAL - } else { - diff / (absA + absB).coerceAtMost(Double.MAX_VALUE) < epsilon - } -} diff --git a/core/src/main/res/values-ko-rKR/strings.xml b/core/src/main/res/values-ko-rKR/strings.xml index 7190f2668f..cbfc822d52 100644 --- a/core/src/main/res/values-ko-rKR/strings.xml +++ b/core/src/main/res/values-ko-rKR/strings.xml @@ -146,7 +146,6 @@ 변경사항 없음 유효하지 않은 프로파일: %1$s - 지원하지 않는 베이젤 속도: %1$s %1$d 분 diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index b27684d643..56ed54ace4 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -241,7 +241,6 @@ Invalid profile: %1$s - Unsupported basal rate: %1$s %1$d min diff --git a/eopatch/libs/eopatch_core.aar b/eopatch/libs/eopatch_core.aar index 938f227251..7c48b147a2 100644 Binary files a/eopatch/libs/eopatch_core.aar and b/eopatch/libs/eopatch_core.aar differ diff --git a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ble/task/ActivateTask.java b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ble/task/ActivateTask.java index 650e314e68..f476a0ad8f 100644 --- a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ble/task/ActivateTask.java +++ b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ble/task/ActivateTask.java @@ -29,8 +29,9 @@ public class ActivateTask extends TaskBase { .concatMapSingle(v -> SET_KEY.setKey()) .doOnNext(this::checkResponse) .firstOrError() - .observeOn(Schedulers.io()).doOnSuccess(this::onActivated) + .observeOn(Schedulers.io()) .flatMap(v -> startBasalTask.start(enabled)) + .doOnSuccess(this::onActivated) .map(BaseResponse::isSuccess) .doOnError(e -> aapsLogger.error(LTag.PUMPCOMM, (e.getMessage() != null) ? e.getMessage() : "ActivateTask error")); } diff --git a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/code/EventType.kt b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/code/EventType.kt index fba95d8629..07ddfb4e0f 100644 --- a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/code/EventType.kt +++ b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/code/EventType.kt @@ -6,7 +6,6 @@ enum class EventType { SUSPEND_CLICKED, RESUME_CLICKED, INVALID_BASAL_RATE, - UNSUPPORTED_BASAL_RATE, PROFILE_NOT_SET, SHOW_PATCH_COMM_DIALOG, DISMISS_PATCH_COMM_DIALOG, @@ -15,7 +14,9 @@ enum class EventType { SHOW_CHANGE_PATCH_DIALOG, FINISH_ACTIVITY, SHOW_DISCARD_DIALOG, + PAUSE_BASAL_SUCCESS, PAUSE_BASAL_FAILED, + RESUME_BASAL_SUCCESS, RESUME_BASAL_FAILED ; } diff --git a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseActivity.kt b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseActivity.kt index 75598cf32f..ee6796531a 100644 --- a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseActivity.kt +++ b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseActivity.kt @@ -2,10 +2,8 @@ package info.nightscout.androidaps.plugins.pump.eopatch.ui import android.content.Intent import android.os.Bundle -import android.widget.Toast import androidx.activity.result.ActivityResultLauncher import androidx.annotation.LayoutRes -import androidx.annotation.StringRes import androidx.databinding.DataBindingUtil import androidx.databinding.ViewDataBinding import androidx.lifecycle.ViewModelProvider @@ -41,14 +39,6 @@ abstract class EoBaseActivity : NoSplashAppCompatActivity() } - override fun toast(message: String) { - Toast.makeText(this@EoBaseActivity, message, Toast.LENGTH_SHORT).show() - } - - override fun toast(@StringRes message: Int) { - Toast.makeText(this@EoBaseActivity, message, Toast.LENGTH_SHORT).show() - } - override fun back() { if(supportFragmentManager.backStackEntryCount == 0) { finish() diff --git a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseFragment.kt b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseFragment.kt index 9161a94770..bec613852b 100644 --- a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseFragment.kt +++ b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseFragment.kt @@ -56,14 +56,6 @@ abstract class EoBaseFragment : DaggerFragment(), EoBaseNav baseActivity = null } - override fun toast(message: String) { - baseActivity?.toast(message) - } - - override fun toast(message: Int) { - baseActivity?.toast(message) - } - override fun back() { baseActivity?.back() } diff --git a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseNavigator.kt b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseNavigator.kt index 2f98ff9cfb..70b892b5fd 100644 --- a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseNavigator.kt +++ b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EoBaseNavigator.kt @@ -1,12 +1,6 @@ package info.nightscout.androidaps.plugins.pump.eopatch.ui -import androidx.annotation.StringRes - interface EoBaseNavigator { - fun toast(message: String) - - fun toast(@StringRes message: Int) - fun back() fun finish(finishAffinity: Boolean = false) diff --git a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchConnectNewFragment.kt b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchConnectNewFragment.kt index 35115640d5..669ddb6734 100644 --- a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchConnectNewFragment.kt +++ b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchConnectNewFragment.kt @@ -2,13 +2,13 @@ package info.nightscout.androidaps.plugins.pump.eopatch.ui import android.os.Bundle import android.view.View -import android.widget.Toast import androidx.lifecycle.ViewModelProvider import info.nightscout.androidaps.plugins.pump.eopatch.ui.viewmodel.EopatchViewModel.SetupStep.* import info.nightscout.androidaps.plugins.pump.eopatch.R import info.nightscout.androidaps.plugins.pump.eopatch.code.PatchStep import info.nightscout.androidaps.plugins.pump.eopatch.databinding.FragmentEopatchConnectNewBinding import info.nightscout.androidaps.plugins.pump.eopatch.ui.viewmodel.EopatchViewModel +import info.nightscout.androidaps.utils.ToastUtils class EopatchConnectNewFragment : EoBaseFragment() { @@ -29,7 +29,7 @@ class EopatchConnectNewFragment : EoBaseFragment checkCommunication({ retryScan() }, { moveStep(PatchStep.WAKE_UP) }) GET_PATCH_INFO_FAILED -> checkCommunication({ getPatchInfo() }, { moveStep(PatchStep.WAKE_UP) }) SELF_TEST_FAILED -> checkCommunication({ selfTest() }, { moveStep(PatchStep.WAKE_UP) }) - ACTIVATION_FAILED -> Toast.makeText(requireContext(), "Activation failed!", Toast.LENGTH_LONG).show() + ACTIVATION_FAILED -> ToastUtils.errorToast(requireContext(), "Activation failed!") else -> Unit } } diff --git a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchOverviewFragment.kt b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchOverviewFragment.kt index ec3e90c4e9..3b4cd0986c 100644 --- a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchOverviewFragment.kt +++ b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchOverviewFragment.kt @@ -3,10 +3,8 @@ package info.nightscout.androidaps.plugins.pump.eopatch.ui import android.content.Intent import android.os.Bundle import android.view.View -import android.widget.Toast import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts -import androidx.annotation.StringRes import androidx.lifecycle.ViewModelProvider import dagger.android.support.DaggerAppCompatActivity import info.nightscout.androidaps.plugins.bus.RxBus @@ -17,6 +15,7 @@ import info.nightscout.androidaps.plugins.pump.eopatch.code.EventType import info.nightscout.androidaps.plugins.pump.eopatch.databinding.FragmentEopatchOverviewBinding import info.nightscout.androidaps.plugins.pump.eopatch.extension.takeOne import info.nightscout.androidaps.plugins.pump.eopatch.ui.viewmodel.EopatchOverviewViewModel +import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.alertDialogs.AlertDialogHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.shared.logging.AAPSLogger @@ -52,11 +51,12 @@ class EopatchOverviewFragment: EoBaseFragment() EventType.DEACTIVATION_CLICKED -> requireContext().apply { startActivity(EopatchActivity.createIntentForChangePatch(this)) } EventType.SUSPEND_CLICKED -> suspend() EventType.RESUME_CLICKED -> resume() - EventType.INVALID_BASAL_RATE -> showToast(R.string.invalid_basal_rate) - EventType.UNSUPPORTED_BASAL_RATE -> showToast(R.string.unsupported_basal_rate, evt.value) - EventType.PROFILE_NOT_SET -> showToast(R.string.no_profile_selected) - EventType.PAUSE_BASAL_FAILED -> showToast(R.string.string_pause_failed) - EventType.RESUME_BASAL_FAILED -> showToast(R.string.string_resume_failed) + EventType.INVALID_BASAL_RATE -> ToastUtils.infoToast(requireContext(), R.string.invalid_basal_rate) + EventType.PROFILE_NOT_SET -> ToastUtils.infoToast(requireContext(), R.string.no_profile_selected) + EventType.PAUSE_BASAL_SUCCESS -> ToastUtils.infoToast(requireContext(), R.string.string_suspended_insulin_delivery_message) + EventType.PAUSE_BASAL_FAILED -> ToastUtils.errorToast(requireContext(), R.string.string_pause_failed) + EventType.RESUME_BASAL_SUCCESS -> ToastUtils.infoToast(requireContext(), R.string.string_resumed_insulin_delivery_message) + EventType.RESUME_BASAL_FAILED -> ToastUtils.errorToast(requireContext(), R.string.string_resume_failed) else -> Unit } } @@ -64,7 +64,7 @@ class EopatchOverviewFragment: EoBaseFragment() resultLauncherForResume = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){ when (it.resultCode) { DaggerAppCompatActivity.RESULT_OK -> resumeBasal() - DaggerAppCompatActivity.RESULT_CANCELED -> showToast(R.string.string_resume_failed) + DaggerAppCompatActivity.RESULT_CANCELED -> ToastUtils.errorToast(requireContext(), R.string.string_resume_failed) } } @@ -74,7 +74,7 @@ class EopatchOverviewFragment: EoBaseFragment() pauseBasal(pauseDuration) pauseDuration = 0.5f } - DaggerAppCompatActivity.RESULT_CANCELED -> showToast(R.string.string_pause_failed) + DaggerAppCompatActivity.RESULT_CANCELED -> ToastUtils.errorToast(requireContext(), R.string.string_pause_failed) } } } @@ -91,13 +91,6 @@ class EopatchOverviewFragment: EoBaseFragment() binding.viewmodel?.startBasalRateUpdate() } - private fun showToast(@StringRes strId: Int, value: Any? = null){ - if(value == null) - Toast.makeText(requireContext(), strId, Toast.LENGTH_SHORT).show() - else - Toast.makeText(requireContext(), getString(strId, value.toString()), Toast.LENGTH_SHORT).show() - } - private fun suspend() { binding.viewmodel?.apply { activity?.let { diff --git a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchRotateKnobFragment.kt b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchRotateKnobFragment.kt index e1e4d7ee21..9f1920a548 100644 --- a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchRotateKnobFragment.kt +++ b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/EopatchRotateKnobFragment.kt @@ -9,6 +9,7 @@ import info.nightscout.androidaps.plugins.pump.eopatch.R import info.nightscout.androidaps.plugins.pump.eopatch.code.PatchStep import info.nightscout.androidaps.plugins.pump.eopatch.databinding.FragmentEopatchRotateKnobBinding import info.nightscout.androidaps.plugins.pump.eopatch.ui.viewmodel.EopatchViewModel +import info.nightscout.androidaps.utils.ToastUtils class EopatchRotateKnobFragment : EoBaseFragment() { @@ -33,10 +34,11 @@ class EopatchRotateKnobFragment : EoBaseFragment { leftMargin = 3 } text = getString(R.string.retry) } - + textPatchRotateKnobDesc.visibility = View.VISIBLE layoutNeedleInsertionError.visibility = View.VISIBLE textRotateKnobDesc2.visibility = View.GONE textRotateKnobDesc2NeedleInsertionError.visibility = View.VISIBLE + textActivationErrorDesc.visibility = View.GONE } setupStep.observe(viewLifecycleOwner) { @@ -44,6 +46,20 @@ class EopatchRotateKnobFragment : EoBaseFragment { checkCommunication({ startNeedleSensing() }) } + EopatchViewModel.SetupStep.ACTIVATION_FAILED -> { + btnNegative.visibility = View.VISIBLE + guidelineButton.setGuidelinePercent(0.4f) + + btnPositive.apply { + updateLayoutParams { leftMargin = 3 } + text = getString(R.string.retry) + } + textPatchRotateKnobDesc.visibility = View.GONE + textRotateKnobDesc2.visibility = View.GONE + textRotateKnobDesc2NeedleInsertionError.visibility = View.VISIBLE + textActivationErrorDesc.visibility = View.VISIBLE + ToastUtils.errorToast(requireContext(), "Activation failed!") + } else -> Unit } } diff --git a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/viewmodel/EopatchOverviewViewModel.kt b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/viewmodel/EopatchOverviewViewModel.kt index 05501cae12..1fd24c16e4 100644 --- a/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/viewmodel/EopatchOverviewViewModel.kt +++ b/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/viewmodel/EopatchOverviewViewModel.kt @@ -16,7 +16,6 @@ import info.nightscout.androidaps.plugins.pump.eopatch.vo.Alarms import info.nightscout.androidaps.plugins.pump.eopatch.vo.PatchConfig import info.nightscout.androidaps.plugins.pump.eopatch.vo.PatchState import info.nightscout.androidaps.interfaces.ResourceHelper -import info.nightscout.androidaps.plugins.pump.eopatch.extension.nearlyEqual import info.nightscout.androidaps.utils.rx.AapsSchedulers import io.reactivex.rxjava3.core.Observable import io.reactivex.rxjava3.disposables.Disposable @@ -180,12 +179,6 @@ class EopatchOverviewViewModel @Inject constructor( isValid = false break } - val mod = (basalRate.value * 1000) % (0.05 * 1000) - if(!mod.nearlyEqual(0.0, 0.00000001)){ - _eventHandler.postValue(UIEvent(EventType.UNSUPPORTED_BASAL_RATE).apply { value = basalRate.value }) - isValid = false - break - } } if(isValid) { @@ -215,7 +208,7 @@ class EopatchOverviewViewModel @Inject constructor( .observeOn(aapsSchedulers.main) .subscribe({ response -> if (response.isSuccess) { - navigator?.toast(R.string.string_suspended_insulin_delivery_message) + UIEvent(EventType.PAUSE_BASAL_SUCCESS).let { _eventHandler.postValue(it) } startPauseTimeUpdate() } else { UIEvent(EventType.PAUSE_BASAL_FAILED).apply { value = pauseDurationHour }.let { _eventHandler.postValue(it) } @@ -231,7 +224,7 @@ class EopatchOverviewViewModel @Inject constructor( .observeOn(aapsSchedulers.main) .subscribe({ if (it.isSuccess) { - navigator?.toast(R.string.string_resumed_insulin_delivery_message) + UIEvent(EventType.RESUME_BASAL_SUCCESS).let { _eventHandler.postValue(it) } stopPauseTimeUpdate() } else { _eventHandler.postValue(UIEvent(EventType.RESUME_BASAL_FAILED)) diff --git a/eopatch/src/main/res/layout/fragment_eopatch_rotate_knob.xml b/eopatch/src/main/res/layout/fragment_eopatch_rotate_knob.xml index 5da32f5bcc..7cc9561f41 100644 --- a/eopatch/src/main/res/layout/fragment_eopatch_rotate_knob.xml +++ b/eopatch/src/main/res/layout/fragment_eopatch_rotate_knob.xml @@ -140,6 +140,16 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/layout_needle_insertion_error" /> + 프로파일에 설정된 베이젤 속도가 0.05 U/hr 보다 작습니다. 이오패치는 최소 주입 단위가 0.05U 입니다. 최소 주입 단위 이상으로 프로파일 설정 후 다시 시도해 주세요. 프로파일이 선택되지 않았습니다. 프로파일 선택 후 다시 시도해 주세요. - 베이젤 속도 %1$s U/hr는 이오패치에서 지원되지 않습니다. day + diff --git a/eopatch/src/main/res/values/strings.xml b/eopatch/src/main/res/values/strings.xml index 2ed40e4bfb..a8c68e6caf 100644 --- a/eopatch/src/main/res/values/strings.xml +++ b/eopatch/src/main/res/values/strings.xml @@ -34,7 +34,6 @@ The basal of the profile is less than 0.05 U/hr. EOPatch has a minimum injection unit of 0.05U. Please try again after setting the profile to more than the minimum injection unit. No profile selected. Please select a profile and try again. - Basal rate %1$s U/hr is not supported by EOPatch. day +