Merge branch 'dev' into kts

This commit is contained in:
Milos Kozak 2023-10-12 16:16:20 +02:00
commit 4aecd28aaf
13 changed files with 74 additions and 45 deletions

View file

@ -86,7 +86,7 @@ import kotlin.math.roundToInt
removed.add(Pair("ExtendedBolus", database.extendedBolusDao.deleteOlderThan(than)))
removed.add(Pair("Bolus", database.bolusDao.deleteOlderThan(than)))
removed.add(Pair("MultiWaveBolus", database.multiwaveBolusLinkDao.deleteOlderThan(than)))
// keep TDD removed.add(Pair("TotalDailyDose", database.totalDailyDoseDao.deleteOlderThan(than)))
removed.add(Pair("TotalDailyDose", database.totalDailyDoseDao.deleteOlderThan(than)))
removed.add(Pair("Carbs", database.carbsDao.deleteOlderThan(than)))
removed.add(Pair("TemporaryTarget", database.temporaryTargetDao.deleteOlderThan(than)))
removed.add(Pair("ApsResultLink", database.apsResultLinkDao.deleteOlderThan(than)))
@ -111,7 +111,7 @@ import kotlin.math.roundToInt
removed.add(Pair("CHANGES Bolus", database.bolusDao.deleteTrackedChanges()))
removed.add(Pair("CHANGES ExtendedBolus", database.extendedBolusDao.deleteTrackedChanges()))
removed.add(Pair("CHANGES MultiWaveBolus", database.multiwaveBolusLinkDao.deleteTrackedChanges()))
// keep TDD removed.add(Pair("CHANGES TotalDailyDose", database.totalDailyDoseDao.deleteTrackedChanges()))
removed.add(Pair("CHANGES TotalDailyDose", database.totalDailyDoseDao.deleteTrackedChanges()))
removed.add(Pair("CHANGES Carbs", database.carbsDao.deleteTrackedChanges()))
removed.add(Pair("CHANGES TemporaryTarget", database.temporaryTargetDao.deleteTrackedChanges()))
removed.add(Pair("CHANGES ApsResultLink", database.apsResultLinkDao.deleteTrackedChanges()))

View file

@ -129,7 +129,7 @@ class AutomationPlugin @Inject constructor(
init {
refreshLoop = Runnable {
processActions()
handler.postDelayed(refreshLoop, T.mins(1).msecs())
handler.postDelayed(refreshLoop, T.secs(150).msecs())
}
}

View file

@ -34,5 +34,6 @@
<string name="do_xdrip_upload_summary">I xDrip+, velg 640G/Eversens som datakilde</string>
<string name="bgsource_upload">Innstillinger for opplasting av BS</string>
<string name="dexcom_log_ns_sensor_change_title">Logg sensorbytte til NS</string>
<string name="dexcom_log_ns_sensor_change_summary">Opprett hendelse \"Sensorbytte\" automatisk i NS ved start av sensoren</string>
<string name="direction">retning</string>
</resources>

View file

@ -122,6 +122,8 @@ class NSClientFragment : DaggerFragment(), MenuProvider, PluginFragment {
ID_MENU_CLEAR_LOG -> {
nsClientPlugin?.listLog?.let {
synchronized(it) {
val size = it.size
binding.recyclerview.adapter?.notifyItemRangeRemoved(0, size)
it.clear()
updateLog()
}
@ -135,7 +137,7 @@ class NSClientFragment : DaggerFragment(), MenuProvider, PluginFragment {
}
ID_MENU_SEND_NOW -> {
nsClientPlugin?.resend("GUI")
handler.post { nsClientPlugin?.resend("GUI") }
true
}

View file

@ -2,4 +2,4 @@ package app.aaps.plugins.sync.nsShared.events
import app.aaps.core.interfaces.rx.events.Event
class EventConnectivityOptionChanged(val blockingReason: String) : Event()
class EventConnectivityOptionChanged(val blockingReason: String, val connected: Boolean) : Event()

View file

@ -94,7 +94,7 @@ class ReceiverDelegate @Inject constructor(
if (newAllowedState != allowed) {
allowed = newAllowedState
if (allowed) blockingReason = ""
rxBus.send(EventConnectivityOptionChanged(blockingReason))
rxBus.send(EventConnectivityOptionChanged(blockingReason, receiverStatusStore.isConnected))
}
}

View file

@ -156,16 +156,16 @@ class NSClientV3Plugin @Inject constructor(
override val status
get() =
when {
sp.getBoolean(R.string.key_ns_paused, false) -> rh.gs(app.aaps.core.ui.R.string.paused)
isAllowed.not() -> blockingReason
sp.getBoolean(R.string.key_ns_paused, false) -> rh.gs(app.aaps.core.ui.R.string.paused)
isAllowed.not() -> blockingReason
sp.getBoolean(app.aaps.core.utils.R.string.key_ns_use_ws, true) && wsConnected -> "WS: " + rh.gs(app.aaps.core.interfaces.R.string.connected)
sp.getBoolean(app.aaps.core.utils.R.string.key_ns_use_ws, true) && !wsConnected -> "WS: " + rh.gs(R.string.not_connected)
lastOperationError != null -> rh.gs(app.aaps.core.ui.R.string.error)
nsAndroidClient?.lastStatus == null -> rh.gs(R.string.not_connected)
workIsRunning() -> rh.gs(R.string.working)
nsAndroidClient?.lastStatus?.apiPermissions?.isFull() == true -> rh.gs(app.aaps.core.interfaces.R.string.connected)
nsAndroidClient?.lastStatus?.apiPermissions?.isRead() == true -> rh.gs(R.string.read_only)
else -> rh.gs(app.aaps.core.ui.R.string.unknown)
lastOperationError != null -> rh.gs(app.aaps.core.ui.R.string.error)
nsAndroidClient?.lastStatus == null -> rh.gs(R.string.not_connected)
workIsRunning() -> rh.gs(R.string.working)
nsAndroidClient?.lastStatus?.apiPermissions?.isFull() == true -> rh.gs(app.aaps.core.interfaces.R.string.connected)
nsAndroidClient?.lastStatus?.apiPermissions?.isRead() == true -> rh.gs(R.string.read_only)
else -> rh.gs(app.aaps.core.ui.R.string.unknown)
}
var lastOperationError: String? = null
@ -197,8 +197,13 @@ class NSClientV3Plugin @Inject constructor(
.observeOn(aapsSchedulers.io)
.subscribe({ ev ->
rxBus.send(EventNSClientNewLog("● CONNECTIVITY", ev.blockingReason))
setClient("CONNECTIVITY")
if (isAllowed) executeLoop("CONNECTIVITY", forceNew = false)
if (ev.connected) {
when {
isAllowed && storageSocket == null -> setClient("CONNECTIVITY") // socket must be created
!isAllowed && storageSocket != null -> shutdownWebsockets()
}
if (isAllowed) executeLoop("CONNECTIVITY", forceNew = false)
}
rxBus.send(EventNSClientUpdateGuiStatus())
}, fabricPrivacy::logException)
disposable += rxBus
@ -211,8 +216,10 @@ class NSClientV3Plugin @Inject constructor(
ev.isChanged(rh.gs(R.string.key_ns_paused)) ||
ev.isChanged(rh.gs(app.aaps.core.utils.R.string.key_ns_alarms)) ||
ev.isChanged(rh.gs(app.aaps.core.utils.R.string.key_ns_announcements))
)
) {
shutdownWebsockets()
setClient("SETTING CHANGE")
}
if (ev.isChanged(rh.gs(app.aaps.core.utils.R.string.key_local_profile_last_change)))
executeUpload("PROFILE_CHANGE", forceNew = true)
@ -299,10 +306,7 @@ class NSClientV3Plugin @Inject constructor(
override fun onStop() {
handler.removeCallbacksAndMessages(null)
disposable.clear()
storageSocket?.disconnect()
alarmSocket?.disconnect()
storageSocket = null
alarmSocket = null
shutdownWebsockets()
super.onStop()
}
@ -331,19 +335,14 @@ class NSClientV3Plugin @Inject constructor(
}
private fun setClient(reason: String) {
nsAndroidClient = NSAndroidClientImpl(
baseUrl = sp.getString(app.aaps.core.utils.R.string.key_nsclientinternal_url, "").lowercase().replace("https://", "").replace(Regex("/$"), ""),
accessToken = sp.getString(R.string.key_ns_client_token, ""),
context = context,
logging = true,
logger = { msg -> aapsLogger.debug(LTag.HTTP, msg) }
)
if (wsConnected) {
storageSocket?.disconnect()
alarmSocket?.disconnect()
storageSocket = null
alarmSocket = null
}
if (nsAndroidClient == null)
nsAndroidClient = NSAndroidClientImpl(
baseUrl = sp.getString(app.aaps.core.utils.R.string.key_nsclientinternal_url, "").lowercase().replace("https://", "").replace(Regex("/$"), ""),
accessToken = sp.getString(R.string.key_ns_client_token, ""),
context = context,
logging = config.isEngineeringMode() || config.isDev(),
logger = { msg -> aapsLogger.debug(LTag.HTTP, msg) }
)
SystemClock.sleep(2000)
initializeWebSockets(reason)
rxBus.send(EventSWSyncStatus(status))
@ -354,8 +353,28 @@ class NSClientV3Plugin @Inject constructor(
**********************/
private var storageSocket: Socket? = null
private var alarmSocket: Socket? = null
var wsConnected = false
internal var wsConnected = false
internal var initialLoadFinished = false
private fun shutdownWebsockets() {
storageSocket?.on(Socket.EVENT_CONNECT, onConnectStorage)
storageSocket?.on(Socket.EVENT_DISCONNECT, onDisconnectStorage)
storageSocket?.on("create", onDataCreateUpdate)
storageSocket?.on("update", onDataCreateUpdate)
storageSocket?.on("delete", onDataDelete)
storageSocket?.disconnect()
alarmSocket?.on(Socket.EVENT_CONNECT, onConnectAlarms)
alarmSocket?.on(Socket.EVENT_DISCONNECT, onDisconnectAlarm)
alarmSocket?.on("announcement", onAnnouncement)
alarmSocket?.on("alarm", onAlarm)
alarmSocket?.on("urgent_alarm", onUrgentAlarm)
alarmSocket?.on("clear_alarm", onClearAlarm)
alarmSocket?.disconnect()
wsConnected = false
storageSocket = null
alarmSocket = null
}
private fun initializeWebSockets(reason: String) {
if (!sp.getBoolean(app.aaps.core.utils.R.string.key_ns_use_ws, true)) return
if (sp.getString(app.aaps.core.utils.R.string.key_nsclientinternal_url, "").isEmpty()) return
@ -435,13 +454,8 @@ class NSClientV3Plugin @Inject constructor(
rxBus.send(EventNSClientNewLog("► WS", "requesting auth for alarms"))
socket.emit("subscribe", authMessage, Ack { args ->
val response = args[0] as JSONObject
wsConnected = if (response.optBoolean("success")) {
rxBus.send(EventNSClientNewLog("◄ WS", response.optString("message")))
true
} else {
rxBus.send(EventNSClientNewLog("◄ WS", "Auth failed"))
false
}
if (response.optBoolean("success")) rxBus.send(EventNSClientNewLog("◄ WS", response.optString("message")))
else rxBus.send(EventNSClientNewLog("◄ WS", "Auth failed"))
})
}
}

View file

@ -53,6 +53,7 @@
<string name="alarm_battery_out">Vybitá baterie</string>
<string name="alarm_no_calibration">Žádná kalibrace</string>
<string name="pump_time_update_failed">Nepodařilo se aktualizovat časové pásmo pumpy, odložit zprávu a aktualizovat ručně.</string>
<string name="bolus_error">Chyba bolusu</string>
<!-- wizard-->
<string name="retry">Opakovat</string>
<string name="next">Další</string>
@ -101,6 +102,8 @@
<string name="press_retry_or_discard">Stiskněte <b>Další</b> pro obnovení aktivace nebo <b>Zahodit</b> pro resetování stavu aktivace.</string>
<string name="reading_activation_status">Počkejte prosím, čtení stavu aktivace z Patche.</string>
<!-- settings-->
<string name="enable_pump_unreachable_alert_summary">Výstraha při nedostupné pumpě byla vynucena, protože patch pumpa Medtrum může selhat a být nedostupná.</string>
<string name="pump_unreachable_threshold_minutes_summary">Doporučujeme nastavit na 30 minut, protože patch pumpa Medtrum může selhat a být nedostupná.</string>
<string name="sn_input_title">Sériové číslo</string>
<string name="sn_input_summary">Zadejte sériové číslo základny Patche.</string>
<string name="sn_input_invalid">Neplatné sériové číslo!</string>

View file

@ -53,6 +53,7 @@
<string name="alarm_battery_out">Batería agotada</string>
<string name="alarm_no_calibration">Sin calibración</string>
<string name="pump_time_update_failed">Error al actualizar la zona horaria de la bomba, posponer zumbido y actualizar manualmente.</string>
<string name="bolus_error">Error de bolo</string>
<!-- wizard-->
<string name="retry">Reintentar</string>
<string name="next">Siguiente</string>
@ -101,6 +102,8 @@
<string name="press_retry_or_discard">Presiona <b>Siguiente</b> para reanudar la activación o <b>Descartar</b> para restablecer el estado de activación.</string>
<string name="reading_activation_status">Por favor, espera, leyendo el estado de activación de la bomba.</string>
<!-- settings-->
<string name="enable_pump_unreachable_alert_summary">Se ha habilitado la alerta de \"Inaccesible forzada\" debido a la posibilidad de que el parche de Medtrum falle y no pueda ser contactado.</string>
<string name="pump_unreachable_threshold_minutes_summary">Se recomienda configurarlo a 30 minutos, debido a que el parche de Medtrum puede presentar fallos y quedar inaccesible.</string>
<string name="sn_input_title">Número de serie</string>
<string name="sn_input_summary">Introduce el número de serie de la base de la bomba.</string>
<string name="sn_input_invalid">¡Número de serie inválido!</string>

View file

@ -53,6 +53,7 @@
<string name="alarm_battery_out">Batteri er tatt ut</string>
<string name="alarm_no_calibration">Ingen kalibrering</string>
<string name="pump_time_update_failed">Kunne ikke oppdatere tidssone på pumpen. Bekreft meldingen og oppdater manuelt.</string>
<string name="bolus_error">Bolus feilet</string>
<!-- wizard-->
<string name="retry">Prøv igjen</string>
<string name="next">Neste</string>
@ -101,6 +102,8 @@
<string name="press_retry_or_discard">Trykk <b>Neste</b> for å gjenoppta aktiveringen eller <b>Forkast</b> for å tilbakestille aktiveringsstatusen.</string>
<string name="reading_activation_status">Vennligst vent, leser aktiveringsstatus fra pumpen.</string>
<!-- settings-->
<string name="enable_pump_unreachable_alert_summary">Varsel om pumpe utilgjengelig tvinges aktivert, fordi Medtrum-patching kan mislykkes og bli utilgjengelig.</string>
<string name="pump_unreachable_threshold_minutes_summary">Anbefales å sette til 30 minutter, fordi Medtrum-patching kan mislykkes og bli utilgjengelig.</string>
<string name="sn_input_title">Serienummer</string>
<string name="sn_input_summary">Skriv inn serienummeret til pumpens base.</string>
<string name="sn_input_invalid">Ugyldig serienummer!</string>

View file

@ -101,6 +101,8 @@
<string name="press_retry_or_discard">Druk op <b>Volgende</b> om de activering te hervatten of <b>Verwijderen</b> om de activeringsstatus te resetten.</string>
<string name="reading_activation_status">Een ogenblik geduld, activeringsstatus van de pomp wordt gelezen.</string>
<!-- settings-->
<string name="enable_pump_unreachable_alert_summary">Waarschuwing onbereikbare pump geforceerd ingeschakeld, omdat de Medtrum-patch kan falen en onbereikbaar kan zijn.</string>
<string name="pump_unreachable_threshold_minutes_summary">Geadviseerd om op 30 minuten in te stellen, omdat de Medtrum-patch kan falen en onbereikbaar kan zijn.</string>
<string name="sn_input_title">Serienummer</string>
<string name="sn_input_summary">Voer het serienummer van uw pompbasis in.</string>
<string name="sn_input_invalid">Ongeldig serienummer!</string>
@ -108,6 +110,7 @@
<string name="alarm_setting_title">Alarminstellingen</string>
<string name="alarm_setting_summary">Selecteer uw gewenste alarminstellingen voor de pomp.</string>
<string name="pump_warning_notification_title">Notificatie bij pomp waarschuwing</string>
<string name="pump_warning_notification_summary">Melding weergeven op niet-kritische pompwaarschuwingen: batterij bijna leeg, reservoir bijna leeg (20 eenheden) en vervalt bijna. Aanbevolen om ingeschakeld te laten wanneer pomp alarmen op stil zijn ingesteld.</string>
<string name="patch_expiration_title">Patch vervalt</string>
<string name="patch_expiration_summary">Wanneer ingeschakeld, zal de patch na 3 dagen verlopen met een extra periode van 8 uur coulance.</string>
<string name="hourly_max_insulin_title">Maximale insuline per uur</string>

View file

@ -106,9 +106,9 @@
<string name="omnipod_common_preferences_expiration_reminder_enabled">Utløpspåminnelse aktivert</string>
<string name="omnipod_common_preferences_expiration_reminder_enabled_summary">Når aktivert, vil Pod\'en pipe når tidspunktet er nådd</string>
<string name="omnipod_common_preferences_expiration_reminder_hours_before_expiry">Påminnelse før utløp (72 timer)</string>
<string name="omnipod_common_preferences_expiration_alarm_enabled">Utløpspåminnelse aktivert</string>
<string name="omnipod_common_preferences_expiration_alarm_enabled">Nedstengingspåminnelse aktivert</string>
<string name="omnipod_common_preferences_expiration_alarm_enabled_summary">Når aktivert, vil Pod\'en pipe når tidspunktet er nådd og en time før nedstenging</string>
<string name="omnipod_common_preferences_expiration_alarm_hours_before_shutdown">Påminnelse før utløp (80 timer)</string>
<string name="omnipod_common_preferences_expiration_alarm_hours_before_shutdown">Påminnelse før nedstenging (80 timer)</string>
<string name="omnipod_common_preferences_low_reservoir_alert_enabled">Varsel om lavt reservoar aktivert</string>
<string name="omnipod_common_preferences_low_reservoir_alert_units">Antall enheter</string>
<string name="omnipod_common_preferences_automatically_silence_alerts">Demp Pod-varsler automatisk</string>

View file

@ -52,7 +52,7 @@
<string name="omnipod_eros_error_set_time_failed_delivery_suspended">Endring av tid mislyktes. Insulinlevering er pauset! Velg gjenoppta levering manuelt fra Omnipod-fanen.</string>
<string name="omnipod_eros_error_failed_to_read_pulse_log">Feilet i å lese Pulsloggen</string>
<string name="omnipod_eros_error_automatic_time_or_timezone_change_failed">Feilet i forsøket på å endre tid på Pod. Du må gå inn i Omnipod menyen og manuelt synkronisere tiden.</string>
<string name="omnipod_eros_error_operation_not_possible_no_configuration">Operasjon ikke mulig.\n\n Du må konfigurere Medtronic pumpen før du kan bruke denne funksjonen.</string>
<string name="omnipod_eros_error_operation_not_possible_no_configuration">Operasjon ikke mulig.\n\nDu må konfigurere Omnipod før du kan bruke denne funksjonen.</string>
<string name="omnipod_eros_error_bolus_failed_uncertain">Kan ikke kontrollere om bolusdosen ble gitt. Kontroller at Pod\'en gir bolus ved å lytte etter klikkk. <b>Dersom du er sikker på at bolusen ikke var vellykket, bør du manuelt slette bolusoppføring fra Behandlingene, selv om du klikker \'Avbryt bolus\' nå!</b></string>
<string name="omnipod_eros_error_bolus_failed_uncertain_smb">Klarte ikke å bekrefte om SMB bolus (%1$.2f E) ble gitt. <b>Hvis du er helt sikker på at Bolus ikke ble levert, da bør du manuelt slette SMB-oppføringen fra Behandlinger.</b></string>
<string name="omnipod_eros_error_tbr_running_but_aaps_not_aware">En midlertidig basal utføres på Pod, men AAPS har ingen informasjon om denne midlertidige basalen. Vennligst avbryt midlertidig basal manuelt.</string>