translate exceptions. Display expiration 8h before the real expiration
This commit is contained in:
parent
09675de3f1
commit
613e7963f2
5 changed files with 40 additions and 2 deletions
|
@ -241,6 +241,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
|
||||||
.plusHours(podLifeInHours.toLong())
|
.plusHours(podLifeInHours.toLong())
|
||||||
.minusMinutes(minutesSinceActivation.toLong())
|
.minusMinutes(minutesSinceActivation.toLong())
|
||||||
.minus(Duration.ofMillis(System.currentTimeMillis() - lastUpdatedSystem))
|
.minus(Duration.ofMillis(System.currentTimeMillis() - lastUpdatedSystem))
|
||||||
|
.minusHours(8)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.OmnipodDashManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.OmnipodDashManager
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertTrigger
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertTrigger
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.I8n
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import io.reactivex.rxkotlin.subscribeBy
|
import io.reactivex.rxkotlin.subscribeBy
|
||||||
|
@ -21,6 +23,7 @@ class DashInitializePodViewModel @Inject constructor(
|
||||||
logger: AAPSLogger,
|
logger: AAPSLogger,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val podStateManager: OmnipodDashPodStateManager,
|
private val podStateManager: OmnipodDashPodStateManager,
|
||||||
|
private val resourceHelper: ResourceHelper
|
||||||
) : InitializePodViewModel(injector, logger) {
|
) : InitializePodViewModel(injector, logger) {
|
||||||
override fun isPodInAlarm(): Boolean = false // TODO
|
override fun isPodInAlarm(): Boolean = false // TODO
|
||||||
|
|
||||||
|
@ -46,7 +49,11 @@ class DashInitializePodViewModel @Inject constructor(
|
||||||
},
|
},
|
||||||
onError = { throwable ->
|
onError = { throwable ->
|
||||||
logger.error(LTag.PUMP, "Error in Pod activation part 1", throwable)
|
logger.error(LTag.PUMP, "Error in Pod activation part 1", throwable)
|
||||||
source.onSuccess(PumpEnactResult(injector).success(false).comment(throwable.toString()))
|
source.onSuccess(
|
||||||
|
PumpEnactResult(injector)
|
||||||
|
.success(false)
|
||||||
|
.comment(I8n.textFromException(throwable, resourceHelper))
|
||||||
|
)
|
||||||
},
|
},
|
||||||
onComplete = {
|
onComplete = {
|
||||||
logger.debug("Pod activation part 1 completed")
|
logger.debug("Pod activation part 1 completed")
|
||||||
|
|
|
@ -16,7 +16,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activati
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.OmnipodDashManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.OmnipodDashManager
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.I8n
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.mapProfileToBasalProgram
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import io.reactivex.rxkotlin.subscribeBy
|
import io.reactivex.rxkotlin.subscribeBy
|
||||||
|
@ -29,6 +31,7 @@ class DashInsertCannulaViewModel @Inject constructor(
|
||||||
private val podStateManager: OmnipodDashPodStateManager,
|
private val podStateManager: OmnipodDashPodStateManager,
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
|
private val resourceHelper: ResourceHelper,
|
||||||
|
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
logger: AAPSLogger
|
logger: AAPSLogger
|
||||||
|
@ -69,7 +72,7 @@ class DashInsertCannulaViewModel @Inject constructor(
|
||||||
},
|
},
|
||||||
onError = { throwable ->
|
onError = { throwable ->
|
||||||
logger.error(LTag.PUMP, "Error in Pod activation part 2", throwable)
|
logger.error(LTag.PUMP, "Error in Pod activation part 2", throwable)
|
||||||
source.onSuccess(PumpEnactResult(injector).success(false).comment(throwable.toString()))
|
source.onSuccess(PumpEnactResult(injector).success(false).comment(I8n.textFromException(throwable, resourceHelper)))
|
||||||
},
|
},
|
||||||
onComplete = {
|
onComplete = {
|
||||||
logger.debug("Pod activation part 2 completed")
|
logger.debug("Pod activation part 2 completed")
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.omnipod.dash.util
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.R
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.FailedToConnectException
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanException
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.ScanFailFoundTooManyException
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
|
||||||
|
class I8n {
|
||||||
|
companion object {
|
||||||
|
fun textFromException(exception: Throwable, rs: ResourceHelper): String {
|
||||||
|
return when (exception) {
|
||||||
|
is FailedToConnectException -> rs.gs(R.string.omnipod_dash_failed_to_connect)
|
||||||
|
is ScanFailFoundTooManyException -> rs.gs(R.string.omnipod_dash_found_too_many_pods)
|
||||||
|
is ScanException -> rs.gs(R.string.omnipod_dash_scan_failed)
|
||||||
|
else ->
|
||||||
|
rs.gs(R.string.omnipod_dash_generic_error, exception.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,4 +24,10 @@
|
||||||
<string name="key_common_preferences_category_other_settings" translatable="false">common_preferences_category_other</string>
|
<string name="key_common_preferences_category_other_settings" translatable="false">common_preferences_category_other</string>
|
||||||
<string name="key_omnipod_common_notification_delivery_suspended_sound_enabled">AAPS.Omnipod.notification_delivery_suspended_sound_enabled</string>
|
<string name="key_omnipod_common_notification_delivery_suspended_sound_enabled">AAPS.Omnipod.notification_delivery_suspended_sound_enabled</string>
|
||||||
<string name="omnipod_common_preferences_notification_delivery_suspended_sound_enabled">Sound when delivery suspended notification enabled</string>
|
<string name="omnipod_common_preferences_notification_delivery_suspended_sound_enabled">Sound when delivery suspended notification enabled</string>
|
||||||
|
|
||||||
|
<!-- Exceptions -->
|
||||||
|
<string name="omnipod_dash_failed_to_connect">Failed to connect to pod</string>
|
||||||
|
<string name="omnipod_dash_found_too_many_pods">Found too many pods when scanning</string>
|
||||||
|
<string name="omnipod_dash_scan_failed">Could not find any available pod for activation</string>
|
||||||
|
<string name="omnipod_dash_generic_error">Generic error: %1$s</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue