From 735ff383d9e86c811a06aa30b92d66ee60938bab Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Wed, 27 Oct 2021 01:24:41 +0200 Subject: [PATCH 01/29] Add some color to History --- .../omnipod/dash/ui/DashPodHistoryActivity.kt | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index fba505ffaa..263e8831a7 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -211,8 +211,40 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } } + private fun getTextColor(commandType: OmnipodCommandType): Int { + val textColor = when (commandType) { + // Operational + OmnipodCommandType.INITIALIZE_POD, + OmnipodCommandType.CONFIGURE_ALERTS, + OmnipodCommandType.INSERT_CANNULA, + OmnipodCommandType.DEACTIVATE_POD, + OmnipodCommandType.DISCARD_POD, + OmnipodCommandType.SUSPEND_DELIVERY, + OmnipodCommandType.RESUME_DELIVERY, + OmnipodCommandType.SET_BASAL_PROFILE -> { + android.graphics.Color.CYAN + } + // User action + OmnipodCommandType.PLAY_TEST_BEEP, + OmnipodCommandType.ACKNOWLEDGE_ALERTS, + OmnipodCommandType.CANCEL_BOLUS -> { + android.graphics.Color.GREEN + } + // Insulin treatment + OmnipodCommandType.SET_BOLUS, + OmnipodCommandType.SET_TEMPORARY_BASAL -> { + android.graphics.Color.WHITE + } + else -> + // Other + android.graphics.Color.LTGRAY + } + return textColor + } + private fun setType(record: HistoryRecord, typeView: TextView) { typeView.text = resourceHelper.gs(record.commandType.resourceId) + typeView.setTextColor(getTextColor(record.commandType)) } private fun setValue(historyEntry: HistoryRecord, valueView: TextView) { @@ -245,6 +277,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { else -> "" } + valueView.setTextColor(getTextColor(historyEntry.commandType)) } override fun getItemCount(): Int { From f96727224df491fa978d264028a84939aeda7fbe Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Wed, 27 Oct 2021 22:46:38 +0200 Subject: [PATCH 02/29] Add some color to History, include success state --- .../omnipod/dash/ui/DashPodHistoryActivity.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index 263e8831a7..15f7e57b81 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -211,8 +211,14 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } } - private fun getTextColor(commandType: OmnipodCommandType): Int { - val textColor = when (commandType) { + private fun setTextViewColor(includeresult: Boolean, textview: TextView, record: HistoryRecord) { + if (includeresult && !record.isSuccess()) { + // Record says not success + textview.setTextColor(android.graphics.Color.YELLOW) + return + } + // On success set color + val textColor = when (record.commandType) { // Operational OmnipodCommandType.INITIALIZE_POD, OmnipodCommandType.CONFIGURE_ALERTS, @@ -239,12 +245,13 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { // Other android.graphics.Color.LTGRAY } - return textColor + textview.setTextColor(textColor) } private fun setType(record: HistoryRecord, typeView: TextView) { typeView.text = resourceHelper.gs(record.commandType.resourceId) - typeView.setTextColor(getTextColor(record.commandType)) + // Set some color, include result + setTextViewColor(includeresult=true, typeView, record) } private fun setValue(historyEntry: HistoryRecord, valueView: TextView) { @@ -277,7 +284,8 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { else -> "" } - valueView.setTextColor(getTextColor(historyEntry.commandType)) + // Set some color + setTextViewColor(includeresult=false, valueView, historyEntry) } override fun getItemCount(): Int { From b6451850057bff0fc7a85de05de1d496c91848af Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Wed, 27 Oct 2021 22:54:09 +0200 Subject: [PATCH 03/29] Refactoring name --- .../pump/omnipod/dash/ui/DashPodHistoryActivity.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index 15f7e57b81..f0b5709ea5 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -211,8 +211,8 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } } - private fun setTextViewColor(includeresult: Boolean, textview: TextView, record: HistoryRecord) { - if (includeresult && !record.isSuccess()) { + private fun setTextViewColor(check_result: Boolean, textview: TextView, record: HistoryRecord) { + if (check_result && !record.isSuccess()) { // Record says not success textview.setTextColor(android.graphics.Color.YELLOW) return @@ -251,7 +251,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { private fun setType(record: HistoryRecord, typeView: TextView) { typeView.text = resourceHelper.gs(record.commandType.resourceId) // Set some color, include result - setTextViewColor(includeresult=true, typeView, record) + setTextViewColor(check_result=true, typeView, record) } private fun setValue(historyEntry: HistoryRecord, valueView: TextView) { @@ -285,7 +285,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { "" } // Set some color - setTextViewColor(includeresult=false, valueView, historyEntry) + setTextViewColor(check_result=false, valueView, historyEntry) } override fun getItemCount(): Int { From d966254815a50b35d3db231a8226ad4121f32622 Mon Sep 17 00:00:00 2001 From: Theo van Elsberg Date: Sat, 30 Oct 2021 01:14:17 +0200 Subject: [PATCH 04/29] klint --- .../omnipod/dash/ui/DashPodHistoryActivity.kt | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index f0b5709ea5..82d885f7fa 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -56,47 +56,48 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { private fun groupForCommandType(type: OmnipodCommandType): PumpHistoryEntryGroup { return when (type) { - OmnipodCommandType.INITIALIZE_POD -> + OmnipodCommandType.INITIALIZE_POD -> PumpHistoryEntryGroup.Prime - OmnipodCommandType.INSERT_CANNULA -> + OmnipodCommandType.INSERT_CANNULA -> PumpHistoryEntryGroup.Prime - OmnipodCommandType.DEACTIVATE_POD -> + OmnipodCommandType.DEACTIVATE_POD -> PumpHistoryEntryGroup.Prime - OmnipodCommandType.DISCARD_POD -> + OmnipodCommandType.DISCARD_POD -> PumpHistoryEntryGroup.Prime OmnipodCommandType.CANCEL_TEMPORARY_BASAL -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.SET_BASAL_PROFILE -> + OmnipodCommandType.SET_BASAL_PROFILE -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.SET_TEMPORARY_BASAL -> + OmnipodCommandType.SET_TEMPORARY_BASAL -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.RESUME_DELIVERY -> + OmnipodCommandType.RESUME_DELIVERY -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.SUSPEND_DELIVERY -> + OmnipodCommandType.SUSPEND_DELIVERY -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.SET_BOLUS -> + OmnipodCommandType.SET_BOLUS -> PumpHistoryEntryGroup.Bolus - OmnipodCommandType.CANCEL_BOLUS -> + OmnipodCommandType.CANCEL_BOLUS -> PumpHistoryEntryGroup.Bolus - OmnipodCommandType.ACKNOWLEDGE_ALERTS -> + OmnipodCommandType.ACKNOWLEDGE_ALERTS -> PumpHistoryEntryGroup.Alarm - OmnipodCommandType.CONFIGURE_ALERTS -> + OmnipodCommandType.CONFIGURE_ALERTS -> PumpHistoryEntryGroup.Alarm - OmnipodCommandType.PLAY_TEST_BEEP -> + OmnipodCommandType.PLAY_TEST_BEEP -> PumpHistoryEntryGroup.Alarm - OmnipodCommandType.GET_POD_STATUS -> + OmnipodCommandType.GET_POD_STATUS -> PumpHistoryEntryGroup.Configuration - OmnipodCommandType.SET_TIME -> + OmnipodCommandType.SET_TIME -> PumpHistoryEntryGroup.Configuration - OmnipodCommandType.READ_POD_PULSE_LOG -> + OmnipodCommandType.READ_POD_PULSE_LOG -> PumpHistoryEntryGroup.Unknown } } + private fun filterHistory(group: PumpHistoryEntryGroup) { filteredHistoryList.clear() aapsLogger.debug(LTag.PUMP, "Items on full list: {}", fullHistoryList.size) @@ -227,7 +228,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { OmnipodCommandType.DISCARD_POD, OmnipodCommandType.SUSPEND_DELIVERY, OmnipodCommandType.RESUME_DELIVERY, - OmnipodCommandType.SET_BASAL_PROFILE -> { + OmnipodCommandType.SET_BASAL_PROFILE -> { android.graphics.Color.CYAN } // User action @@ -241,6 +242,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { OmnipodCommandType.SET_TEMPORARY_BASAL -> { android.graphics.Color.WHITE } + else -> // Other android.graphics.Color.LTGRAY @@ -251,7 +253,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { private fun setType(record: HistoryRecord, typeView: TextView) { typeView.text = resourceHelper.gs(record.commandType.resourceId) // Set some color, include result - setTextViewColor(check_result=true, typeView, record) + setTextViewColor(check_result = true, typeView, record) } private fun setValue(historyEntry: HistoryRecord, valueView: TextView) { @@ -268,24 +270,27 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { resourceHelper.gs(R.string.omnipod_common_history_tbr_value, it.rate, it.duration) } ?: "n/a" } - OmnipodCommandType.SET_BOLUS -> { + + OmnipodCommandType.SET_BOLUS -> { val bolus = historyEntry.record as BolusRecord bolus?.let { resourceHelper.gs(R.string.omnipod_common_history_bolus_value, it.amout) } ?: "n/a" } + OmnipodCommandType.SET_BASAL_PROFILE, OmnipodCommandType.SET_TIME, OmnipodCommandType.INSERT_CANNULA, - OmnipodCommandType.RESUME_DELIVERY -> { + OmnipodCommandType.RESUME_DELIVERY -> { val basal = historyEntry.record as BasalValuesRecord ProfileUtil.getBasalProfilesDisplayable(basal.segments.toTypedArray(), PumpType.OMNIPOD_DASH) } - else -> + + else -> "" } // Set some color - setTextViewColor(check_result=false, valueView, historyEntry) + setTextViewColor(check_result = false, valueView, historyEntry) } override fun getItemCount(): Int { @@ -293,6 +298,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } inner class HistoryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val timeView: TextView = itemView.findViewById(R.id.omnipod_history_time) val typeView: TextView = itemView.findViewById(R.id.omnipod_history_source) val valueView: TextView = itemView.findViewById(R.id.omnipod_history_description) @@ -303,17 +309,18 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { return when { historyEntry.initialResult == InitialResult.FAILURE_SENDING -> R.string.omnipod_dash_failed_to_send - historyEntry.initialResult == InitialResult.NOT_SENT -> + historyEntry.initialResult == InitialResult.NOT_SENT -> R.string.omnipod_dash_command_not_sent historyEntry.initialResult == InitialResult.SENT && - historyEntry.resolvedResult == ResolvedResult.FAILURE -> + historyEntry.resolvedResult == ResolvedResult.FAILURE -> R.string.omnipod_dash_command_not_received_by_the_pod - else -> + else -> R.string.omnipod_dash_unknown } } companion object { + private var selectedGroup: PumpHistoryEntryGroup = PumpHistoryEntryGroup.All const val DAYS_TO_DISPLAY = 5 } From c68491ba78447b193e833e322dc8c546ec430f1d Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Sun, 31 Oct 2021 00:22:50 +0200 Subject: [PATCH 05/29] fix deactivation --- .../omnipod/dash/OmnipodDashPumpPlugin.kt | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index 4db2aa2bc1..f320cc0150 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -310,8 +310,8 @@ class OmnipodDashPumpPlugin @Inject constructor( ) private fun checkPodKaput(): Completable = Completable.defer { - val tbr = pumpSync.expectedPumpState().temporaryBasal if (podStateManager.isPodKaput) { + val tbr = pumpSync.expectedPumpState().temporaryBasal if (tbr == null || tbr.rate != 0.0) { pumpSync.syncTemporaryBasalWithPumpId( timestamp = System.currentTimeMillis(), @@ -340,20 +340,23 @@ class OmnipodDashPumpPlugin @Inject constructor( aapsLogger.info(LTag.PUMP, "syncBolusWithPumpId on CANCEL_BOLUS returned: $sync") } } - showNotification( - Notification.OMNIPOD_POD_FAULT, - podStateManager.alarmType.toString(), - Notification.URGENT, - R.raw.boluserror - ) - if (!podStateManager.alarmSynced) { - pumpSync.insertAnnouncement( - error = podStateManager.alarmType?.toString() ?: "Unknown pod failure", - pumpId = Random.Default.nextLong(), - pumpType = PumpType.OMNIPOD_DASH, - pumpSerial = serialNumber() + + podStateManager.alarmType?.let { + showNotification( + Notification.OMNIPOD_POD_FAULT, + it.toString(), + Notification.URGENT, + R.raw.boluserror ) - podStateManager.alarmSynced = true + if (!podStateManager.alarmSynced) { + pumpSync.insertAnnouncement( + error = it.toString(), + pumpId = Random.Default.nextLong(), + pumpType = PumpType.OMNIPOD_DASH, + pumpSerial = serialNumber() + ) + podStateManager.alarmSynced = true + } } } Completable.complete() @@ -1165,14 +1168,14 @@ class OmnipodDashPumpPlugin @Inject constructor( val ret = executeProgrammingCommand( historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD), command = omnipodManager.deactivatePod().ignoreElements(), - checkNoActiveCommand = false, - post = createFakeTBRWhenNoActivePod(), + checkNoActiveCommand = false ).doOnComplete { if (podStateManager.activeCommand != null) { success = false + } else { + podStateManager.reset() + rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT)) } - podStateManager.reset() - rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT)) }.toPumpEnactResult() if (!success) { ret.success(false) From 2b71bfdeb078941345c084ced6ee33da8f572fad Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 31 Oct 2021 17:24:15 +0100 Subject: [PATCH 06/29] hide button without active profile --- .../info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index 1f0dc67dcd..5e892563b1 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -137,6 +137,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { } else { binding.reuselayout.visibility = View.GONE } + else binding.reuselayout.visibility = View.GONE } binding.ttLayout.visibility = View.GONE } From ba9a5dc97be7a7ee2fec670b8a1a4f0bd836d716 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 31 Oct 2021 17:44:04 +0100 Subject: [PATCH 07/29] better handle wrong profile --- .../androidaps/dialogs/ProfileSwitchDialog.kt | 63 ++++++++++--------- .../ProfileFunctionImplementation.kt | 12 ++-- .../smsCommunicator/SmsCommunicatorPlugin.kt | 15 +++-- .../automation/actions/ActionProfileSwitch.kt | 4 +- .../actions/ActionProfileSwitchPercent.kt | 3 +- .../androidaps/interfaces/ProfileFunction.kt | 6 +- 6 files changed, 56 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index 5e892563b1..732070815c 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -178,47 +178,48 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { actions.add(resourceHelper.gs(R.string.careportal_temporarytarget) + ": " + resourceHelper.gs(R.string.activity)) activity?.let { activity -> - val ps = profileFunction.buildProfileSwitch(profileStore, profileName, duration, percent, timeShift, eventTime) + val ps = profileFunction.buildProfileSwitch(profileStore, profileName, duration, percent, timeShift, eventTime) ?: return@let val validity = ProfileSealed.PS(ps).isValid(resourceHelper.gs(R.string.careportal_profileswitch), activePlugin.activePump, config, resourceHelper, rxBus, hardLimits, false) if (validity.isValid) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - profileFunction.createProfileSwitch( + if (profileFunction.createProfileSwitch( profileStore, profileName = profileName, durationInMinutes = duration, percentage = percent, timeShiftInHours = timeShift, timestamp = eventTime - ) - uel.log(Action.PROFILE_SWITCH, - Sources.ProfileSwitchDialog, - notes, - ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, - ValueWithUnit.SimpleString(profileName), - ValueWithUnit.Percent(percent), - ValueWithUnit.Hour(timeShift).takeIf { timeShift != 0 }, - ValueWithUnit.Minute(duration).takeIf { duration != 0 }) - if (percent == 90 && duration == 10) sp.putBoolean(R.string.key_objectiveuseprofileswitch, true) - if (isTT) { - disposable += repository.runTransactionForResult( - InsertAndCancelCurrentTemporaryTargetTransaction( - timestamp = eventTime, - duration = TimeUnit.MINUTES.toMillis(duration.toLong()), - reason = TemporaryTarget.Reason.ACTIVITY, - lowTarget = Profile.toMgdl(target, profileFunction.getUnits()), - highTarget = Profile.toMgdl(target, profileFunction.getUnits()) + )) { + uel.log(Action.PROFILE_SWITCH, + Sources.ProfileSwitchDialog, + notes, + ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, + ValueWithUnit.SimpleString(profileName), + ValueWithUnit.Percent(percent), + ValueWithUnit.Hour(timeShift).takeIf { timeShift != 0 }, + ValueWithUnit.Minute(duration).takeIf { duration != 0 }) + if (percent == 90 && duration == 10) sp.putBoolean(R.string.key_objectiveuseprofileswitch, true) + if (isTT) { + disposable += repository.runTransactionForResult( + InsertAndCancelCurrentTemporaryTargetTransaction( + timestamp = eventTime, + duration = TimeUnit.MINUTES.toMillis(duration.toLong()), + reason = TemporaryTarget.Reason.ACTIVITY, + lowTarget = Profile.toMgdl(target, profileFunction.getUnits()), + highTarget = Profile.toMgdl(target, profileFunction.getUnits()) + ) + ).subscribe({ result -> + result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } + result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } + }, { + aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) + }) + uel.log( + Action.TT, Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason( + TemporaryTarget.Reason.ACTIVITY + ), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration) ) - ).subscribe({ result -> - result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") } - result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") } - }, { - aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) - }) - uel.log( - Action.TT, Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason( - TemporaryTarget.Reason.ACTIVITY - ), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration) - ) + } } }) else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt index 9cf9338901..7411792996 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ProfileFunctionImplementation.kt @@ -141,9 +141,8 @@ class ProfileFunctionImplementation @Inject constructor( if (sp.getString(R.string.key_units, Constants.MGDL) == Constants.MGDL) GlucoseUnit.MGDL else GlucoseUnit.MMOL - override fun buildProfileSwitch(profileStore: ProfileStore, profileName: String, durationInMinutes: Int, percentage: Int, timeShiftInHours: Int, timestamp: Long): ProfileSwitch { - val pureProfile = profileStore.getSpecificProfile(profileName) - ?: throw InvalidParameterSpecException(profileName) + override fun buildProfileSwitch(profileStore: ProfileStore, profileName: String, durationInMinutes: Int, percentage: Int, timeShiftInHours: Int, timestamp: Long): ProfileSwitch? { + val pureProfile = profileStore.getSpecificProfile(profileName) ?: return null return ProfileSwitch( timestamp = timestamp, basalBlocks = pureProfile.basalBlocks, @@ -161,8 +160,8 @@ class ProfileFunctionImplementation @Inject constructor( ) } - override fun createProfileSwitch(profileStore: ProfileStore, profileName: String, durationInMinutes: Int, percentage: Int, timeShiftInHours: Int, timestamp: Long) { - val ps = buildProfileSwitch(profileStore, profileName, durationInMinutes, percentage, timeShiftInHours, timestamp) + override fun createProfileSwitch(profileStore: ProfileStore, profileName: String, durationInMinutes: Int, percentage: Int, timeShiftInHours: Int, timestamp: Long): Boolean { + val ps = buildProfileSwitch(profileStore, profileName, durationInMinutes, percentage, timeShiftInHours, timestamp) ?: return false disposable += repository.runTransactionForResult(InsertOrUpdateProfileSwitch(ps)) .subscribe({ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted ProfileSwitch $it") } @@ -170,12 +169,13 @@ class ProfileFunctionImplementation @Inject constructor( }, { aapsLogger.error(LTag.DATABASE, "Error while saving ProfileSwitch", it) }) + return true } override fun createProfileSwitch(durationInMinutes: Int, percentage: Int, timeShiftInHours: Int): Boolean { val profile = repository.getPermanentProfileSwitch(dateUtil.now()) ?: return false val profileStore = activePlugin.activeProfileSource.profile ?: return false - val ps = buildProfileSwitch(profileStore, profile.profileName, durationInMinutes, percentage, 0, dateUtil.now()) + val ps = buildProfileSwitch(profileStore, profile.profileName, durationInMinutes, percentage, 0, dateUtil.now()) ?: return false val validity = ProfileSealed.PS(ps).isValid( resourceHelper.gs(info.nightscout.androidaps.automation.R.string.careportal_profileswitch), activePlugin.activePump, diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index 883bab601f..c551f166ef 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -605,11 +605,16 @@ class SmsCommunicatorPlugin @Inject constructor( val finalPercentage = percentage messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(pumpCommand = true, list[pIndex - 1] as String, finalPercentage) { override fun run() { - profileFunction.createProfileSwitch(store, list[pIndex - 1] as String, 0, finalPercentage, 0, dateUtil.now()) - val replyText = resourceHelper.gs(R.string.profileswitchcreated) - sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.PROFILE_SWITCH, Sources.SMS, resourceHelper.gs(R.string.profileswitchcreated), - ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.profileswitchcreated))) + if (profileFunction.createProfileSwitch(store, list[pIndex - 1] as String, 0, finalPercentage, 0, dateUtil.now())) { + val replyText = resourceHelper.gs(R.string.profileswitchcreated) + sendSMS(Sms(receivedSms.phoneNumber, replyText)) + uel.log( + Action.PROFILE_SWITCH, Sources.SMS, resourceHelper.gs(R.string.profileswitchcreated), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.profileswitchcreated)) + ) + } else { + sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.invalidprofile))) + } } }) } diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt index 38985b833a..49c52a514c 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt @@ -62,8 +62,8 @@ class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) { uel.log(UserEntry.Action.PROFILE_SWITCH, Sources.Automation, title, ValueWithUnit.SimpleString(inputProfileName.value), ValueWithUnit.Percent(100)) - profileFunction.createProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, dateUtil.now()) - callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() + val result = profileFunction.createProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, dateUtil.now()) + callback.result(PumpEnactResult(injector).success(result).comment(R.string.ok))?.run() } override fun generateDialog(root: LinearLayout) { diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt index 0634021564..b9f6c74de5 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt @@ -52,10 +52,11 @@ class ActionProfileSwitchPercent(injector: HasAndroidInjector) : Action(injector ValueWithUnit.Percent(pct.value.toInt()), ValueWithUnit.Minute(duration.value) ) + callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() } else { aapsLogger.error(LTag.AUTOMATION, "Final profile not valid") + callback.result(PumpEnactResult(injector).success(false).comment(R.string.ok))?.run() } - callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() } override fun generateDialog(root: LinearLayout) { diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileFunction.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileFunction.kt index 03b2f03590..73d20102b4 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileFunction.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileFunction.kt @@ -55,8 +55,9 @@ interface ProfileFunction { * @param percentage 100 = no modification * @param timeShiftInHours 0 = no modification * @param timestamp expected time + * @return null if profile cannot be created from profile store */ - fun buildProfileSwitch(profileStore: ProfileStore, profileName: String, durationInMinutes: Int, percentage: Int, timeShiftInHours: Int, timestamp: Long): ProfileSwitch + fun buildProfileSwitch(profileStore: ProfileStore, profileName: String, durationInMinutes:Int, percentage: Int, timeShiftInHours: Int, timestamp: Long): ProfileSwitch? /** * Create a new circadian profile switch request based on provided profile @@ -67,8 +68,9 @@ interface ProfileFunction { * @param percentage 100 = no modification * @param timeShiftInHours 0 = no modification * @param timestamp expected time + * @return true if profile was created from store */ - fun createProfileSwitch(profileStore: ProfileStore, profileName: String, durationInMinutes: Int, percentage: Int, timeShiftInHours: Int, timestamp: Long) + fun createProfileSwitch(profileStore: ProfileStore, profileName: String, durationInMinutes: Int, percentage: Int, timeShiftInHours: Int, timestamp: Long): Boolean /** * Create a new circadian profile switch request based on currently selected profile interface and default profile From a7ce4c0150627dbe85604a401067966d789ca028 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 31 Oct 2021 17:46:22 +0100 Subject: [PATCH 08/29] view param nullable --- .../plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index 8cece0c509..ed146577ea 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -157,7 +157,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { historyTypeSpinner?.run { adapter = spinnerAdapter onItemSelectedListener = object : AdapterView.OnItemSelectedListener { - override fun onItemSelected(parent: AdapterView<*>?, view: View, position: Int, id: Long) { + override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { if (manualChange) return val selected = selectedItem as TypeList selectedGroup = selected.entryGroup From 543719b0916fca1f3f7d1c4d15ee3f221c7ba3d8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 31 Oct 2021 17:51:43 +0100 Subject: [PATCH 09/29] prevent NPE --- .../pump/omnipod/eros/manager/AapsOmnipodErosManager.java | 2 +- .../omnipod/eros/rileylink/service/RileyLinkOmnipodService.java | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsOmnipodErosManager.java b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsOmnipodErosManager.java index 097b8145bb..7f1c88fc47 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsOmnipodErosManager.java +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/manager/AapsOmnipodErosManager.java @@ -385,7 +385,7 @@ public class AapsOmnipodErosManager { if (detailedBolusInfo.getBolusType() == DetailedBolusInfo.BolusType.SMB) { showNotification(Notification.OMNIPOD_UNCERTAIN_SMB, getStringResource(R.string.omnipod_eros_error_bolus_failed_uncertain_smb, detailedBolusInfo.insulin), Notification.URGENT, isNotificationUncertainSmbSoundEnabled() ? R.raw.boluserror : null); } else { - showErrorDialog(getStringResource(R.string.omnipod_eros_error_bolus_failed_uncertain), isNotificationUncertainBolusSoundEnabled() ? R.raw.boluserror : null); + showErrorDialog(getStringResource(R.string.omnipod_eros_error_bolus_failed_uncertain), isNotificationUncertainBolusSoundEnabled() ? R.raw.boluserror : 0); } } diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/rileylink/service/RileyLinkOmnipodService.java b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/rileylink/service/RileyLinkOmnipodService.java index 090e754eb2..79f598dea2 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/rileylink/service/RileyLinkOmnipodService.java +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/rileylink/service/RileyLinkOmnipodService.java @@ -19,8 +19,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService; import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin; import info.nightscout.androidaps.plugins.pump.omnipod.eros.R; -import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.manager.ErosPodStateManager; -import info.nightscout.androidaps.plugins.pump.omnipod.eros.manager.AapsOmnipodErosManager; import info.nightscout.androidaps.plugins.pump.omnipod.eros.rileylink.manager.OmnipodRileyLinkCommunicationManager; import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.AapsOmnipodUtil; From 085ff63d639ad808b382263ca8f9559cd8726d7b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 1 Nov 2021 08:03:48 +0100 Subject: [PATCH 10/29] fix tests --- .../plugins/general/automation/TestBaseWithProfile.kt | 2 +- .../automation/actions/ActionProfileSwitchPercentTest.kt | 2 ++ .../general/automation/actions/ActionProfileSwitchTest.kt | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestBaseWithProfile.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestBaseWithProfile.kt index 79a9b09d7f..e384bb4b3d 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestBaseWithProfile.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/TestBaseWithProfile.kt @@ -34,7 +34,7 @@ open class TestBaseWithProfile : TestBase() { val rxBus = RxBus(aapsSchedulers, aapsLogger) - val profileInjector = HasAndroidInjector { + private val profileInjector = HasAndroidInjector { AndroidInjector { } } diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercentTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercentTest.kt index 60a109bd62..b1ea596b24 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercentTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercentTest.kt @@ -7,6 +7,7 @@ import info.nightscout.androidaps.queue.Callback import org.junit.Assert import org.junit.Before import org.junit.Test +import org.mockito.ArgumentMatchers import org.mockito.Mockito import org.mockito.Mockito.`when` @@ -38,6 +39,7 @@ class ActionProfileSwitchPercentTest : ActionsTestBase() { } @Test fun doActionTest() { + `when`(profileFunction.createProfileSwitch(Mockito.anyInt(), Mockito.anyInt(), Mockito.anyInt())).thenReturn(true) sut.pct = InputPercent(110.0) sut.duration = InputDuration(30, InputDuration.TimeUnit.MINUTES) sut.doAction(object : Callback() { diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchTest.kt index c15d1030b0..6af8a3711e 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchTest.kt @@ -80,6 +80,7 @@ class ActionProfileSwitchTest : ActionsTestBase() { // do profile switch `when`(profileFunction.getProfileName()).thenReturn("Test") + `when`(profileFunction.createProfileSwitch(anyObject(), anyString(), anyInt(), anyInt(), anyInt(), anyLong())).thenReturn(true) sut.inputProfileName = InputProfileName(resourceHelper, activePlugin, TESTPROFILENAME) sut.doAction(object : Callback() { override fun run() { From 6f6b3791562f092ef4645d938cfb324fecf3c1ba Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 1 Nov 2021 09:12:18 +0100 Subject: [PATCH 11/29] fix tests --- .../general/smsCommunicator/SmsCommunicatorPluginTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt index a56824dd4c..7f2fdcee82 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPluginTest.kt @@ -225,6 +225,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { `when`(resourceHelper.gs(R.string.smscommunicator_pumpdisconnected)).thenReturn("Pump disconnected") `when`(resourceHelper.gs(R.string.smscommunicator_code_from_authenticator_for)).thenReturn("from Authenticator app for: %1\$s followed by PIN") `when`(resourceHelper.gs(R.string.patient_name_default)).thenReturn("User") + `when`(resourceHelper.gs(R.string.invalidprofile)).thenReturn("Invalid profile !!!") `when`(resourceHelper.gsNotLocalised(R.string.loopsuspended)).thenReturn("Loop suspended") `when`(resourceHelper.gsNotLocalised(R.string.smscommunicator_stoppedsms)).thenReturn("SMS Remote Service stopped. To reactivate it, use AAPS on master smartphone.") `when`(resourceHelper.gsNotLocalised(R.string.profileswitchcreated)).thenReturn("Profile switch created") @@ -707,6 +708,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() { Assert.assertTrue(smsCommunicatorPlugin.messages[1].text.contains("To switch profile to someProfile 100% reply with code")) //PROFILE 1 90(OK) + `when`(profileFunction.createProfileSwitch(anyObject(), Mockito.anyString(), Mockito.anyInt(), Mockito.anyInt(), Mockito.anyInt(), anyLong())).thenReturn(true) smsCommunicatorPlugin.messages = ArrayList() sms = Sms("1234", "PROFILE 1 90") smsCommunicatorPlugin.processSms(sms) From c0f12d3203a0fad076ecc6fdc5f6afd03dde0b80 Mon Sep 17 00:00:00 2001 From: Philoul Date: Mon, 1 Nov 2021 12:55:35 +0100 Subject: [PATCH 12/29] Less default colors in UserEntries --- .../androidaps/database/entities/UserEntry.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt b/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt index a0981c1b56..889f365ec4 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt @@ -64,23 +64,23 @@ data class UserEntry( CALIBRATION (ColorGroup.Careportal), PRIME_BOLUS (ColorGroup.Pump), TREATMENT (ColorGroup.InsulinTreatment), - CAREPORTAL_NS_REFRESH (ColorGroup.Aaps), - PROFILE_SWITCH_NS_REFRESH (ColorGroup.Aaps), - TREATMENTS_NS_REFRESH (ColorGroup.Aaps), - TT_NS_REFRESH (ColorGroup.Aaps), + CAREPORTAL_NS_REFRESH (ColorGroup.Careportal), + PROFILE_SWITCH_NS_REFRESH (ColorGroup.Profile), + TREATMENTS_NS_REFRESH (ColorGroup.InsulinTreatment), + TT_NS_REFRESH (ColorGroup.TT), AUTOMATION_REMOVED (ColorGroup.Aaps), BG_REMOVED (ColorGroup.Aaps), - CAREPORTAL_REMOVED (ColorGroup.Aaps), - EXTENDED_BOLUS_REMOVED (ColorGroup.Aaps), + CAREPORTAL_REMOVED (ColorGroup.Careportal), + EXTENDED_BOLUS_REMOVED (ColorGroup.InsulinTreatment), FOOD_REMOVED (ColorGroup.CarbTreatment), PROFILE_REMOVED (ColorGroup.Profile), - PROFILE_SWITCH_REMOVED (ColorGroup.Aaps), + PROFILE_SWITCH_REMOVED (ColorGroup.Profile), RESTART_EVENTS_REMOVED (ColorGroup.Aaps), - TREATMENT_REMOVED (ColorGroup.Aaps), - BOLUS_REMOVED (ColorGroup.Aaps), - CARBS_REMOVED (ColorGroup.Aaps), - TEMP_BASAL_REMOVED (ColorGroup.Aaps), - TT_REMOVED (ColorGroup.Aaps), + TREATMENT_REMOVED (ColorGroup.InsulinTreatment), + BOLUS_REMOVED (ColorGroup.InsulinTreatment), + CARBS_REMOVED (ColorGroup.CarbTreatment), + TEMP_BASAL_REMOVED (ColorGroup.BasalTreatment), + TT_REMOVED (ColorGroup.TT), NS_PAUSED (ColorGroup.Aaps), NS_RESUME (ColorGroup.Aaps), NS_QUEUE_CLEARED (ColorGroup.Aaps), From 561f88e4ff59403b4a2811746d19d62a21057c2f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 1 Nov 2021 17:17:28 +0100 Subject: [PATCH 13/29] New Crowdin updates (#800) * New translations strings.xml (Romanian) * New translations strings.xml (Tamil) * New translations strings.xml (Slovak) * New translations strings.xml (Slovenian) * New translations strings.xml (Swedish) * New translations strings.xml (Turkish) * New translations strings.xml (Chinese Simplified) * New translations strings.xml (Portuguese, Brazilian) * New translations strings.xml (Croatian) * New translations strings.xml (Portuguese) * New translations strings.xml (Russian) * New translations strings.xml (Polish) * New translations strings.xml (French) * New translations strings.xml (German) * New translations strings.xml (Spanish) * New translations strings.xml (Afrikaans) * New translations strings.xml (Bulgarian) * New translations strings.xml (Catalan) * New translations strings.xml (Czech) * New translations strings.xml (Danish) * New translations strings.xml (Greek) * New translations strings.xml (Norwegian) * New translations strings.xml (Irish) * New translations strings.xml (Hebrew) * New translations strings.xml (Italian) * New translations strings.xml (Korean) * New translations strings.xml (Lithuanian) * New translations strings.xml (Dutch) * New translations strings.xml (Dutch) * New translations strings.xml (Hebrew) * New translations strings.xml (Hebrew) * New translations strings.xml (Hebrew) * New translations strings.xml (Hebrew) * New translations strings.xml (Hebrew) * New translations strings.xml (Hebrew) * New translations strings.xml (Hebrew) * New translations strings.xml (Hebrew) * New translations strings.xml (Norwegian) * New translations strings.xml (Norwegian) * New translations strings.xml (Norwegian) * New translations strings.xml (Norwegian) * New translations strings.xml (Russian) * New translations strings.xml (Russian) * New translations strings.xml (Dutch) * New translations strings.xml (Russian) * New translations strings.xml (Hebrew) * New translations strings.xml (Czech) * New translations strings.xml (French) * New translations strings.xml (Italian) * New translations strings.xml (French) * New translations strings.xml (French) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Italian) * New translations strings.xml (Italian) --- app/src/main/res/values-fr-rFR/strings.xml | 1 + app/src/main/res/values-it-rIT/strings.xml | 5 +++++ app/src/main/res/values-iw-rIL/strings.xml | 3 ++- app/src/main/res/values-nl-rNL/strings.xml | 8 +++++++- app/src/main/res/values-no-rNO/strings.xml | 7 +++++++ app/src/main/res/values-ru-rRU/strings.xml | 1 + .../src/main/res/values-fr-rFR/strings.xml | 2 ++ .../src/main/res/values-it-rIT/strings.xml | 2 ++ .../src/main/res/values-iw-rIL/strings.xml | 2 ++ .../src/main/res/values-no-rNO/strings.xml | 2 ++ .../src/main/res/values-ru-rRU/strings.xml | 2 ++ core/src/main/res/values-it-rIT/strings.xml | 2 +- core/src/main/res/values-iw-rIL/strings.xml | 4 ++-- core/src/main/res/values-no-rNO/strings.xml | 1 + dana/src/main/res/values-iw-rIL/strings.xml | 2 +- .../src/main/res/values-af-rZA/strings.xml | 1 + .../src/main/res/values-bg-rBG/strings.xml | 1 + .../src/main/res/values-ca-rES/strings.xml | 1 + .../src/main/res/values-cs-rCZ/strings.xml | 15 +++++++++++++++ .../src/main/res/values-da-rDK/strings.xml | 1 + .../src/main/res/values-de-rDE/strings.xml | 15 +++++++++++++++ .../src/main/res/values-el-rGR/strings.xml | 1 + .../src/main/res/values-es-rES/strings.xml | 1 + .../src/main/res/values-fr-rFR/strings.xml | 15 +++++++++++++++ .../src/main/res/values-ga-rIE/strings.xml | 1 + .../src/main/res/values-hr-rHR/strings.xml | 1 + .../src/main/res/values-it-rIT/strings.xml | 15 +++++++++++++++ .../src/main/res/values-iw-rIL/strings.xml | 19 +++++++++++++++++-- .../src/main/res/values-ko-rKR/strings.xml | 1 + .../src/main/res/values-lt-rLT/strings.xml | 1 + .../src/main/res/values-nl-rNL/strings.xml | 1 + .../src/main/res/values-no-rNO/strings.xml | 15 +++++++++++++++ .../src/main/res/values-pl-rPL/strings.xml | 1 + .../src/main/res/values-pt-rBR/strings.xml | 1 + .../src/main/res/values-pt-rPT/strings.xml | 1 + .../src/main/res/values-ro-rRO/strings.xml | 1 + .../src/main/res/values-ru-rRU/strings.xml | 15 +++++++++++++++ .../src/main/res/values-sk-rSK/strings.xml | 1 + .../src/main/res/values-sl-rSI/strings.xml | 1 + .../src/main/res/values-sv-rSE/strings.xml | 1 + .../src/main/res/values-ta-rIN/strings.xml | 1 + .../src/main/res/values-tr-rTR/strings.xml | 1 + .../src/main/res/values-zh-rCN/strings.xml | 1 + .../src/main/res/values-it-rIT/strings.xml | 2 +- .../src/main/res/values-iw-rIL/strings.xml | 2 +- wear/src/main/res/values-iw-rIL/strings.xml | 2 +- 46 files changed, 169 insertions(+), 11 deletions(-) diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index 27600d2205..fefa9231cb 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -892,4 +892,5 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S Erreur dans les valeurs de basal Erreur dans les valeurs cibles Erreur dans les valeurs de SI + Exécuter %s? diff --git a/app/src/main/res/values-it-rIT/strings.xml b/app/src/main/res/values-it-rIT/strings.xml index 508a8f6256..923c7c1a4f 100644 --- a/app/src/main/res/values-it-rIT/strings.xml +++ b/app/src/main/res/values-it-rIT/strings.xml @@ -678,6 +678,7 @@ Ripristina valori predefiniti Malfunzionamento NSClient. Considera il riavvio di NS e NSClient. Offset + Ricorda di fare il bolo Modalità APS preferita Totale Calc @@ -844,6 +845,9 @@ Usa un promemoria per iniziare a mangiare invece del risultato del calcolatore durante la glicemia alta (\"pre-bolo\") Tempo di mangiare!\nEsegui il calcolatore e fai di nuovi i calcoli. Tempo di mangiare + Promemoria bolo + Abilita promemoria bolo + Tempo di fare un bolo!\nEsegui il calcolatore e fai di nuovi i calcoli. Caricamento log dei crash disabilitato! Grafico Menu grafico @@ -886,4 +890,5 @@ Errore nei valori della basale Errore nei valori del target Errore nei valori ISF + Eseguire %s? diff --git a/app/src/main/res/values-iw-rIL/strings.xml b/app/src/main/res/values-iw-rIL/strings.xml index fdc076afae..6b49ddbe9a 100644 --- a/app/src/main/res/values-iw-rIL/strings.xml +++ b/app/src/main/res/values-iw-rIL/strings.xml @@ -247,7 +247,7 @@ Wear שלח מחדש את כל הנתונים פתיחת הגדרות Wear - ערכים בזאליים: + מינונים בזאליים: ערך הבסיס מתחת למינימום. פרופיל אינו מוגדר! ערכי סוכר בדם: ערכי סוכר אחרונים: @@ -892,4 +892,5 @@ שגיאה בערכי המינון הבזאלי שגיאה בערכי המטרה שגיאה בערכי יחס התיקון + להפעיל %s? diff --git a/app/src/main/res/values-nl-rNL/strings.xml b/app/src/main/res/values-nl-rNL/strings.xml index 7b3de291e1..ee604c3bf2 100644 --- a/app/src/main/res/values-nl-rNL/strings.xml +++ b/app/src/main/res/values-nl-rNL/strings.xml @@ -432,7 +432,7 @@ Afbreken Niet alle profielen zijn geladen! Waarden niet opgeslagen! - Schakel lokaal data delen naar andere apps (zoals xDrip) in. Schakel dit niet in als je NSClient of meer dan één installatie van AAPS op je telefoon hebt staan! + Schakel lokaal data delen met andere apps (zoals xDrip) in. Schakel dit niet in als er meer dan één installatie van AAPS of NSClient zijn geinstalleerd! Activeer locaal delen. OpenAPS SMB Activeer UAM @@ -678,6 +678,7 @@ Terug naar standaardinstellingen NSClient werkt niet goed. Overweg een herstart van NS en NSClient. Tijdverschuiving + Herinner later te bolussen Voorkeur APS-modus Totaal Calc @@ -844,6 +845,11 @@ Gebruik bij een hoge bloedglucose niet het resultaat van de wizard, maar een herinnering om later met eten te beginnen (\"pre-bolus\") Tijd om te eten!\nVoer de boluswizard opnieuw uit. Tijd om te eten + Bolus herinnering + Bolus herinnering inschakelen + Gebruik herinnering om later te bolussen met de wizard + (\"post-bolus\") + Tijd om te bolussen!\nVoer de boluswizard uit en maak de berekening opnieuw. Upload van crashrapporten is uitgeschakeld! Grafiek Grafiek menu diff --git a/app/src/main/res/values-no-rNO/strings.xml b/app/src/main/res/values-no-rNO/strings.xml index 9631c5f0c7..5eea02b2bc 100644 --- a/app/src/main/res/values-no-rNO/strings.xml +++ b/app/src/main/res/values-no-rNO/strings.xml @@ -678,6 +678,7 @@ Gjenopprett standardinnstillinger NSClient feil. Vurder omstart av NS og NSClient. Tidsforskyvning + Påminnelse til å gi bolus senere Foretrukket APS modus Total Kalkyle @@ -844,6 +845,11 @@ Bruk en påminnelse om å spise senere enn kalkulator resultatet fra wizard ved høyt blodsukker (\"pre-bolus\") Nå må du spise!\Bruk bolus veiviseren og beregn på nytt. Nå må du spise + Bolus påminnelse + Aktiver bolus påminnelse + Bruk påminnelse for å sette bolus dosen senere med veiviseren + («post bolus») + Tid for bolus!\nStart bolus-veiviser og gjør beregning på nytt. Opplast av krasj logger er deaktivert! Graf Diagram meny @@ -886,4 +892,5 @@ Feil i basalverdiene Feil i BS mål verdiene Feil i IF verdien + Kjør %s? diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml index ae429b6f3c..58778e9810 100644 --- a/app/src/main/res/values-ru-rRU/strings.xml +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -893,4 +893,5 @@ Context | Edit Context Ошибка в величине базала Ошибка в целевых значениях Ошибка в значении фактора чувствительности к инсулину ISF + Запустить %s? diff --git a/automation/src/main/res/values-fr-rFR/strings.xml b/automation/src/main/res/values-fr-rFR/strings.xml index a42641de69..c580c81d44 100644 --- a/automation/src/main/res/values-fr-rFR/strings.xml +++ b/automation/src/main/res/values-fr-rFR/strings.xml @@ -105,9 +105,11 @@ ÉDITER Choisir un type d\'action Choisir un type de déclencheur + Choisissez un type d\'opération Déclencheurs : SUPPRIMER Conditions préalables : Evénement auto. Réordonner + Actions utilisateur diff --git a/automation/src/main/res/values-it-rIT/strings.xml b/automation/src/main/res/values-it-rIT/strings.xml index fb8001f975..2ff0e7466f 100644 --- a/automation/src/main/res/values-it-rIT/strings.xml +++ b/automation/src/main/res/values-it-rIT/strings.xml @@ -105,9 +105,11 @@ MODIFICA Scegli un tipo di azione Scegli un tipo di trigger + Scegli un tipo di operazione Trigger: RIMUOVI Presupposti: Evento di automazione Riordina + Azione utente diff --git a/automation/src/main/res/values-iw-rIL/strings.xml b/automation/src/main/res/values-iw-rIL/strings.xml index 46a2efd8ef..5ba51cb7fa 100644 --- a/automation/src/main/res/values-iw-rIL/strings.xml +++ b/automation/src/main/res/values-iw-rIL/strings.xml @@ -105,9 +105,11 @@ עריכה בחרו סוג פעולה בחירת סוג הטריגר + נא לבחור סוג פעולה טריגרים: הסר תנאים מוקדמים: אירוע אוטומציה סדר מחדש + פעולות משתמש diff --git a/automation/src/main/res/values-no-rNO/strings.xml b/automation/src/main/res/values-no-rNO/strings.xml index 1df8018334..9ddd8db943 100644 --- a/automation/src/main/res/values-no-rNO/strings.xml +++ b/automation/src/main/res/values-no-rNO/strings.xml @@ -105,9 +105,11 @@ REDIGER Velg en handling Velg en trigger type + Velg en handling Triggere: FJERN Forutsetninger: Automasjons hendelse Endre rekkefølge + Bruker handling diff --git a/automation/src/main/res/values-ru-rRU/strings.xml b/automation/src/main/res/values-ru-rRU/strings.xml index 9557684a9a..96a71d6cd0 100644 --- a/automation/src/main/res/values-ru-rRU/strings.xml +++ b/automation/src/main/res/values-ru-rRU/strings.xml @@ -105,9 +105,11 @@ РЕДАКТ Выберите тип действия Выберите тип триггера + Выберите тип действия Триггеры: УДАЛИТЬ Предусловия: Автоматизированное событие Повторный заказ + Действия пользователя diff --git a/core/src/main/res/values-it-rIT/strings.xml b/core/src/main/res/values-it-rIT/strings.xml index 7d993762ae..1daa37f44e 100644 --- a/core/src/main/res/values-it-rIT/strings.xml +++ b/core/src/main/res/values-it-rIT/strings.xml @@ -385,7 +385,7 @@ PLUGIN DISABILITATO SCONOSCIUTO Stringa - Fonte + Origine Offset UTC Azione Data e ora diff --git a/core/src/main/res/values-iw-rIL/strings.xml b/core/src/main/res/values-iw-rIL/strings.xml index 576adaac67..1f48ff2e51 100644 --- a/core/src/main/res/values-iw-rIL/strings.xml +++ b/core/src/main/res/values-iw-rIL/strings.xml @@ -54,7 +54,7 @@ התחברות אחרונה בולוס אחרון יחידות יומיות - בזאלי בסיסי + מינון בזאלי בסיסי בזאלי זמני בולוס ממושך מכל @@ -245,7 +245,7 @@ יחס # ימים משקל - שימוש בבולוס למילוי / פריימינג עשוי לגרום לחוסר דיוק! + שימוש בבולוס למילוי \\ תיחול עשוי לגרום לחוסר דיוק! הנתונים ישנים. לרענון לחצו \"טען מחדש\" סה\"כ בזאלי בסיסי סה\"כ בזאלי בסיסי * 2 diff --git a/core/src/main/res/values-no-rNO/strings.xml b/core/src/main/res/values-no-rNO/strings.xml index fd1b371d10..368df9e88d 100644 --- a/core/src/main/res/values-no-rNO/strings.xml +++ b/core/src/main/res/values-no-rNO/strings.xml @@ -304,6 +304,7 @@ S BOLUS + BOLUS KALKULATOR BOLUS ASSISTENT FORLENGET BOLUS SUPERBOLUS TBR diff --git a/dana/src/main/res/values-iw-rIL/strings.xml b/dana/src/main/res/values-iw-rIL/strings.xml index 1be01b16d1..f73217831e 100644 --- a/dana/src/main/res/values-iw-rIL/strings.xml +++ b/dana/src/main/res/values-iw-rIL/strings.xml @@ -51,7 +51,7 @@ הפסקת בזאלי זמני מגדיר בולוס ממושך מפסיק בולוס ממושך - מעדכן את הקצב הבזאלי + מעדכן את המינון הבזאלי הגדרת בזאלי זמני ממתין לסינכרון השעון (%1$d שנ\') סיסמת משאבה שגויה! diff --git a/omnipod-dash/src/main/res/values-af-rZA/strings.xml b/omnipod-dash/src/main/res/values-af-rZA/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-af-rZA/strings.xml +++ b/omnipod-dash/src/main/res/values-af-rZA/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-dash/src/main/res/values-bg-rBG/strings.xml b/omnipod-dash/src/main/res/values-bg-rBG/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-bg-rBG/strings.xml +++ b/omnipod-dash/src/main/res/values-bg-rBG/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-dash/src/main/res/values-ca-rES/strings.xml b/omnipod-dash/src/main/res/values-ca-rES/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-ca-rES/strings.xml +++ b/omnipod-dash/src/main/res/values-ca-rES/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-dash/src/main/res/values-cs-rCZ/strings.xml b/omnipod-dash/src/main/res/values-cs-rCZ/strings.xml index 2aa2949dc0..3e9314bea0 100644 --- a/omnipod-dash/src/main/res/values-cs-rCZ/strings.xml +++ b/omnipod-dash/src/main/res/values-cs-rCZ/strings.xml @@ -3,6 +3,15 @@ Integrace pumpy pro Omnipod Dash (nový model s funkcí Bluetooth a modrým krytem). + + Historie Podu + Popis + Zdroj + Datum + Typ: + %1$.2f U + %1$.2f U, Sach=%2$.1f g + Rychlost: %1$.2f U, doba trvání: %2$d minut Stav Bluetooth Adresa Bluetooth @@ -18,4 +27,10 @@ Nalezeno příliš mnoho Podů k aktivaci Nelze najít dostupný Pod k aktivaci Obecná chyba: %1$s + Nezdařilo se odeslat příkaz + Příkaz nebyl odeslán + Příkaz nebyl přijat podem + Neznámý stav příkazu + Rychlost: %1$.2f U, doba trvání: %2$d minut + %1$.2f U diff --git a/omnipod-dash/src/main/res/values-da-rDK/strings.xml b/omnipod-dash/src/main/res/values-da-rDK/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-da-rDK/strings.xml +++ b/omnipod-dash/src/main/res/values-da-rDK/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-dash/src/main/res/values-de-rDE/strings.xml b/omnipod-dash/src/main/res/values-de-rDE/strings.xml index 7778e692ff..1eaa7a2eff 100644 --- a/omnipod-dash/src/main/res/values-de-rDE/strings.xml +++ b/omnipod-dash/src/main/res/values-de-rDE/strings.xml @@ -3,6 +3,15 @@ Pumpen-Integration für Omnipod Dash (das neue, bluetooth-fähige Modell mit blauer Nadelkappe). + + Pod Historie + Beschreibung + Quelle + Datum + Typ: + %1$.2f IE + %1$.2f IE, CH=%2$.1f g + Rate: %1$.2f IE, Dauer: %2$d min. Bluetooth-Status Bluetooth-Adresse @@ -18,4 +27,10 @@ Zu viele Pods für die Aktivierung gefunden Konnte keinen verfügbaren Pod für die Aktivierung finden Allgemeiner Fehler: %1$s + Fehler beim Senden des Befehls + Befehl nicht gesendet + Befehl nicht vom Pod empfangen + Unbekannter Status für den Befehl + Rate: %1$.2f IE, Dauer: %2$d min. + %1$.2f IE diff --git a/omnipod-dash/src/main/res/values-el-rGR/strings.xml b/omnipod-dash/src/main/res/values-el-rGR/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-el-rGR/strings.xml +++ b/omnipod-dash/src/main/res/values-el-rGR/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-dash/src/main/res/values-es-rES/strings.xml b/omnipod-dash/src/main/res/values-es-rES/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-es-rES/strings.xml +++ b/omnipod-dash/src/main/res/values-es-rES/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-dash/src/main/res/values-fr-rFR/strings.xml b/omnipod-dash/src/main/res/values-fr-rFR/strings.xml index a178c01d4f..d9887349b7 100644 --- a/omnipod-dash/src/main/res/values-fr-rFR/strings.xml +++ b/omnipod-dash/src/main/res/values-fr-rFR/strings.xml @@ -3,6 +3,15 @@ Intégration de la pompe Omnipod Dash (le nouveau modèle Bluetooth, avec un bouchon d\'aiguille bleue). + + Historique du Pod + Description + Source + Date + Type : + %1$.2f U + %1$.2f U, Gluc=%2$.1f g + Débit : %1$.2f U, durée : %2$d minutes État Bluetooth Adresse Bluetooth @@ -18,4 +27,10 @@ Trop de pods trouvés pour l\'activation Impossible de trouver un pod disponible pour l\'activation Erreur générique : %1$s + Échec d\'envoi de la commande + Commande non envoyée + Commande non reçue par le pod + État inconnu pour la commande + Débit : %1$.2f U, durée : %2$d minutes + %1$.2f U diff --git a/omnipod-dash/src/main/res/values-ga-rIE/strings.xml b/omnipod-dash/src/main/res/values-ga-rIE/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-ga-rIE/strings.xml +++ b/omnipod-dash/src/main/res/values-ga-rIE/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-dash/src/main/res/values-hr-rHR/strings.xml b/omnipod-dash/src/main/res/values-hr-rHR/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-hr-rHR/strings.xml +++ b/omnipod-dash/src/main/res/values-hr-rHR/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-dash/src/main/res/values-it-rIT/strings.xml b/omnipod-dash/src/main/res/values-it-rIT/strings.xml index 6b0f3d4214..b6ce74a9d8 100644 --- a/omnipod-dash/src/main/res/values-it-rIT/strings.xml +++ b/omnipod-dash/src/main/res/values-it-rIT/strings.xml @@ -3,6 +3,15 @@ Integrazione del microinfusore Omnipod Dash (il nuovo modello, abilitato al Bluetooth e con la protezione ago di colore blu). + + Storico pod + Descrizione + Origine + Data + Tipo: + %1$.2f U + %1$.2f U, CHO=%2$.1f g + Tasso: %1$.2f U, durata: %2$d minuti Stato bluetooth Indirizzo bluetooth @@ -18,4 +27,10 @@ Trovati troppi pod per l\'attivazione Nessun pod disponibile per l\'attivazione Errore generico: %1$s + Impossibile inviare il comando + Comando non inviato + Comando non ricevuto dal pod + Stato sconosciuto per il comando + Tasso: %1$.2f U, durata: %2$d minuti + %1$.2f U diff --git a/omnipod-dash/src/main/res/values-iw-rIL/strings.xml b/omnipod-dash/src/main/res/values-iw-rIL/strings.xml index 2fb153f0c6..61e25aea1e 100644 --- a/omnipod-dash/src/main/res/values-iw-rIL/strings.xml +++ b/omnipod-dash/src/main/res/values-iw-rIL/strings.xml @@ -3,6 +3,15 @@ חיבור משאבת Omnipod Dash (הדגם החדש, התומך בבלוטות\' ובעל מכסה מחט כחול). + + היסטוריית הפוד + תיאור + מקור + תאריך + סוג: + %1$.2f יח\' + %1$.2f יח\', פחמ\'= %2$.1f גר\' + מינון: %1$.2f יח\', משך: %2$d דק\' מצב בלוטות\' כתובת בלוטות\' @@ -10,12 +19,18 @@ איכות החיבור סטטוס הזרקה - מלאו פוד חדש עם מספיק אינסולין לשלושה ימים.\n\nהקשיבו לשני צפצופים מהפוד במהלך המילוי. הם מציינים שהכמות המינימלית של 80 יחידות הוכנסה. הקפידו לרוקן לחלוטין את מזרק המילוי, גם לאחר שמיעת שני הצפצופים.\n\nלאחר מילוי הפוד, יש ללחוץ הבא.\n\nהערה: נא לא להסיר עדיין את מכסה המחט. - מנסה לצמד את הפוד החדש ולתחל אותו.\n\nכאשר תהליך התחול יסתיים בהצלחה, תוכלו ללחוץ על הבא. + מלאו פוד חדש עם מספיק אינסולין לשלושה ימים.\n\nהקשיבו לשני צפצופים מהפוד במהלך המילוי. הם מציינים שהכמות המינימלית של 80 יחידות הוכנסה. הקפידו לרוקן לחלוטין את מזרק המילוי לתוך הפוד, גם לאחר שמיעת שני הצפצופים.\n\nלאחר מילוי הפוד, יש ללחוץ הבא.\n\nהערה: נא לא להסיר עדיין את מכסה המחט. + מנסה לצמד את הפוד החדש ולתחל אותו.\n\nכאשר תהליך התיחול יסתיים בהצלחה, תוכלו ללחוץ על הבא. השמע כשהתראת הפסקת ההזרקה מאופשרת הקישור לפוד נכשל נמצאו יותר מדי פודים להפעלה לא נמצא פוד זמין להפעלה שגיאה גנרית: %1$s + שליחת הפקודה נכשלה + הפקודה לא נשלחה + הפקודה לא התקבלה ע\"י הפוד + מצב הפקודה לא ידוע + מינון: %1$.2f יח\', משך: %2$d דק\' + %1$.2f יח\' diff --git a/omnipod-dash/src/main/res/values-ko-rKR/strings.xml b/omnipod-dash/src/main/res/values-ko-rKR/strings.xml index f01c43835c..91fdf1f9e3 100644 --- a/omnipod-dash/src/main/res/values-ko-rKR/strings.xml +++ b/omnipod-dash/src/main/res/values-ko-rKR/strings.xml @@ -3,6 +3,7 @@ 옴니파드 대쉬(파란색 바늘 캡이 달린 새로운 블루투스 연결 모델)를 위한 펌프 통합 + diff --git a/omnipod-dash/src/main/res/values-lt-rLT/strings.xml b/omnipod-dash/src/main/res/values-lt-rLT/strings.xml index fe222a093a..390923037e 100644 --- a/omnipod-dash/src/main/res/values-lt-rLT/strings.xml +++ b/omnipod-dash/src/main/res/values-lt-rLT/strings.xml @@ -3,6 +3,7 @@ Pompos integracija Omnipod Dash (naujas, Bluetooth palaikantis modelis su mėlynu adatos dangteliu). + Bluetooth būklė Bluetooth adresas diff --git a/omnipod-dash/src/main/res/values-nl-rNL/strings.xml b/omnipod-dash/src/main/res/values-nl-rNL/strings.xml index 71ac7ad09e..c2a0897111 100644 --- a/omnipod-dash/src/main/res/values-nl-rNL/strings.xml +++ b/omnipod-dash/src/main/res/values-nl-rNL/strings.xml @@ -3,6 +3,7 @@ Pomp integratie voor Omnipod Dash (het nieuwe, Bluetooth-enabled model met een blauwe naalddop). + Bluetooth status Bluetooth adres diff --git a/omnipod-dash/src/main/res/values-no-rNO/strings.xml b/omnipod-dash/src/main/res/values-no-rNO/strings.xml index 6f3619cf85..a6f98fd074 100644 --- a/omnipod-dash/src/main/res/values-no-rNO/strings.xml +++ b/omnipod-dash/src/main/res/values-no-rNO/strings.xml @@ -3,6 +3,15 @@ Pumpeintegrering for Omnipod Dash (den nye, Bluetooth-aktiverte modellen med en blå kanylehette). + + Pod historikk + Beskrivelse + Kilde + Dato + Type: + %1$.2f E + %1$.2f E, KH=%2$.1f g + Dosering: %1$.2f E, varighet: %2$d min Bluetooth status Bluetooth adresse @@ -18,4 +27,10 @@ Fant for mange podder for aktivering Fant ingen pod tilgjengelig for aktivering Generell feil: %1$s + Feilet i å sende kommandoen + Kommando ikke sendt + Kommandoen ikke mottatt av podden + Ukjent tilstand for kommandoen + Dosering: %1$.2f E, varighet: %2$d min + %1$.2f E diff --git a/omnipod-dash/src/main/res/values-pl-rPL/strings.xml b/omnipod-dash/src/main/res/values-pl-rPL/strings.xml index 5faa140ff9..cd2dc79a7a 100644 --- a/omnipod-dash/src/main/res/values-pl-rPL/strings.xml +++ b/omnipod-dash/src/main/res/values-pl-rPL/strings.xml @@ -3,6 +3,7 @@ Integracja dla pompy Omnipod Dash (nowy, posiadając Bluetooth model z niebieską osłonką na igłę). + Status Bluetooth Adres Bluetooth diff --git a/omnipod-dash/src/main/res/values-pt-rBR/strings.xml b/omnipod-dash/src/main/res/values-pt-rBR/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-pt-rBR/strings.xml +++ b/omnipod-dash/src/main/res/values-pt-rBR/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-dash/src/main/res/values-pt-rPT/strings.xml b/omnipod-dash/src/main/res/values-pt-rPT/strings.xml index d01a3acdfe..6cf06aa469 100644 --- a/omnipod-dash/src/main/res/values-pt-rPT/strings.xml +++ b/omnipod-dash/src/main/res/values-pt-rPT/strings.xml @@ -3,6 +3,7 @@ Integração para a Omnipod Dash (o novo modelo, habilitado para o Bluetooth com uma proteção de agulha azul). + diff --git a/omnipod-dash/src/main/res/values-ro-rRO/strings.xml b/omnipod-dash/src/main/res/values-ro-rRO/strings.xml index d338e79f73..e3b74fe808 100644 --- a/omnipod-dash/src/main/res/values-ro-rRO/strings.xml +++ b/omnipod-dash/src/main/res/values-ro-rRO/strings.xml @@ -3,6 +3,7 @@ Integrarea pompei pentru Omnipod Dash (modelul nou, cu Bluetooth, cu un capac de ac albastru). + Stare Bluetooth Adresă Bluetooth diff --git a/omnipod-dash/src/main/res/values-ru-rRU/strings.xml b/omnipod-dash/src/main/res/values-ru-rRU/strings.xml index 73452811e8..51e31a2ee1 100644 --- a/omnipod-dash/src/main/res/values-ru-rRU/strings.xml +++ b/omnipod-dash/src/main/res/values-ru-rRU/strings.xml @@ -3,6 +3,15 @@ Интеграция с помпой Omnipod Dash (новая модель с поддержкой Bluetooth, с синим колпачком на игле). + + Журнал помпы + Описание + Источник + Дата + Тип: + %1$.2f ед + %1$.2f ед %2$.1f ГУ + Баз Скорость: %1$.2f ед, Продолжительность: %2$d мин Состояние Bluetooth Адрес Bluetooth @@ -18,4 +27,10 @@ Cлишком много pod\'ов для активации Pod для активации не найден Общая ошибка: %1$s + Не удалось отправить команду + Команда не отправлена + Команда не получена помпой + Состояние команды неясно + Баз Скорость: %1$.2f ед, Продолжительность: %2$d мин + %1$.2f ед diff --git a/omnipod-dash/src/main/res/values-sk-rSK/strings.xml b/omnipod-dash/src/main/res/values-sk-rSK/strings.xml index bb75fed0a6..9374e5ee8d 100644 --- a/omnipod-dash/src/main/res/values-sk-rSK/strings.xml +++ b/omnipod-dash/src/main/res/values-sk-rSK/strings.xml @@ -3,6 +3,7 @@ Integrácia pumpy pre Omnipod Dash (nový model s funkciou Bluetooth a modrým krytom). + Stav Bluetooth Adresa Bluetooth diff --git a/omnipod-dash/src/main/res/values-sl-rSI/strings.xml b/omnipod-dash/src/main/res/values-sl-rSI/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-sl-rSI/strings.xml +++ b/omnipod-dash/src/main/res/values-sl-rSI/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-dash/src/main/res/values-sv-rSE/strings.xml b/omnipod-dash/src/main/res/values-sv-rSE/strings.xml index e9c744f38a..efb200826e 100644 --- a/omnipod-dash/src/main/res/values-sv-rSE/strings.xml +++ b/omnipod-dash/src/main/res/values-sv-rSE/strings.xml @@ -3,6 +3,7 @@ Pumpintegration för Omnipod Dash (den nya, Bluetooth-aktiverade modellen med blå nålskydd). + Bluetooth-status Bluetooth-adress diff --git a/omnipod-dash/src/main/res/values-ta-rIN/strings.xml b/omnipod-dash/src/main/res/values-ta-rIN/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-ta-rIN/strings.xml +++ b/omnipod-dash/src/main/res/values-ta-rIN/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-dash/src/main/res/values-tr-rTR/strings.xml b/omnipod-dash/src/main/res/values-tr-rTR/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-tr-rTR/strings.xml +++ b/omnipod-dash/src/main/res/values-tr-rTR/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-dash/src/main/res/values-zh-rCN/strings.xml b/omnipod-dash/src/main/res/values-zh-rCN/strings.xml index 0d89375603..942b365512 100644 --- a/omnipod-dash/src/main/res/values-zh-rCN/strings.xml +++ b/omnipod-dash/src/main/res/values-zh-rCN/strings.xml @@ -2,6 +2,7 @@ + diff --git a/omnipod-eros/src/main/res/values-it-rIT/strings.xml b/omnipod-eros/src/main/res/values-it-rIT/strings.xml index 4aa838fcff..e868194eb9 100644 --- a/omnipod-eros/src/main/res/values-it-rIT/strings.xml +++ b/omnipod-eros/src/main/res/values-it-rIT/strings.xml @@ -17,7 +17,7 @@ Storico pod Descrizione - Fonte + Origine Data Tipo: %1$.2f U diff --git a/omnipod-eros/src/main/res/values-iw-rIL/strings.xml b/omnipod-eros/src/main/res/values-iw-rIL/strings.xml index fc5c628e92..53c96db90e 100644 --- a/omnipod-eros/src/main/res/values-iw-rIL/strings.xml +++ b/omnipod-eros/src/main/res/values-iw-rIL/strings.xml @@ -22,7 +22,7 @@ סוג: %1$.2f יח\' %1$.2f יח\', פחמ\'= %2$.1f גר\' - קצב: %1$.2f יח\', משך: %2$d דק\' + מינון: %1$.2f יח\', משך: %2$d דק\' סול\' ריילי: %1$d diff --git a/wear/src/main/res/values-iw-rIL/strings.xml b/wear/src/main/res/values-iw-rIL/strings.xml index 5702c3b293..c507be2de5 100644 --- a/wear/src/main/res/values-iw-rIL/strings.xml +++ b/wear/src/main/res/values-iw-rIL/strings.xml @@ -26,7 +26,7 @@ הצג דלתא ממוצעת הצג את סוללת הטלפון הצג את סוללת ה-Rig - הצג קצב בזאלי + הצג מינון בזאלי הצג סטטוס לולאה הצג רמת סוכר הצג חץ כיוון From 33dc2abe1bd1c903ebdb86a4ae0e352fa42ad033 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Nov 2021 16:18:23 +0000 Subject: [PATCH 14/29] Bump firebase-crashlytics-gradle from 2.7.1 to 2.8.0 Bumps firebase-crashlytics-gradle from 2.7.1 to 2.8.0. --- updated-dependencies: - dependency-name: com.google.firebase:firebase-crashlytics-gradle dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 97b1ff47f7..701e6d5943 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:7.0.3' classpath 'com.google.gms:google-services:4.3.10' - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files From f700c22966c6edbdee5a60caeb123290ad6dbba6 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 1 Nov 2021 18:43:07 +0100 Subject: [PATCH 15/29] prevent Missing BG notification on start --- .../PersistentNotificationPlugin.kt | 86 +++++++++++-------- 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt index 6d670461aa..75c6a4c2f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/persistentNotification/PersistentNotificationPlugin.kt @@ -22,6 +22,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers import io.reactivex.disposables.CompositeDisposable +import io.reactivex.rxkotlin.plusAssign import javax.inject.Inject import javax.inject.Singleton @@ -42,14 +43,15 @@ class PersistentNotificationPlugin @Inject constructor( private val dummyServiceHelper: DummyServiceHelper, private val iconsProvider: IconsProvider, private val glucoseStatusProvider: GlucoseStatusProvider -) : PluginBase(PluginDescription() - .mainType(PluginType.GENERAL) - .neverVisible(true) - .pluginName(R.string.ongoingnotificaction) - .enableByDefault(true) - .alwaysEnabled(true) - .showInList(false) - .description(R.string.description_persistent_notification), +) : PluginBase( + PluginDescription() + .mainType(PluginType.GENERAL) + .neverVisible(true) + .pluginName(R.string.ongoingnotificaction) + .enableByDefault(true) + .alwaysEnabled(true) + .showInList(false) + .description(R.string.description_persistent_notification), aapsLogger, resourceHelper, injector ) { @@ -63,49 +65,48 @@ class PersistentNotificationPlugin @Inject constructor( // End Android auto private val disposable = CompositeDisposable() + private var channel: NotificationChannel? = null override fun onStart() { super.onStart() - createNotificationChannel() // make sure channels exist before triggering updates through the bus - disposable.add(rxBus + disposable += rxBus .toObservable(EventRefreshOverview::class.java) .observeOn(aapsSchedulers.io) - .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException)) - disposable.add(rxBus + .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException) + disposable += rxBus .toObservable(EventExtendedBolusChange::class.java) .observeOn(aapsSchedulers.io) - .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException)) - disposable.add(rxBus + .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException) + disposable += rxBus .toObservable(EventTempBasalChange::class.java) .observeOn(aapsSchedulers.io) - .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException)) - disposable.add(rxBus + .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException) + disposable += rxBus .toObservable(EventTreatmentChange::class.java) .observeOn(aapsSchedulers.io) - .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException)) - disposable.add(rxBus + .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException) + disposable += rxBus .toObservable(EventInitializationChanged::class.java) .observeOn(aapsSchedulers.io) - .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException)) - disposable.add(rxBus + .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException) + disposable += rxBus .toObservable(EventEffectiveProfileSwitchChanged::class.java) .observeOn(aapsSchedulers.io) - .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException)) - disposable.add(rxBus + .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException) + disposable += rxBus .toObservable(EventAutosensCalculationFinished::class.java) .observeOn(aapsSchedulers.io) - .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException)) - disposable.add(rxBus + .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException) + disposable += rxBus .toObservable(EventPreferenceChange::class.java) .observeOn(aapsSchedulers.io) - .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException)) - triggerNotificationUpdate() + .subscribe({ triggerNotificationUpdate() }, fabricPrivacy::logException) } private fun createNotificationChannel() { val mNotificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - val channel = NotificationChannel(notificationHolder.channelID, notificationHolder.channelID as CharSequence, NotificationManager.IMPORTANCE_HIGH) - mNotificationManager.createNotificationChannel(channel) + channel = NotificationChannel(notificationHolder.channelID, notificationHolder.channelID as CharSequence, NotificationManager.IMPORTANCE_HIGH) + channel?.let { mNotificationManager.createNotificationChannel(it) } } override fun onStop() { @@ -115,6 +116,8 @@ class PersistentNotificationPlugin @Inject constructor( } private fun triggerNotificationUpdate() { + if (channel == null) + createNotificationChannel() // make sure channels exist before triggering updates through the bus updateNotification() dummyServiceHelper.startService(context) } @@ -155,8 +158,16 @@ class PersistentNotificationPlugin @Inject constructor( //IOB val bolusIob = iobCobCalculator.calculateIobFromBolus().round() val basalIob = iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended().round() - line2 = resourceHelper.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U " + resourceHelper.gs(R.string.cob) + ": " + iobCobCalculator.getCobInfo(false, "PersistentNotificationPlugin").generateCOBString() - val line2aa = resourceHelper.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U. " + resourceHelper.gs(R.string.cob) + ": " + iobCobCalculator.getCobInfo(false, "PersistentNotificationPlugin").generateCOBString() + "." + line2 = + resourceHelper.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U " + resourceHelper.gs(R.string.cob) + ": " + iobCobCalculator.getCobInfo( + false, + "PersistentNotificationPlugin" + ).generateCOBString() + val line2aa = + resourceHelper.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U. " + resourceHelper.gs(R.string.cob) + ": " + iobCobCalculator.getCobInfo( + false, + "PersistentNotificationPlugin" + ).generateCOBString() + "." line3 = DecimalFormatter.to2Decimal(pump.baseBasalRate) + " U/h" var line3aa = DecimalFormatter.to2Decimal(pump.baseBasalRate) + " U/h." line3 += " - " + profileFunction.getProfileName() @@ -167,10 +178,12 @@ class PersistentNotificationPlugin @Inject constructor( .setAction(READ_ACTION) .putExtra(CONVERSATION_ID, notificationHolder.notificationID) .setPackage(PACKAGE) - val msgReadPendingIntent = PendingIntent.getBroadcast(context, + val msgReadPendingIntent = PendingIntent.getBroadcast( + context, notificationHolder.notificationID, msgReadIntent, - PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) + PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT + ) val msgReplyIntent = Intent() .addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES) .setAction(REPLY_ACTION) @@ -180,7 +193,8 @@ class PersistentNotificationPlugin @Inject constructor( context, notificationHolder.notificationID, msgReplyIntent, - PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) + PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT + ) // Build a RemoteInput for receiving voice input from devices val remoteInput = RemoteInput.Builder(EXTRA_VOICE_REPLY).build() // Create the UnreadConversation @@ -205,8 +219,10 @@ class PersistentNotificationPlugin @Inject constructor( if (line3 != null) builder.setSubText(line3) /// Android Auto if (unreadConversationBuilder != null) { - builder.extend(NotificationCompat.CarExtender() - .setUnreadConversation(unreadConversationBuilder.build())) + builder.extend( + NotificationCompat.CarExtender() + .setUnreadConversation(unreadConversationBuilder.build()) + ) } /// End Android Auto builder.setContentIntent(notificationHolder.openAppIntent(context)) From 7442774ab7fceb39492a45fe1f62e965cebc680a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 1 Nov 2021 22:29:02 +0100 Subject: [PATCH 16/29] notify about wrong profiles from NS --- .../aps/openAPSAMA/OpenAPSAMAPlugin.kt | 6 +-- .../aps/openAPSSMB/OpenAPSSMBPlugin.kt | 6 +-- .../notifications/NotificationStore.kt | 1 + .../profile/local/LocalProfileFragment.kt | 4 +- .../profile/local/LocalProfilePlugin.kt | 47 ++++++++++++++----- app/src/main/res/values/strings.xml | 3 ++ .../androidaps/data/ProfileSealed.kt | 22 ++++----- .../androidaps/interfaces/ProfileStore.kt | 2 +- .../overview/notifications/Notification.kt | 5 ++ .../nightscout/androidaps/utils/HardLimits.kt | 6 +-- 10 files changed, 67 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.kt index b11d5b8e20..162a3f63ed 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSAMA/OpenAPSAMAPlugin.kt @@ -114,9 +114,9 @@ class OpenAPSAMAPlugin @Inject constructor( val maxIob = constraintChecker.getMaxIOBAllowed().also { maxIOBAllowedConstraint -> inputConstraints.copyReasons(maxIOBAllowedConstraint) }.value() - var minBg = hardLimits.verifyHardLimits(Round.roundTo(profile.getTargetLowMgdl(), 0.1), R.string.profile_low_target, HardLimits.VERY_HARD_LIMIT_MIN_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_MIN_BG[1].toDouble()) - var maxBg = hardLimits.verifyHardLimits(Round.roundTo(profile.getTargetHighMgdl(), 0.1), R.string.profile_high_target, HardLimits.VERY_HARD_LIMIT_MAX_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_MAX_BG[1].toDouble()) - var targetBg = hardLimits.verifyHardLimits(profile.getTargetMgdl(), R.string.temp_target_value, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble()) + var minBg = hardLimits.verifyHardLimits(Round.roundTo(profile.getTargetLowMgdl(), 0.1), R.string.profile_low_target, HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]) + var maxBg = hardLimits.verifyHardLimits(Round.roundTo(profile.getTargetHighMgdl(), 0.1), R.string.profile_high_target, HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]) + var targetBg = hardLimits.verifyHardLimits(profile.getTargetMgdl(), R.string.temp_target_value, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1]) var isTempTarget = false val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() if (tempTarget is ValueWrapper.Existing) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.kt index 42c1700fb8..0b03ab5aca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/OpenAPSSMBPlugin.kt @@ -119,9 +119,9 @@ class OpenAPSSMBPlugin @Inject constructor( inputConstraints.copyReasons(maxIOBAllowedConstraint) }.value() - var minBg = hardLimits.verifyHardLimits(Round.roundTo(profile.getTargetLowMgdl(), 0.1), R.string.profile_low_target, HardLimits.VERY_HARD_LIMIT_MIN_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_MIN_BG[1].toDouble()) - var maxBg = hardLimits.verifyHardLimits(Round.roundTo(profile.getTargetHighMgdl(), 0.1), R.string.profile_high_target, HardLimits.VERY_HARD_LIMIT_MAX_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_MAX_BG[1].toDouble()) - var targetBg = hardLimits.verifyHardLimits(profile.getTargetMgdl(), R.string.temp_target_value, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble()) + var minBg = hardLimits.verifyHardLimits(Round.roundTo(profile.getTargetLowMgdl(), 0.1), R.string.profile_low_target, HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]) + var maxBg = hardLimits.verifyHardLimits(Round.roundTo(profile.getTargetHighMgdl(), 0.1), R.string.profile_high_target, HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]) + var targetBg = hardLimits.verifyHardLimits(profile.getTargetMgdl(), R.string.temp_target_value, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1]) var isTempTarget = false val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() if (tempTarget is ValueWrapper.Existing) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt index 80ee31d783..152d9c5b2a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt @@ -183,6 +183,7 @@ class NotificationStore @Inject constructor( binding.dismiss.setOnClickListener { val notification = it.tag as Notification rxBus.send(EventDismissNotification(notification.id)) + notification.contextForAction = itemView.context notification.action?.run() } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index 1675d4986b..59310cb8f4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -132,10 +132,10 @@ class LocalProfileFragment : DaggerFragment() { basalView = TimeListEdit(context, aapsLogger, dateUtil, view, R.id.basal_holder, "BASAL", resourceHelper.gs(R.string.basal_label) + ": " + sumLabel(), currentProfile.basal, null, pumpDescription.basalMinimumRate, pumpDescription.basalMaximumRate, 0.01, DecimalFormat("0.00"), save) if (units == Constants.MGDL) { TimeListEdit(context, aapsLogger, dateUtil, view, R.id.isf, "ISF", resourceHelper.gs(R.string.isf_label), currentProfile.isf, null, HardLimits.MIN_ISF, HardLimits.MAX_ISF, 1.0, DecimalFormat("0"), save) - TimeListEdit(context, aapsLogger, dateUtil, view, R.id.target, "TARGET", resourceHelper.gs(R.string.target_label), currentProfile.targetLow, currentProfile.targetHigh, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), 1.0, DecimalFormat("0"), save) + TimeListEdit(context, aapsLogger, dateUtil, view, R.id.target, "TARGET", resourceHelper.gs(R.string.target_label), currentProfile.targetLow, currentProfile.targetHigh, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1], 1.0, DecimalFormat("0"), save) } else { TimeListEdit(context, aapsLogger, dateUtil, view, R.id.isf, "ISF", resourceHelper.gs(R.string.isf_label), currentProfile.isf, null, Profile.fromMgdlToUnits(HardLimits.MIN_ISF, GlucoseUnit.MMOL), Profile.fromMgdlToUnits(HardLimits.MAX_ISF, GlucoseUnit.MMOL), 0.1, DecimalFormat("0.0"), save) - TimeListEdit(context, aapsLogger, dateUtil, view, R.id.target, "TARGET", resourceHelper.gs(R.string.target_label), currentProfile.targetLow, currentProfile.targetHigh, Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), GlucoseUnit.MMOL), Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), GlucoseUnit.MMOL), 0.1, DecimalFormat("0.0"), save) + TimeListEdit(context, aapsLogger, dateUtil, view, R.id.target, "TARGET", resourceHelper.gs(R.string.target_label), currentProfile.targetLow, currentProfile.targetHigh, Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], GlucoseUnit.MMOL), Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_TARGET_BG[1], GlucoseUnit.MMOL), 0.1, DecimalFormat("0.0"), save) } // Spinner diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index 45ffde96b0..34aba93fea 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -18,6 +18,9 @@ import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBus +import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification +import info.nightscout.androidaps.plugins.general.overview.notifications.Notification +import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged import info.nightscout.androidaps.receivers.DataWorker import info.nightscout.androidaps.utils.DateUtil @@ -48,7 +51,8 @@ class LocalProfilePlugin @Inject constructor( private val profileFunction: ProfileFunction, private val activePlugin: ActivePlugin, private val hardLimits: HardLimits, - private val dateUtil: DateUtil + private val dateUtil: DateUtil, + private val config: Config ) : PluginBase(PluginDescription() .mainType(PluginType.PROFILE) .fragmentClass(LocalProfileFragment::class.java.name) @@ -131,11 +135,11 @@ class LocalProfilePlugin @Inject constructor( ToastUtils.errorToast(activity,resourceHelper.gs(R.string.error_in_basal_values)) return false } - if (low?.any { it.amount < HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble() || it.amount > HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble() } != false) { - ToastUtils.errorToast(activity,resourceHelper.gs(R.string.error_in_target_values)) + if (low?.any { hardLimits.isInRange(it.amount, HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]) } == false) { + ToastUtils.errorToast(activity, resourceHelper.gs(R.string.error_in_target_values)) return false } - if (high?.any { it.amount < HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble() || it.amount > HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble() } != false) { + if (high?.any { hardLimits.isInRange(it.amount, HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]) } == false) { ToastUtils.errorToast(activity,resourceHelper.gs(R.string.error_in_target_values)) return false } @@ -148,18 +152,22 @@ class LocalProfilePlugin @Inject constructor( ToastUtils.errorToast(activity,resourceHelper.gs(R.string.error_in_basal_values)) return false } - if (low?.any { it.amount < Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), GlucoseUnit.MMOL) || it.amount > Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), GlucoseUnit.MMOL) } != false) { - ToastUtils.errorToast(activity,resourceHelper.gs(R.string.error_in_target_values)) + if (low?.any { hardLimits.isInRange(Profile.toMgdl(it.amount, GlucoseUnit.MMOL), HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]) } == false) { + ToastUtils.errorToast(activity, resourceHelper.gs(R.string.error_in_target_values)) return false } - if (high?.any { it.amount < Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), GlucoseUnit.MMOL) || it.amount > Profile.fromMgdlToUnits(HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), GlucoseUnit.MMOL) } != false) { + if (high?.any { hardLimits.isInRange(Profile.toMgdl(it.amount, GlucoseUnit.MMOL), HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]) } == false) { ToastUtils.errorToast(activity,resourceHelper.gs(R.string.error_in_target_values)) return false } } - for (i in low.indices) if (low[i].amount > high[i].amount) { - ToastUtils.errorToast(activity,resourceHelper.gs(R.string.error_in_target_values)) - return false + low?.let { + high?.let { + for (i in low.indices) if (low[i].amount > high[i].amount) { + ToastUtils.errorToast(activity,resourceHelper.gs(R.string.error_in_target_values)) + return false + } + } } } return true @@ -251,10 +259,25 @@ class LocalProfilePlugin @Inject constructor( try { val newProfiles: ArrayList = ArrayList() for (p in store.getProfileList()) { - store.getSpecificProfile(p.toString())?.let { - val sp = copyFrom(it, p.toString()) + val profile = store.getSpecificProfile(p.toString()) + val validityCheck = profile?.let { ProfileSealed.Pure(profile).isValid("NS", activePlugin.activePump, config, resourceHelper, rxBus, hardLimits, false) } ?: Profile.ValidityCheck() + if (profile != null && validityCheck.isValid) { + val sp = copyFrom(profile, p.toString()) sp.name = p.toString() newProfiles.add(sp) + } else { + val n = NotificationWithAction( + injector, + Notification.INVALID_PROFILE_NOT_ACCEPTED, + resourceHelper.gs(R.string.invalid_profile_not_accepted, p.toString()), + Notification.NORMAL + ) + n.action(R.string.view) { + n.contextForAction?.let { + OKDialog.show(it, resourceHelper.gs(R.string.errors), validityCheck.reasons.joinToString(separator = "\n"), null) + } + } + rxBus.send(EventNewNotification(n)) } } if (newProfiles.size > 0) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ee00a2eab8..2fe7985621 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1125,5 +1125,8 @@ Error in target values Error in ISF values Run %s? + Invalid profile %1$s not accepted from NS + View + Errors 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 93286b5a3d..58e00a684c 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt +++ b/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt @@ -122,6 +122,11 @@ sealed class ProfileSealed( break } } + if (!hardLimits.isInRange(basalAmount, 0.01, hardLimits.maxBasal())) { + validityCheck.isValid = false + validityCheck.reasons.add(resourceHelper.gs(R.string.value_out_of_hard_limits, resourceHelper.gs(R.string.basal_value), basalAmount)) + break + } // Check for minimal basal value if (basalAmount < description.basalMinimumRate) { basal.amount = description.basalMinimumRate @@ -136,11 +141,6 @@ sealed class ProfileSealed( validityCheck.reasons.add(resourceHelper.gs(R.string.maximumbasalvaluereplaced, from)) break } - if (!hardLimits.isInRange(basalAmount, 0.01, hardLimits.maxBasal())) { - validityCheck.isValid = false - validityCheck.reasons.add(resourceHelper.gs(R.string.value_out_of_hard_limits, resourceHelper.gs(R.string.basal_value), basalAmount)) - break - } } if (!hardLimits.isInRange(dia, hardLimits.minDia(), hardLimits.maxDia())) { validityCheck.isValid = false @@ -160,9 +160,9 @@ sealed class ProfileSealed( } for (target in targetBlocks) { if (!hardLimits.isInRange( - Profile.toMgdl(target.lowTarget, units), - HardLimits.VERY_HARD_LIMIT_MIN_BG[0].toDouble(), - HardLimits.VERY_HARD_LIMIT_MIN_BG[1].toDouble() + toMgdl(target.lowTarget, units), + HardLimits.VERY_HARD_LIMIT_MIN_BG[0], + HardLimits.VERY_HARD_LIMIT_MIN_BG[1] ) ) { validityCheck.isValid = false @@ -170,9 +170,9 @@ sealed class ProfileSealed( break } if (!hardLimits.isInRange( - Profile.toMgdl(target.highTarget, units), - HardLimits.VERY_HARD_LIMIT_MAX_BG[0].toDouble(), - HardLimits.VERY_HARD_LIMIT_MAX_BG[1].toDouble() + toMgdl(target.highTarget, units), + HardLimits.VERY_HARD_LIMIT_MAX_BG[0], + HardLimits.VERY_HARD_LIMIT_MAX_BG[1] ) ) { validityCheck.isValid = false diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileStore.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileStore.kt index 03b0d773bf..49ad281742 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileStore.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileStore.kt @@ -68,7 +68,7 @@ class ProfileStore(val injector: HasAndroidInjector, val data: JSONObject, val d if (profile == null) { JsonHelper.safeGetJSONObject(store, profileName, null)?.let { profileObject -> profile = pureProfileFromJson(profileObject, dateUtil, defaultUnits) - cachedObjects[profileName] = profile + profile?.let { cachedObjects[profileName] = profile } } } } diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.kt index b7325e964e..c7b55e93ae 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.general.overview.notifications +import android.content.Context import androidx.annotation.RawRes import info.nightscout.androidaps.utils.T @@ -14,6 +15,8 @@ open class Notification { var action: Runnable? = null var buttonText = 0 + var contextForAction: Context? = null + constructor() constructor(id: Int, date: Long, text: String, level: Int, validTo: Long) { this.id = id @@ -55,6 +58,7 @@ open class Notification { const val LOW = 2 const val INFO = 3 const val ANNOUNCEMENT = 4 + const val PROFILE_SET_FAILED = 0 const val PROFILE_SET_OK = 1 const val EASY_MODE_ENABLED = 2 @@ -122,6 +126,7 @@ open class Notification { const val WRONG_PUMP_DATA = 72 const val NSCLIENT_VERSION_DOES_NOT_MATCH = 73 const val VERSION_EXPIRE = 74 + const val INVALID_PROFILE_NOT_ACCEPTED = 75 const val USER_MESSAGE = 1000 diff --git a/core/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt b/core/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt index aecb0ff2b4..c71691462b 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/HardLimits.kt @@ -40,9 +40,9 @@ class HardLimits @Inject constructor( // Very Hard Limits Ranges // First value is the Lowest and second value is the Highest a Limit can define - val VERY_HARD_LIMIT_MIN_BG = intArrayOf(80, 180) - val VERY_HARD_LIMIT_MAX_BG = intArrayOf(90, 270) - val VERY_HARD_LIMIT_TARGET_BG = intArrayOf(80, 200) + val VERY_HARD_LIMIT_MIN_BG = doubleArrayOf(80.0, 180.0) + val VERY_HARD_LIMIT_MAX_BG = doubleArrayOf(90.0, 200.0) + val VERY_HARD_LIMIT_TARGET_BG = doubleArrayOf(80.0, 200.0) // Very Hard Limits Ranges for Temp Targets val VERY_HARD_LIMIT_TEMP_MIN_BG = intArrayOf(72, 180) From fa23f30ab1ca5ee56418cccdbda0dc6ecd037101 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 1 Nov 2021 22:51:13 +0100 Subject: [PATCH 17/29] lints --- .../androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt index e18ae5dd9d..05e65e78bc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.kt @@ -18,7 +18,6 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP import org.json.JSONArray import org.json.JSONException import org.json.JSONObject -import java.util.* import javax.inject.Inject import javax.inject.Singleton @@ -195,7 +194,7 @@ class NSDeviceStatus @Inject constructor( if (clock == 0L || deviceStatusData.pumpData != null && clock < deviceStatusData.pumpData!!.clock) return // create new status and process data - var deviceStatusPumpData = DeviceStatusData.PumpData() + val deviceStatusPumpData = DeviceStatusData.PumpData() deviceStatusPumpData.clock = clock if (pump.has("status") && pump.getJSONObject("status").has("status")) deviceStatusPumpData.status = pump.getJSONObject("status").getString("status") if (pump.has("reservoir")) deviceStatusPumpData.reservoir = pump.getDouble("reservoir") From d53071297ee276caf897268e20451efe1a08a5af Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 1 Nov 2021 22:54:55 +0100 Subject: [PATCH 18/29] fix showing Save button --- .../androidaps/plugins/profile/local/LocalProfileFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index 59310cb8f4..2106eb5a86 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -126,7 +126,7 @@ class LocalProfileFragment : DaggerFragment() { binding.name.removeTextChangedListener(textWatch) binding.name.setText(currentProfile.name) binding.name.addTextChangedListener(textWatch) - binding.dia.setParams(currentProfile.dia, hardLimits.minDia(), hardLimits.maxDia(), 0.1, DecimalFormat("0.0"), false, binding.save, textWatch) + binding.dia.setParams(currentProfile.dia, hardLimits.minDia(), hardLimits.maxDia(), 0.1, DecimalFormat("0.0"), false, null, textWatch) binding.dia.tag = "LP_DIA" TimeListEdit(context, aapsLogger, dateUtil, view, R.id.ic, "IC", resourceHelper.gs(R.string.ic_label), currentProfile.ic, null, hardLimits.minIC(), hardLimits.maxIC(), 0.1, DecimalFormat("0.0"), save) basalView = TimeListEdit(context, aapsLogger, dateUtil, view, R.id.basal_holder, "BASAL", resourceHelper.gs(R.string.basal_label) + ": " + sumLabel(), currentProfile.basal, null, pumpDescription.basalMinimumRate, pumpDescription.basalMaximumRate, 0.01, DecimalFormat("0.00"), save) From 760261e258e51e0d8f290e1ae9322df7bc1e0ff1 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Nov 2021 09:19:56 +0100 Subject: [PATCH 19/29] exclude invalid profiles from ProfileSwitchDialog --- .../androidaps/dialogs/ProfileSwitchDialog.kt | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index 732070815c..14fb20d79d 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -38,6 +38,7 @@ import java.text.DecimalFormat import java.util.* import java.util.concurrent.TimeUnit import javax.inject.Inject +import kotlin.collections.ArrayList class ProfileSwitchDialog : DialogFragmentWithDate() { @@ -113,7 +114,17 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { context?.let { context -> val profileStore = activePlugin.activeProfileSource.profile ?: return - val profileList = profileStore.getProfileList() + val profileListToCheck = profileStore.getProfileList() + val profileList = ArrayList() + for (profileName in profileListToCheck) { + val profileToCheck = activePlugin.activeProfileSource.profile?.getSpecificProfile(profileName.toString()) + if (profileToCheck != null && ProfileSealed.Pure(profileToCheck).isValid("ProfileSwitch", activePlugin.activePump, config, resourceHelper, rxBus, hardLimits, false).isValid) + profileList.add(profileName) + } + if (profileList.isEmpty()) { + dismiss() + return + } val adapter = ArrayAdapter(context, R.layout.spinner_centered, profileList) binding.profile.adapter = adapter // set selected to actual profile @@ -123,7 +134,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { for (p in profileList.indices) if (profileList[p] == profileFunction.getOriginalProfileName()) binding.profile.setSelection(p) - } ?: return + } profileFunction.getProfile()?.let { profile -> if (profile is ProfileSealed.EPS) @@ -183,13 +194,14 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { if (validity.isValid) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { if (profileFunction.createProfileSwitch( - profileStore, - profileName = profileName, - durationInMinutes = duration, - percentage = percent, - timeShiftInHours = timeShift, - timestamp = eventTime - )) { + profileStore, + profileName = profileName, + durationInMinutes = duration, + percentage = percent, + timeShiftInHours = timeShift, + timestamp = eventTime + ) + ) { uel.log(Action.PROFILE_SWITCH, Sources.ProfileSwitchDialog, notes, From bb2fced905bb6a64cb0c26ae000aa96a0032a64d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Nov 2021 09:53:16 +0100 Subject: [PATCH 20/29] fix NaN in statistics --- .../nightscout/androidaps/MainActivity.kt | 26 +++---- .../activities/HistoryBrowseActivity.kt | 12 +-- .../activities/PreferencesActivity.kt | 2 +- .../activities/ProfileHelperActivity.kt | 22 +++--- .../androidaps/activities/StatsActivity.kt | 9 ++- .../activities/TreatmentsActivity.kt | 16 ++-- .../activities/QuickWizardListActivity.kt | 2 +- .../activities/SmsCommunicatorOtpActivity.kt | 12 +-- .../setupwizard/SetupWizardActivity.kt | 4 +- .../DaggerAppCompatActivityWithResult.kt | 4 +- .../androidaps/activities/TDDStatsActivity.kt | 73 ++++++++++--------- .../extensions/TotalDailyDoseExtension.kt | 15 ++-- .../dana/activities/DanaHistoryActivity.kt | 28 +++---- .../activities/DanaUserOptionsActivity.kt | 2 +- .../danars/activities/EnterPinActivity.kt | 14 ++-- .../activities/DiaconnG8HistoryActivity.kt | 22 +++--- .../DiaconnG8UserOptionsActivity.kt | 14 ++-- .../omnipod/dash/ui/DashPodHistoryActivity.kt | 10 +-- .../dash/ui/DashPodManagementActivity.kt | 8 +- .../eros/ui/ErosPodManagementActivity.kt | 10 +-- 20 files changed, 156 insertions(+), 149 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index c7a4b5b447..4b9ce47c7f 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -113,7 +113,7 @@ class MainActivity : NoSplashAppCompatActivity() { } // initialize screen wake lock - processPreferenceChange(EventPreferenceChange(resourceHelper.gs(R.string.key_keep_screen_on))) + processPreferenceChange(EventPreferenceChange(rh.gs(R.string.key_keep_screen_on))) binding.mainPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { override fun onPageScrollStateChanged(state: Int) {} override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {} @@ -173,8 +173,8 @@ class MainActivity : NoSplashAppCompatActivity() { override fun onResume() { super.onResume() protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, null, - UIRunnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed)) { finish() } }, - UIRunnable { OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed)) { finish() } } + UIRunnable { OKDialog.show(this, "", rh.gs(R.string.authorizationfailed)) { finish() } }, + UIRunnable { OKDialog.show(this, "", rh.gs(R.string.authorizationfailed)) { finish() } } ) } @@ -184,8 +184,8 @@ class MainActivity : NoSplashAppCompatActivity() { } private fun processPreferenceChange(ev: EventPreferenceChange) { - if (ev.isChanged(resourceHelper, R.string.key_keep_screen_on)) setWakeLock() - if (ev.isChanged(resourceHelper, R.string.key_skin)) recreate() + if (ev.isChanged(rh, R.string.key_keep_screen_on)) setWakeLock() + if (ev.isChanged(rh, R.string.key_skin)) recreate() } private fun setupViews() { @@ -259,7 +259,7 @@ class MainActivity : NoSplashAppCompatActivity() { private fun setPluginPreferenceMenuName() { if (binding.mainPager.currentItem >= 0) { val plugin = (binding.mainPager.adapter as TabPageAdapter).getPluginAt(binding.mainPager.currentItem) - this.menu?.findItem(R.id.nav_plugin_preferences)?.title = resourceHelper.gs(R.string.nav_preferences_plugin, plugin.name) + this.menu?.findItem(R.id.nav_plugin_preferences)?.title = rh.gs(R.string.nav_preferences_plugin, plugin.name) } } @@ -309,18 +309,18 @@ class MainActivity : NoSplashAppCompatActivity() { R.id.nav_about -> { var message = "Build: ${BuildConfig.BUILDVERSION}\n" message += "Flavor: ${BuildConfig.FLAVOR}${BuildConfig.BUILD_TYPE}\n" - message += "${resourceHelper.gs(R.string.configbuilder_nightscoutversion_label)} ${nsSettingsStatus.getVersion()}" - if (buildHelper.isEngineeringMode()) message += "\n${resourceHelper.gs(R.string.engineering_mode_enabled)}" - if (!fabricPrivacy.fabricEnabled()) message += "\n${resourceHelper.gs(R.string.fabric_upload_disabled)}" - message += resourceHelper.gs(R.string.about_link_urls) + message += "${rh.gs(R.string.configbuilder_nightscoutversion_label)} ${nsSettingsStatus.getVersion()}" + if (buildHelper.isEngineeringMode()) message += "\n${rh.gs(R.string.engineering_mode_enabled)}" + if (!fabricPrivacy.fabricEnabled()) message += "\n${rh.gs(R.string.fabric_upload_disabled)}" + message += rh.gs(R.string.about_link_urls) val messageSpanned = SpannableString(message) Linkify.addLinks(messageSpanned, Linkify.WEB_URLS) AlertDialog.Builder(this) - .setTitle(resourceHelper.gs(R.string.app_name) + " " + BuildConfig.VERSION) + .setTitle(rh.gs(R.string.app_name) + " " + BuildConfig.VERSION) .setIcon(iconsProvider.getIcon()) .setMessage(messageSpanned) - .setPositiveButton(resourceHelper.gs(R.string.ok), null) - .setNeutralButton(resourceHelper.gs(R.string.cta_dont_kill_my_app_info)) { _, _ -> DokiActivity.start(context = this@MainActivity) } + .setPositiveButton(rh.gs(R.string.ok), null) + .setNeutralButton(rh.gs(R.string.cta_dont_kill_my_app_info)) { _, _ -> DokiActivity.start(context = this@MainActivity) } .create().apply { show() findViewById(android.R.id.message)?.movementMethod = LinkMovementMethod.getInstance() diff --git a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt index ebf2360320..74d46d6b39 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt @@ -89,8 +89,8 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { setContentView(binding.root) // We don't want to use injected singletons but own instance working on top of different data - iobCobCalculator = IobCobCalculatorPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, resourceHelper, profileFunction, activePlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil, repository) - overviewData = OverviewData(injector, aapsLogger, resourceHelper, dateUtil, sp, activePlugin, defaultValueHelper, profileFunction, config, loopPlugin, nsDeviceStatus, repository, overviewMenus, iobCobCalculator, translator) + iobCobCalculator = IobCobCalculatorPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, rh, profileFunction, activePlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil, repository) + overviewData = OverviewData(injector, aapsLogger, rh, dateUtil, sp, activePlugin, defaultValueHelper, profileFunction, config, loopPlugin, nsDeviceStatus, repository, overviewMenus, iobCobCalculator, translator) binding.left.setOnClickListener { adjustTimeRange(overviewData.fromTime - T.hours(rangeToDisplay.toLong()).msecs()) @@ -158,7 +158,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { axisWidth = if (dm.densityDpi <= 120) 3 else if (dm.densityDpi <= 160) 10 else if (dm.densityDpi <= 320) 35 else if (dm.densityDpi <= 420) 50 else if (dm.densityDpi <= 560) 70 else 80 - binding.bgGraph.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid) + binding.bgGraph.gridLabelRenderer?.gridColor = rh.gc(R.color.graphgrid) binding.bgGraph.gridLabelRenderer?.reloadStyles() binding.bgGraph.gridLabelRenderer?.labelVerticalWidth = axisWidth @@ -241,8 +241,8 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { relativeLayout.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) val graph = GraphView(this) - graph.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, resourceHelper.dpToPx(100)).also { it.setMargins(0, resourceHelper.dpToPx(15), 0, resourceHelper.dpToPx(10)) } - graph.gridLabelRenderer?.gridColor = resourceHelper.gc(R.color.graphgrid) + graph.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, rh.dpToPx(100)).also { it.setMargins(0, rh.dpToPx(15), 0, rh.dpToPx(10)) } + graph.gridLabelRenderer?.gridColor = rh.gc(R.color.graphgrid) graph.gridLabelRenderer?.reloadStyles() graph.gridLabelRenderer?.isHorizontalLabelsVisible = false graph.gridLabelRenderer?.labelVerticalWidth = axisWidth @@ -251,7 +251,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { relativeLayout.addView(graph) val label = TextView(this) - val layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).also { it.setMargins(resourceHelper.dpToPx(30), resourceHelper.dpToPx(25), 0, 0) } + val layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).also { it.setMargins(rh.dpToPx(30), rh.dpToPx(25), 0, 0) } layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP) layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT) label.layoutParams = layoutParams diff --git a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt index d209670b01..edff599122 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt @@ -31,7 +31,7 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa override fun afterTextChanged(s: Editable) {} }) - title = resourceHelper.gs(R.string.nav_preferences) + title = rh.gs(R.string.nav_preferences) supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayShowHomeEnabled(true) myPreferenceFragment = MyPreferenceFragment() diff --git a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt index 9e0bd5db90..47b574ad33 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt @@ -140,7 +140,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { val profile = if (typeSelected[tabSelected] == ProfileType.MOTOL_DEFAULT) defaultProfile.profile(age, tdd, weight, profileFunction.getUnits()) else defaultProfileDPV.profile(age, tdd, pct / 100.0, profileFunction.getUnits()) profile?.let { - OKDialog.showConfirmation(this, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile), Runnable { + OKDialog.showConfirmation(this, rh.gs(R.string.careportal_profileswitch), rh.gs(R.string.copytolocalprofile), Runnable { localProfilePlugin.addProfile(localProfilePlugin.copyFrom(it, "DefaultProfile " + dateUtil.dateAndTimeAndSecondsString(dateUtil.now()) .replace(".", "/") @@ -242,8 +242,8 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { private fun getProfileName(age: Double, tdd: Double, weight: Double, basalSumPct: Double, tab: Int): String = when (typeSelected[tab]) { - ProfileType.MOTOL_DEFAULT -> if (tdd > 0) resourceHelper.gs(R.string.formatwithtdd, age, tdd) else resourceHelper.gs(R.string.formatwithweight, age, weight) - ProfileType.DPV_DEFAULT -> resourceHelper.gs(R.string.formatwittddandpct, age, tdd, (basalSumPct * 100).toInt()) + ProfileType.MOTOL_DEFAULT -> if (tdd > 0) rh.gs(R.string.formatwithtdd, age, tdd) else rh.gs(R.string.formatwithweight, age, weight) + ProfileType.DPV_DEFAULT -> rh.gs(R.string.formatwittddandpct, age, tdd, (basalSumPct * 100).toInt()) ProfileType.CURRENT -> profileFunction.getProfileName() ProfileType.AVAILABLE_PROFILE -> profileList[profileUsed[tab]].toString() ProfileType.PROFILE_SWITCH -> profileSwitch[profileSwitchUsed[tab]].originalCustomizedName @@ -263,16 +263,16 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { tabSelected = tab typeSelected[tabSelected] = newContent - binding.profiletypeTitle.defaultHintTextColor = ColorStateList.valueOf(resourceHelper.gc(if (tab == 0) R.color.tabBgColorSelected else R.color.examinedProfile)) + binding.profiletypeTitle.defaultHintTextColor = ColorStateList.valueOf(rh.gc(if (tab == 0) R.color.tabBgColorSelected else R.color.examinedProfile)) // show new content binding.profiletype.setText( when (typeSelected[tabSelected]) { - ProfileType.MOTOL_DEFAULT -> resourceHelper.gs(R.string.motoldefaultprofile) - ProfileType.DPV_DEFAULT -> resourceHelper.gs(R.string.dpvdefaultprofile) - ProfileType.CURRENT -> resourceHelper.gs(R.string.currentprofile) - ProfileType.AVAILABLE_PROFILE -> resourceHelper.gs(R.string.availableprofile) - ProfileType.PROFILE_SWITCH -> resourceHelper.gs(R.string.careportal_profileswitch) + ProfileType.MOTOL_DEFAULT -> rh.gs(R.string.motoldefaultprofile) + ProfileType.DPV_DEFAULT -> rh.gs(R.string.dpvdefaultprofile) + ProfileType.CURRENT -> rh.gs(R.string.currentprofile) + ProfileType.AVAILABLE_PROFILE -> rh.gs(R.string.availableprofile) + ProfileType.PROFILE_SWITCH -> rh.gs(R.string.careportal_profileswitch) }) binding.defaultProfile.visibility = (newContent == ProfileType.MOTOL_DEFAULT || newContent == ProfileType.DPV_DEFAULT).toVisibility() binding.currentProfile.visibility = (newContent == ProfileType.CURRENT).toVisibility() @@ -293,7 +293,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { } private fun setBackgroundColorOnSelected(tab: Int) { - binding.menu1.setBackgroundColor(resourceHelper.gc(if (tab == 1) R.color.defaultbackground else R.color.tempbasal)) - binding.menu2.setBackgroundColor(resourceHelper.gc(if (tab == 0) R.color.defaultbackground else R.color.examinedProfile)) + binding.menu1.setBackgroundColor(rh.gc(if (tab == 1) R.color.defaultbackground else R.color.tempbasal)) + binding.menu2.setBackgroundColor(rh.gc(if (tab == 0) R.color.defaultbackground else R.color.examinedProfile)) } } diff --git a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt index 82912e3da3..1ad4bb826f 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt @@ -9,6 +9,7 @@ import info.nightscout.androidaps.databinding.ActivityStatsBinding import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.utils.ActivityMonitor import info.nightscout.androidaps.utils.alertDialogs.OKDialog +import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.stats.TddCalculator import info.nightscout.androidaps.utils.stats.TirCalculator import javax.inject.Inject @@ -28,9 +29,9 @@ class StatsActivity : NoSplashAppCompatActivity() { binding = ActivityStatsBinding.inflate(layoutInflater) setContentView(binding.root) - binding.tdds.text = getString(R.string.tdd) + ": " + getString(R.string.calculation_in_progress) - binding.tir.text = getString(R.string.tir) + ": " + getString(R.string.calculation_in_progress) - binding.activity.text = getString(R.string.activitymonitor) + ": " + getString(R.string.calculation_in_progress) + binding.tdds.text = getString(R.string.tdd) + ": " + rh.gs(R.string.calculation_in_progress) + binding.tir.text = getString(R.string.tir) + ": " + rh.gs(R.string.calculation_in_progress) + binding.activity.text = rh.gs(R.string.activitymonitor) + ": " + rh.gs(R.string.calculation_in_progress) Thread { val tdds = tddCalculator.stats() @@ -47,7 +48,7 @@ class StatsActivity : NoSplashAppCompatActivity() { binding.ok.setOnClickListener { finish() } binding.reset.setOnClickListener { - OKDialog.showConfirmation(this, resourceHelper.gs(R.string.doyouwantresetstats)) { + OKDialog.showConfirmation(this, rh.gs(R.string.doyouwantresetstats)) { uel.log(Action.STAT_RESET, Sources.Stats) activityMonitor.reset() recreate() diff --git a/app/src/main/java/info/nightscout/androidaps/activities/TreatmentsActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/TreatmentsActivity.kt index 4cd4ab559a..a24e651b0b 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/TreatmentsActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/TreatmentsActivity.kt @@ -67,14 +67,14 @@ class TreatmentsActivity : NoSplashAppCompatActivity() { } private fun setBackgroundColorOnSelected(selected: View) { - binding.treatments.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground)) - binding.extendedBoluses.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground)) - binding.tempBasals.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground)) - binding.tempTargets.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground)) - binding.profileSwitches.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground)) - binding.careportal.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground)) - binding.userentry.setBackgroundColor(resourceHelper.gc(R.color.defaultbackground)) - selected.setBackgroundColor(resourceHelper.gc(R.color.tabBgColorSelected)) + binding.treatments.setBackgroundColor(rh.gc(R.color.defaultbackground)) + binding.extendedBoluses.setBackgroundColor(rh.gc(R.color.defaultbackground)) + binding.tempBasals.setBackgroundColor(rh.gc(R.color.defaultbackground)) + binding.tempTargets.setBackgroundColor(rh.gc(R.color.defaultbackground)) + binding.profileSwitches.setBackgroundColor(rh.gc(R.color.defaultbackground)) + binding.careportal.setBackgroundColor(rh.gc(R.color.defaultbackground)) + binding.userentry.setBackgroundColor(rh.gc(R.color.defaultbackground)) + selected.setBackgroundColor(rh.gc(R.color.tabBgColorSelected)) } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt index 0b82509cc1..eb56d8067e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/activities/QuickWizardListActivity.kt @@ -45,7 +45,7 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() { holder.from.text = dateUtil.timeString(quickWizard[position].validFromDate()) holder.to.text = dateUtil.timeString(quickWizard[position].validToDate()) holder.buttonText.text = quickWizard[position].buttonText() - holder.carbs.text = resourceHelper.gs(R.string.format_carbs, quickWizard[position].carbs()) + holder.carbs.text = rh.gs(R.string.format_carbs, quickWizard[position].carbs()) } override fun getItemCount(): Int = quickWizard.size() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt index f6bc7a230a..f3f7b150bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt @@ -71,25 +71,25 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { binding.otpReset.setOnClickListener { OKDialog.showConfirmation(this, - resourceHelper.gs(R.string.smscommunicator_otp_reset_title), - resourceHelper.gs(R.string.smscommunicator_otp_reset_prompt), + rh.gs(R.string.smscommunicator_otp_reset_title), + rh.gs(R.string.smscommunicator_otp_reset_prompt), Runnable { uel.log(Action.OTP_RESET, Sources.SMS) otp.ensureKey(true) updateGui() - ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_reset_successful)) + ToastUtils.Long.infoToast(this, rh.gs(R.string.smscommunicator_otp_reset_successful)) }) } binding.otpProvisioning.setOnLongClickListener { OKDialog.showConfirmation(this, - resourceHelper.gs(R.string.smscommunicator_otp_export_title), - resourceHelper.gs(R.string.smscommunicator_otp_export_prompt), + rh.gs(R.string.smscommunicator_otp_export_title), + rh.gs(R.string.smscommunicator_otp_export_prompt), Runnable { val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager val clip = ClipData.newPlainText("OTP Secret", otp.provisioningSecret()) clipboard.setPrimaryClip(clip) - ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_export_successful)) + ToastUtils.Long.infoToast(this, rh.gs(R.string.smscommunicator_otp_export_successful)) uel.log(Action.OTP_EXPORT, Sources.SMS) }) diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt index 7e964ab77d..2239207183 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt @@ -145,13 +145,13 @@ class SetupWizardActivity : NoSplashAppCompatActivity() { } override fun onBackPressed() { - if (currentWizardPage == 0) OKDialog.showConfirmation(this, resourceHelper.gs(R.string.exitwizard)) { finish() } else showPreviousPage(null) + if (currentWizardPage == 0) OKDialog.showConfirmation(this, rh.gs(R.string.exitwizard)) { finish() } else showPreviousPage(null) } @Suppress("UNUSED_PARAMETER") fun exitPressed(view: View?) { sp.putBoolean(R.string.key_setupwizard_processed, true) - OKDialog.showConfirmation(this, resourceHelper.gs(R.string.exitwizard)) { finish() } + OKDialog.showConfirmation(this, rh.gs(R.string.exitwizard)) { finish() } } @Suppress("UNUSED_PARAMETER") diff --git a/core/src/main/java/info/nightscout/androidaps/activities/DaggerAppCompatActivityWithResult.kt b/core/src/main/java/info/nightscout/androidaps/activities/DaggerAppCompatActivityWithResult.kt index 986ef95719..0a2941fe7b 100644 --- a/core/src/main/java/info/nightscout/androidaps/activities/DaggerAppCompatActivityWithResult.kt +++ b/core/src/main/java/info/nightscout/androidaps/activities/DaggerAppCompatActivityWithResult.kt @@ -15,7 +15,7 @@ import javax.inject.Inject open class DaggerAppCompatActivityWithResult : DaggerAppCompatActivity() { - @Inject lateinit var resourceHelper: ResourceHelperImplementation + @Inject lateinit var rh: ResourceHelperImplementation @Inject lateinit var importExportPrefs: ImportExportPrefs val callForPrefFile = registerForActivityResult(PrefsFileContract()) { @@ -35,7 +35,7 @@ open class DaggerAppCompatActivityWithResult : DaggerAppCompatActivity() { when (it.key) { Manifest.permission.WRITE_EXTERNAL_STORAGE -> //show dialog after permission is granted - OKDialog.show(this, "", resourceHelper.gs(R.string.alert_dialog_storage_permission_text)) + OKDialog.show(this, "", rh.gs(R.string.alert_dialog_storage_permission_text)) // ignore the rest } } diff --git a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt index 3a8dea9020..64481f241a 100644 --- a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt +++ b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt @@ -94,23 +94,23 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { trHead.setBackgroundColor(Color.DKGRAY) trHead.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) trHead.addView(TextView(this).also { labelDate -> - labelDate.text = resourceHelper.gs(R.string.date) + labelDate.text = rh.gs(R.string.date) labelDate.setTextColor(Color.WHITE) }) trHead.addView(TextView(this).also { labelBasalRate -> - labelBasalRate.text = resourceHelper.gs(R.string.basalrate) + labelBasalRate.text = rh.gs(R.string.basalrate) labelBasalRate.setTextColor(Color.WHITE) }) trHead.addView(TextView(this).also { labelBolus -> - labelBolus.text = resourceHelper.gs(R.string.bolus) + labelBolus.text = rh.gs(R.string.bolus) labelBolus.setTextColor(Color.WHITE) }) trHead.addView(TextView(this).also { labelTdd -> - labelTdd.text = resourceHelper.gs(R.string.tdd) + labelTdd.text = rh.gs(R.string.tdd) labelTdd.setTextColor(Color.WHITE) }) trHead.addView(TextView(this).also { labelRatio -> - labelRatio.text = resourceHelper.gs(R.string.ratio) + labelRatio.text = rh.gs(R.string.ratio) labelRatio.setTextColor(Color.WHITE) }) }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) @@ -122,15 +122,15 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { ctrHead.setBackgroundColor(Color.DKGRAY) ctrHead.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) ctrHead.addView(TextView(this).also { labelCumAmountDays -> - labelCumAmountDays.text = resourceHelper.gs(R.string.amount_days) + labelCumAmountDays.text = rh.gs(R.string.amount_days) labelCumAmountDays.setTextColor(Color.WHITE) }) ctrHead.addView(TextView(this).also { labelCumTdd -> - labelCumTdd.text = resourceHelper.gs(R.string.tdd) + labelCumTdd.text = rh.gs(R.string.tdd) labelCumTdd.setTextColor(Color.WHITE) }) ctrHead.addView(TextView(this).also { labelCumRatio -> - labelCumRatio.text = resourceHelper.gs(R.string.ratio) + labelCumRatio.text = rh.gs(R.string.ratio) labelCumRatio.setTextColor(Color.WHITE) }) }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) @@ -142,15 +142,15 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { etrHead.setBackgroundColor(Color.DKGRAY) etrHead.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) etrHead.addView(TextView(this).also { labelExpWeight -> - labelExpWeight.text = resourceHelper.gs(R.string.weight) + labelExpWeight.text = rh.gs(R.string.weight) labelExpWeight.setTextColor(Color.WHITE) }) etrHead.addView(TextView(this).also { labelExpTdd -> - labelExpTdd.text = resourceHelper.gs(R.string.tdd) + labelExpTdd.text = rh.gs(R.string.tdd) labelExpTdd.setTextColor(Color.WHITE) }) etrHead.addView(TextView(this).also { labelExpRatio -> - labelExpRatio.text = resourceHelper.gs(R.string.ratio) + labelExpRatio.text = rh.gs(R.string.ratio) labelExpRatio.setTextColor(Color.WHITE) }) }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) @@ -160,7 +160,7 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { binding.reload.visibility = View.GONE binding.connectionStatus.visibility = View.VISIBLE binding.message.visibility = View.VISIBLE - binding.message.text = resourceHelper.gs(R.string.warning_Message) + binding.message.text = rh.gs(R.string.warning_Message) commandQueue.loadTDDs(object : Callback() { override fun run() { loadDataFromDB() @@ -195,18 +195,20 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { override fun onResume() { super.onResume() - disposable.add(rxBus - .toObservable(EventPumpStatusChanged::class.java) - .observeOn(aapsSchedulers.main) - .subscribe({ event -> binding.connectionStatus.text = event.getStatus(resourceHelper) }, fabricPrivacy::logException) + disposable.add( + rxBus + .toObservable(EventPumpStatusChanged::class.java) + .observeOn(aapsSchedulers.main) + .subscribe({ event -> binding.connectionStatus.text = event.getStatus(rh) }, fabricPrivacy::logException) ) - disposable.add(rxBus - .toObservable(EventDanaRSyncStatus::class.java) - .observeOn(aapsSchedulers.main) - .subscribe({ event -> - aapsLogger.debug("EventDanaRSyncStatus: " + event.message) - binding.connectionStatus.text = event.message - }, fabricPrivacy::logException) + disposable.add( + rxBus + .toObservable(EventDanaRSyncStatus::class.java) + .observeOn(aapsSchedulers.main) + .subscribe({ event -> + aapsLogger.debug("EventDanaRSyncStatus: " + event.message) + binding.connectionStatus.text = event.message + }, fabricPrivacy::logException) ) } @@ -292,7 +294,8 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { tr.id = 100 + i tr.layoutParams = TableLayout.LayoutParams( TableLayout.LayoutParams.MATCH_PARENT, - TableLayout.LayoutParams.WRAP_CONTENT) + TableLayout.LayoutParams.WRAP_CONTENT + ) // Here create the TextView dynamically tr.addView(TextView(this@TDDStatsActivity).also { labelDATE -> @@ -302,17 +305,17 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { }) tr.addView(TextView(this@TDDStatsActivity).also { labelBASAL -> labelBASAL.id = 300 + i - labelBASAL.text = resourceHelper.gs(R.string.formatinsulinunits, record.basalAmount) + labelBASAL.text = rh.gs(R.string.formatinsulinunits, record.basalAmount) labelBASAL.setTextColor(Color.WHITE) }) tr.addView(TextView(this@TDDStatsActivity).also { labelBOLUS -> labelBOLUS.id = 400 + i - labelBOLUS.text = resourceHelper.gs(R.string.formatinsulinunits, record.bolusAmount) + labelBOLUS.text = rh.gs(R.string.formatinsulinunits, record.bolusAmount) labelBOLUS.setTextColor(Color.WHITE) }) tr.addView(TextView(this@TDDStatsActivity).also { labelTDD -> labelTDD.id = 500 + i - labelTDD.text = resourceHelper.gs(R.string.formatinsulinunits, tdd) + labelTDD.text = rh.gs(R.string.formatinsulinunits, tdd) labelTDD.setTextColor(Color.WHITE) }) tr.addView(TextView(this@TDDStatsActivity).also { labelRATIO -> @@ -320,7 +323,8 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { labelRATIO.text = (100 * tdd / magicNumber).roundToInt().toString() + "%" labelRATIO.setTextColor(Color.WHITE) }) - }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)) + }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) + ) i++ } i = 0 @@ -349,7 +353,7 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { ctr.addView(TextView(this@TDDStatsActivity).also { labelCUMTDD -> labelCUMTDD.id = 900 + i - labelCUMTDD.text = resourceHelper.gs(R.string.formatinsulinunits, sum / i) + labelCUMTDD.text = rh.gs(R.string.formatinsulinunits, sum / i) labelCUMTDD.setTextColor(Color.WHITE) }) @@ -363,7 +367,7 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { } if (isOldData(historyList) && activePlugin.activePump.pumpDescription.needsManualTDDLoad) { binding.message.visibility = View.VISIBLE - binding.message.text = resourceHelper.gs(R.string.olddata_Message) + binding.message.text = rh.gs(R.string.olddata_Message) } else binding.mainTable.setBackgroundColor(Color.TRANSPARENT) if (historyList.isNotEmpty() && df1.format(Date(historyList[0].timestamp)) == df1.format(Date())) { //Today should not be included @@ -401,9 +405,9 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { etr.addView(TextView(this@TDDStatsActivity).also { labelEXPTDD -> labelEXPTDD.id = 1300 + i labelEXPTDD.text = """ - ${resourceHelper.gs(R.string.formatinsulinunits, weighted03)} - ${resourceHelper.gs(R.string.formatinsulinunits, weighted05)} - ${resourceHelper.gs(R.string.formatinsulinunits, weighted07)} + ${rh.gs(R.string.formatinsulinunits, weighted03)} + ${rh.gs(R.string.formatinsulinunits, weighted05)} + ${rh.gs(R.string.formatinsulinunits, weighted07)} """.trimIndent() labelEXPTDD.setTextColor(Color.WHITE) }) @@ -429,7 +433,8 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { private fun isOldData(historyList: List): Boolean { val type = activePlugin.activePump.pumpDescription.pumpType - val startsYesterday = type == PumpType.DANA_R || type == PumpType.DANA_RS || type == PumpType.DANA_RV2 || type == PumpType.DANA_R_KOREAN || type == PumpType.ACCU_CHEK_INSIGHT_VIRTUAL || type == PumpType.DIACONN_G8 + val startsYesterday = + type == PumpType.DANA_R || type == PumpType.DANA_RS || type == PumpType.DANA_RV2 || type == PumpType.DANA_R_KOREAN || type == PumpType.ACCU_CHEK_INSIGHT_VIRTUAL || type == PumpType.DIACONN_G8 val df: DateFormat = SimpleDateFormat("dd.MM.", Locale.getDefault()) return historyList.size < 3 || df.format(Date(historyList[0].timestamp)) != df.format(Date(System.currentTimeMillis() - if (startsYesterday) 1000 * 60 * 60 * 24 else 0)) } diff --git a/core/src/main/java/info/nightscout/androidaps/extensions/TotalDailyDoseExtension.kt b/core/src/main/java/info/nightscout/androidaps/extensions/TotalDailyDoseExtension.kt index eab8085a8c..31f228125f 100644 --- a/core/src/main/java/info/nightscout/androidaps/extensions/TotalDailyDoseExtension.kt +++ b/core/src/main/java/info/nightscout/androidaps/extensions/TotalDailyDoseExtension.kt @@ -4,7 +4,6 @@ import info.nightscout.androidaps.core.R import info.nightscout.androidaps.database.entities.TotalDailyDose import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.resources.ResourceHelper -import java.util.* val TotalDailyDose.total get() = if (totalAmount > 0) totalAmount else basalAmount + bolusAmount @@ -12,10 +11,12 @@ val TotalDailyDose.total val TotalDailyDose.basalPct: Double get() = if (total > 0) basalAmount / total * 100 else 0.0 -fun TotalDailyDose.toText(resourceHelper: ResourceHelper, dateUtil: DateUtil, includeCarbs: Boolean): String = - if (includeCarbs) resourceHelper.gs(R.string.tddwithcarbsformat, dateUtil.dateStringShort(timestamp), total, bolusAmount, basalAmount, basalPct, carbs) - else resourceHelper.gs(R.string.tddformat, dateUtil.dateStringShort(timestamp), total, bolusAmount, basalAmount, basalPct) +fun TotalDailyDose.toText(rh: ResourceHelper, dateUtil: DateUtil, includeCarbs: Boolean): String = + if (total.isNaN() || bolusAmount.isNaN() || basalAmount.isNaN() || carbs.isNaN()) "" + else if (includeCarbs) rh.gs(R.string.tddwithcarbsformat, dateUtil.dateStringShort(timestamp), total, bolusAmount, basalAmount, basalPct, carbs) + else rh.gs(R.string.tddformat, dateUtil.dateStringShort(timestamp), total, bolusAmount, basalAmount, basalPct) -fun TotalDailyDose.toText(resourceHelper: ResourceHelper, days: Int, includeCarbs: Boolean): String = - if (includeCarbs) resourceHelper.gs(R.string.tddwithcarbsformat, String.format(Locale.getDefault(), "%d ", days) + resourceHelper.gs(R.string.days), total, bolusAmount, basalAmount, basalAmount / total * 100, carbs) - else resourceHelper.gs(R.string.tddformat, String.format(Locale.getDefault(), "%d ", days) + resourceHelper.gs(R.string.days), total, bolusAmount, basalAmount, basalAmount / total * 100) +fun TotalDailyDose.toText(rh: ResourceHelper, days: Int, includeCarbs: Boolean): String = + if (total.isNaN() || bolusAmount.isNaN() || basalAmount.isNaN() || carbs.isNaN()) "" + else if (includeCarbs) rh.gs(R.string.tddwithcarbsformat, days.toString() + rh.gs(R.string.days), total, bolusAmount, basalAmount, basalAmount / total * 100, carbs) + else rh.gs(R.string.tddformat, days.toString() + rh.gs(R.string.days), total, bolusAmount, basalAmount, basalAmount / total * 100) diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaHistoryActivity.kt b/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaHistoryActivity.kt index 5b531eb2ce..f6101959b2 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaHistoryActivity.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaHistoryActivity.kt @@ -65,7 +65,7 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() { disposable += rxBus .toObservable(EventPumpStatusChanged::class.java) .observeOn(aapsSchedulers.main) - .subscribe({ binding.status.text = it.getStatus(resourceHelper) }, fabricPrivacy::logException) + .subscribe({ binding.status.text = it.getStatus(rh) }, fabricPrivacy::logException) disposable += rxBus .toObservable(EventDanaRSyncStatus::class.java) .observeOn(aapsSchedulers.main) @@ -96,19 +96,19 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() { // Types val typeList = ArrayList() - typeList.add(TypeList(RecordTypes.RECORD_TYPE_ALARM, resourceHelper.gs(R.string.danar_history_alarm))) - typeList.add(TypeList(RecordTypes.RECORD_TYPE_BASALHOUR, resourceHelper.gs(R.string.danar_history_basalhours))) - typeList.add(TypeList(RecordTypes.RECORD_TYPE_BOLUS, resourceHelper.gs(R.string.danar_history_bolus))) - typeList.add(TypeList(RecordTypes.RECORD_TYPE_CARBO, resourceHelper.gs(R.string.danar_history_carbohydrates))) - typeList.add(TypeList(RecordTypes.RECORD_TYPE_DAILY, resourceHelper.gs(R.string.danar_history_dailyinsulin))) - typeList.add(TypeList(RecordTypes.RECORD_TYPE_GLUCOSE, resourceHelper.gs(R.string.danar_history_glucose))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_ALARM, rh.gs(R.string.danar_history_alarm))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_BASALHOUR, rh.gs(R.string.danar_history_basalhours))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_BOLUS, rh.gs(R.string.danar_history_bolus))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_CARBO, rh.gs(R.string.danar_history_carbohydrates))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_DAILY, rh.gs(R.string.danar_history_dailyinsulin))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_GLUCOSE, rh.gs(R.string.danar_history_glucose))) if (!isKorean && !isRS) { - typeList.add(TypeList(RecordTypes.RECORD_TYPE_ERROR, resourceHelper.gs(R.string.danar_history_errors))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_ERROR, rh.gs(R.string.danar_history_errors))) } - if (isRS) typeList.add(TypeList(RecordTypes.RECORD_TYPE_PRIME, resourceHelper.gs(R.string.danar_history_prime))) + if (isRS) typeList.add(TypeList(RecordTypes.RECORD_TYPE_PRIME, rh.gs(R.string.danar_history_prime))) if (!isKorean) { - typeList.add(TypeList(RecordTypes.RECORD_TYPE_REFILL, resourceHelper.gs(R.string.danar_history_refill))) - typeList.add(TypeList(RecordTypes.RECORD_TYPE_SUSPEND, resourceHelper.gs(R.string.danar_history_syspend))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_REFILL, rh.gs(R.string.danar_history_refill))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_SUSPEND, rh.gs(R.string.danar_history_syspend))) } binding.spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, typeList) @@ -180,9 +180,9 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() { } RecordTypes.RECORD_TYPE_DAILY -> { - holder.binding.dailyBasal.text = resourceHelper.gs(R.string.formatinsulinunits, record.dailyBasal) - holder.binding.dailyBolus.text = resourceHelper.gs(R.string.formatinsulinunits, record.dailyBolus) - holder.binding.dailyTotal.text = resourceHelper.gs(R.string.formatinsulinunits, record.dailyBolus + record.dailyBasal) + holder.binding.dailyBasal.text = rh.gs(R.string.formatinsulinunits, record.dailyBasal) + holder.binding.dailyBolus.text = rh.gs(R.string.formatinsulinunits, record.dailyBolus) + holder.binding.dailyTotal.text = rh.gs(R.string.formatinsulinunits, record.dailyBolus + record.dailyBasal) holder.binding.time.text = dateUtil.dateString(record.timestamp) holder.binding.time.visibility = View.VISIBLE holder.binding.value.visibility = View.GONE diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt b/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt index 9993d991fe..44c567b23e 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt @@ -153,7 +153,7 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() { commandQueue.setUserOptions(object : Callback() { override fun run() { if (!result.success) { - ErrorHelperActivity.runAlarm(context, result.comment, resourceHelper.gs(R.string.pumperror), R.raw.boluserror) + ErrorHelperActivity.runAlarm(context, result.comment, rh.gs(R.string.pumperror), R.raw.boluserror) } } }) diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/activities/EnterPinActivity.kt b/danars/src/main/java/info/nightscout/androidaps/danars/activities/EnterPinActivity.kt index 115bc91523..7c6b791a8d 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/activities/EnterPinActivity.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/activities/EnterPinActivity.kt @@ -39,12 +39,12 @@ class EnterPinActivity : NoSplashAppCompatActivity() { setContentView(binding.root) val p1 = DefaultEditTextValidator(binding.rsV3Pin1, this) - .setTestErrorString(resourceHelper.gs(R.string.error_mustbe12hexadidits), this) - .setCustomRegexp(resourceHelper.gs(R.string.twelvehexanumber), this) + .setTestErrorString(rh.gs(R.string.error_mustbe12hexadidits), this) + .setCustomRegexp(rh.gs(R.string.twelvehexanumber), this) .setTestType(EditTextValidator.TEST_REGEXP, this) val p2 = DefaultEditTextValidator(binding.rsV3Pin2, this) - .setTestErrorString(resourceHelper.gs(R.string.error_mustbe8hexadidits), this) - .setCustomRegexp(resourceHelper.gs(R.string.eighthexanumber), this) + .setTestErrorString(rh.gs(R.string.error_mustbe8hexadidits), this) + .setCustomRegexp(rh.gs(R.string.eighthexanumber), this) .setTestType(EditTextValidator.TEST_REGEXP, this) binding.okcancel.ok.setOnClickListener { @@ -56,7 +56,7 @@ class EnterPinActivity : NoSplashAppCompatActivity() { if (result) { bleComm.finishV3Pairing() finish() - } else OKDialog.show(this, resourceHelper.gs(R.string.error), resourceHelper.gs(R.string.invalidinput)) + } else OKDialog.show(this, rh.gs(R.string.error), rh.gs(R.string.invalidinput)) } } binding.okcancel.cancel.setOnClickListener { finish() } @@ -86,12 +86,12 @@ class EnterPinActivity : NoSplashAppCompatActivity() { for (i in pairingKey.indices) pairingKeyCheckSum = pairingKeyCheckSum xor pairingKey[i] - sp.putString(resourceHelper.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName, Base64.encodeToString(pairingKey, Base64.DEFAULT)) + sp.putString(rh.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName, Base64.encodeToString(pairingKey, Base64.DEFAULT)) for (i in randomPairingKey.indices) pairingKeyCheckSum = pairingKeyCheckSum xor randomPairingKey[i] - sp.putString(resourceHelper.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName, Base64.encodeToString(randomPairingKey, Base64.DEFAULT)) + sp.putString(rh.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName, Base64.encodeToString(randomPairingKey, Base64.DEFAULT)) return checksum[0] == pairingKeyCheckSum } diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8HistoryActivity.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8HistoryActivity.kt index e11f5db161..a025c92ce0 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8HistoryActivity.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8HistoryActivity.kt @@ -63,7 +63,7 @@ class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() { disposable += rxBus .toObservable(EventPumpStatusChanged::class.java) .observeOn(aapsSchedulers.main) - .subscribe({ binding.status.text = it.getStatus(resourceHelper) }) { fabricPrivacy.logException(it) } + .subscribe({ binding.status.text = it.getStatus(rh) }) { fabricPrivacy.logException(it) } swapAdapter(showingType) } @@ -84,13 +84,13 @@ class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() { // Types val typeList = ArrayList() - typeList.add(TypeList(RecordTypes.RECORD_TYPE_ALARM, resourceHelper.gs(R.string.diaconn_g8_history_alarm))) - typeList.add(TypeList(RecordTypes.RECORD_TYPE_BASALHOUR, resourceHelper.gs(R.string.diaconn_g8_history_basalhours))) - typeList.add(TypeList(RecordTypes.RECORD_TYPE_BOLUS, resourceHelper.gs(R.string.diaconn_g8_history_bolus))) - typeList.add(TypeList(RecordTypes.RECORD_TYPE_TB, resourceHelper.gs(R.string.diaconn_g8_history_tempbasal))) - typeList.add(TypeList(RecordTypes.RECORD_TYPE_DAILY, resourceHelper.gs(R.string.diaconn_g8_history_dailyinsulin))) - typeList.add(TypeList(RecordTypes.RECORD_TYPE_REFILL, resourceHelper.gs(R.string.diaconn_g8_history_refill))) - typeList.add(TypeList(RecordTypes.RECORD_TYPE_SUSPEND, resourceHelper.gs(R.string.diaconn_g8_history_suspend))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_ALARM, rh.gs(R.string.diaconn_g8_history_alarm))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_BASALHOUR, rh.gs(R.string.diaconn_g8_history_basalhours))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_BOLUS, rh.gs(R.string.diaconn_g8_history_bolus))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_TB, rh.gs(R.string.diaconn_g8_history_tempbasal))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_DAILY, rh.gs(R.string.diaconn_g8_history_dailyinsulin))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_REFILL, rh.gs(R.string.diaconn_g8_history_refill))) + typeList.add(TypeList(RecordTypes.RECORD_TYPE_SUSPEND, rh.gs(R.string.diaconn_g8_history_suspend))) binding.spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, typeList) binding.reload.setOnClickListener { @@ -163,9 +163,9 @@ class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() { } RecordTypes.RECORD_TYPE_DAILY -> { - holder.dailyBasal.text = resourceHelper.gs(R.string.formatinsulinunits, record.dailyBasal) - holder.dailyBolus.text = resourceHelper.gs(R.string.formatinsulinunits, record.dailyBolus) - holder.dailyTotal.text = resourceHelper.gs(R.string.formatinsulinunits, record.dailyBolus + record.dailyBasal) + holder.dailyBasal.text = rh.gs(R.string.formatinsulinunits, record.dailyBasal) + holder.dailyBolus.text = rh.gs(R.string.formatinsulinunits, record.dailyBolus) + holder.dailyTotal.text = rh.gs(R.string.formatinsulinunits, record.dailyBolus + record.dailyBasal) holder.time.text = dateUtil.dateString(record.timestamp) holder.time.visibility = View.VISIBLE holder.value.visibility = View.GONE diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8UserOptionsActivity.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8UserOptionsActivity.kt index b8c6867a6c..83c09e5ae8 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8UserOptionsActivity.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8UserOptionsActivity.kt @@ -158,7 +158,7 @@ class DiaconnG8UserOptionsActivity : NoSplashAppCompatActivity() { val i = Intent(context, ErrorHelperActivity::class.java) i.putExtra("soundid", R.raw.boluserror) i.putExtra("status", result.comment) - i.putExtra("title", resourceHelper.gs(R.string.pumperror)) + i.putExtra("title", rh.gs(R.string.pumperror)) i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) context.startActivity(i) } @@ -169,9 +169,9 @@ class DiaconnG8UserOptionsActivity : NoSplashAppCompatActivity() { private fun fillSoundCategory() { val categories = ArrayList() - categories.add(resourceHelper.gs(R.string.diaconn_g8_pumpalarm_sound)) - categories.add(resourceHelper.gs(R.string.diaconn_g8_pumpalarm_vibrate)) - categories.add(resourceHelper.gs(R.string.diaconn_g8_pumpalarm_silent)) + categories.add(rh.gs(R.string.diaconn_g8_pumpalarm_sound)) + categories.add(rh.gs(R.string.diaconn_g8_pumpalarm_vibrate)) + categories.add(rh.gs(R.string.diaconn_g8_pumpalarm_silent)) context.let { context -> val adapterCategories = ArrayAdapter(context, R.layout.spinner_centered, categories) binding.beepAndAlarm.adapter = adapterCategories @@ -180,9 +180,9 @@ class DiaconnG8UserOptionsActivity : NoSplashAppCompatActivity() { private fun fillSoundSubCategory() { val categories = ArrayList() - categories.add(resourceHelper.gs(R.string.diaconn_g8_pumpalarm_intensity_low)) - categories.add(resourceHelper.gs(R.string.diaconn_g8_pumpalarm_intensity_middle)) - categories.add(resourceHelper.gs(R.string.diaconn_g8_pumpalarm_intensity_high)) + categories.add(rh.gs(R.string.diaconn_g8_pumpalarm_intensity_low)) + categories.add(rh.gs(R.string.diaconn_g8_pumpalarm_intensity_middle)) + categories.add(rh.gs(R.string.diaconn_g8_pumpalarm_intensity_high)) context.let { context -> val adapterCategories = ArrayAdapter(context, R.layout.spinner_centered, categories) binding.alarmIntesity.adapter = adapterCategories diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index d7c96235cd..18b0277238 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -153,7 +153,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { statusView?.run { visibility = View.GONE } historyTypeSpinner = findViewById(R.id.omnipod_historytype) - typeListFull = getTypeList(PumpHistoryEntryGroup.Companion.getTranslatedList(resourceHelper)) + typeListFull = getTypeList(PumpHistoryEntryGroup.Companion.getTranslatedList(rh)) val spinnerAdapter: ArrayAdapter = ArrayAdapter(this, R.layout.spinner_centered, typeListFull!!) historyTypeSpinner?.run { adapter = spinnerAdapter @@ -248,7 +248,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } private fun setType(record: HistoryRecord, typeView: TextView) { - typeView.text = resourceHelper.gs(record.commandType.resourceId) + typeView.text = rh.gs(record.commandType.resourceId) // Set some color, include result setTextViewColor(check_result = true, typeView, record) } @@ -257,21 +257,21 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { valueView.text = historyEntry.toString() // val entryType = historyEntry.commandType if (!historyEntry.isSuccess()) { - valueView.text = resourceHelper.gs(translatedFailure(historyEntry)) + valueView.text = rh.gs(translatedFailure(historyEntry)) return } valueView.text = when (historyEntry.commandType) { OmnipodCommandType.SET_TEMPORARY_BASAL -> { val tbr = historyEntry.record as TempBasalRecord tbr.let { - resourceHelper.gs(R.string.omnipod_common_history_tbr_value, it.rate, it.duration) + rh.gs(R.string.omnipod_common_history_tbr_value, it.rate, it.duration) } } OmnipodCommandType.SET_BOLUS -> { val bolus = historyEntry.record as BolusRecord bolus.let { - resourceHelper.gs(R.string.omnipod_common_history_bolus_value, it.amout) + rh.gs(R.string.omnipod_common_history_bolus_value, it.amout) } } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt index c2bb6240ea..8039afec57 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt @@ -66,7 +66,7 @@ class DashPodManagementActivity : NoSplashAppCompatActivity() { binding.buttonDiscardPod.setOnClickListener { OKDialog.showConfirmation( this, - resourceHelper.gs(R.string.omnipod_common_pod_management_discard_pod_confirmation), + rh.gs(R.string.omnipod_common_pod_management_discard_pod_confirmation), Thread { podStateManager.reset() } @@ -83,10 +83,10 @@ class DashPodManagementActivity : NoSplashAppCompatActivity() { override fun run() { if (!result.success) { displayErrorDialog( - resourceHelper.gs(R.string.omnipod_common_warning), - resourceHelper.gs( + rh.gs(R.string.omnipod_common_warning), + rh.gs( R.string.omnipod_common_two_strings_concatenated_by_colon, - resourceHelper.gs(R.string.omnipod_common_error_failed_to_play_test_beep), + rh.gs(R.string.omnipod_common_error_failed_to_play_test_beep), result.comment ), false diff --git a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/ui/ErosPodManagementActivity.kt b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/ui/ErosPodManagementActivity.kt index 06d42d307d..fcf2683239 100644 --- a/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/ui/ErosPodManagementActivity.kt +++ b/omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/ui/ErosPodManagementActivity.kt @@ -85,7 +85,7 @@ class ErosPodManagementActivity : NoSplashAppCompatActivity() { binding.buttonDiscardPod.setOnClickListener { OKDialog.showConfirmation(this, - resourceHelper.gs(R.string.omnipod_common_pod_management_discard_pod_confirmation), Thread { + rh.gs(R.string.omnipod_common_pod_management_discard_pod_confirmation), Thread { aapsOmnipodManager.discardPodState() }) } @@ -110,7 +110,7 @@ class ErosPodManagementActivity : NoSplashAppCompatActivity() { commandQueue.customCommand(CommandPlayTestBeep(), object : Callback() { override fun run() { if (!result.success) { - displayErrorDialog(resourceHelper.gs(R.string.omnipod_common_warning), resourceHelper.gs(R.string.omnipod_common_two_strings_concatenated_by_colon, resourceHelper.gs(R.string.omnipod_common_error_failed_to_play_test_beep), result.comment), false) + displayErrorDialog(rh.gs(R.string.omnipod_common_warning), rh.gs(R.string.omnipod_common_two_strings_concatenated_by_colon, rh.gs(R.string.omnipod_common_error_failed_to_play_test_beep), result.comment), false) } } }) @@ -123,7 +123,7 @@ class ErosPodManagementActivity : NoSplashAppCompatActivity() { commandQueue.customCommand(CommandReadPulseLog(), object : Callback() { override fun run() { if (!result.success) { - displayErrorDialog(resourceHelper.gs(R.string.omnipod_common_warning), resourceHelper.gs(R.string.omnipod_common_two_strings_concatenated_by_colon, resourceHelper.gs(R.string.omnipod_eros_error_failed_to_read_pulse_log), result.comment), false) + displayErrorDialog(rh.gs(R.string.omnipod_common_warning), rh.gs(R.string.omnipod_common_two_strings_concatenated_by_colon, rh.gs(R.string.omnipod_eros_error_failed_to_read_pulse_log), result.comment), false) } } }) @@ -229,8 +229,8 @@ class ErosPodManagementActivity : NoSplashAppCompatActivity() { private fun displayNotConfiguredDialog() { context.let { UIRunnable { - OKDialog.show(it, resourceHelper.gs(R.string.omnipod_common_warning), - resourceHelper.gs(R.string.omnipod_eros_error_operation_not_possible_no_configuration), null) + OKDialog.show(it, rh.gs(R.string.omnipod_common_warning), + rh.gs(R.string.omnipod_eros_error_operation_not_possible_no_configuration), null) }.run() } } From ca39802e6d4fb7e8e7006894c1d30221b3df8f77 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Nov 2021 10:39:13 +0100 Subject: [PATCH 21/29] fix profile validity check --- .../androidaps/plugins/profile/local/LocalProfilePlugin.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index 34aba93fea..81be4f50b2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -126,7 +126,7 @@ class LocalProfilePlugin @Inject constructor( } val low = blockFromJsonArray(targetLow, dateUtil) val high = blockFromJsonArray(targetHigh, dateUtil) - if (profileFunction.getUnits() == GlucoseUnit.MGDL) { + if (mgdl) { if (blockFromJsonArray(isf, dateUtil)?.any { it.amount < HardLimits.MIN_ISF || it.amount > HardLimits.MAX_ISF } != false) { ToastUtils.errorToast(activity,resourceHelper.gs(R.string.error_in_isf_values)) return false @@ -144,7 +144,8 @@ class LocalProfilePlugin @Inject constructor( return false } } else { - if (blockFromJsonArray(isf, dateUtil)?.any { it.amount < Profile.fromMgdlToUnits(HardLimits.MIN_ISF, GlucoseUnit.MMOL) || it.amount > Profile.fromMgdlToUnits(HardLimits.MAX_ISF, GlucoseUnit.MMOL) } != false) { + if (blockFromJsonArray(isf, dateUtil)?.any { it.amount < Profile.toMgdl(HardLimits.MIN_ISF, GlucoseUnit.MMOL) || it.amount > Profile.toMgdl(HardLimits.MAX_ISF, GlucoseUnit.MMOL) + } != false) { ToastUtils.errorToast(activity,resourceHelper.gs(R.string.error_in_isf_values)) return false } From b4dec7195c028a987974eaf3a8e3ca0acc37929b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Nov 2021 12:45:34 +0100 Subject: [PATCH 22/29] more profile tweaking --- .../plugins/profile/local/LocalProfilePlugin.kt | 15 +++++---------- .../nightscout/androidaps/data/ProfileSealed.kt | 1 + .../androidaps/interfaces/ProfileStore.kt | 4 ++-- .../nightscout/androidaps/utils/ToastUtils.java | 11 +++++++---- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index 81be4f50b2..6e6ff3550e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -23,11 +23,7 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationWithAction import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged import info.nightscout.androidaps.receivers.DataWorker -import info.nightscout.androidaps.utils.DateUtil -import info.nightscout.androidaps.utils.DecimalFormatter -import info.nightscout.androidaps.utils.HardLimits -import info.nightscout.androidaps.utils.JsonHelper -import info.nightscout.androidaps.utils.ToastUtils +import info.nightscout.androidaps.utils.* import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP @@ -127,8 +123,8 @@ class LocalProfilePlugin @Inject constructor( val low = blockFromJsonArray(targetLow, dateUtil) val high = blockFromJsonArray(targetHigh, dateUtil) if (mgdl) { - if (blockFromJsonArray(isf, dateUtil)?.any { it.amount < HardLimits.MIN_ISF || it.amount > HardLimits.MAX_ISF } != false) { - ToastUtils.errorToast(activity,resourceHelper.gs(R.string.error_in_isf_values)) + if (blockFromJsonArray(isf, dateUtil)?.any { hardLimits.isInRange(it.amount, HardLimits.MIN_ISF, HardLimits.MAX_ISF) } == false) { + ToastUtils.errorToast(activity, resourceHelper.gs(R.string.error_in_isf_values)) return false } if (blockFromJsonArray(basal, dateUtil)?.any { it.amount < pumpDescription.basalMinimumRate || it.amount > 10.0 } != false) { @@ -144,8 +140,7 @@ class LocalProfilePlugin @Inject constructor( return false } } else { - if (blockFromJsonArray(isf, dateUtil)?.any { it.amount < Profile.toMgdl(HardLimits.MIN_ISF, GlucoseUnit.MMOL) || it.amount > Profile.toMgdl(HardLimits.MAX_ISF, GlucoseUnit.MMOL) - } != false) { + if (blockFromJsonArray(isf, dateUtil)?.any { hardLimits.isInRange(Profile.toMgdl(it.amount, GlucoseUnit.MMOL), HardLimits.MIN_ISF, HardLimits.MAX_ISF) } == false) { ToastUtils.errorToast(activity,resourceHelper.gs(R.string.error_in_isf_values)) return false } @@ -482,7 +477,7 @@ class LocalProfilePlugin @Inject constructor( ?: return Result.failure(workDataOf("Error" to "missing input data")) if (sp.getBoolean(R.string.key_ns_receive_profile_store, true) || config.NSCLIENT) { val store = ProfileStore(injector, profileJson, dateUtil) - val createdAt = store.getCreatedAt() + val createdAt = store.getStartDate() val lastLocalChange = sp.getLong(R.string.key_local_profile_last_change, 0) aapsLogger.debug(LTag.PROFILE, "Received profileStore: createdAt: $createdAt Local last modification: $lastLocalChange") @Suppress("LiftReturnOrAssignment") 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 58e00a684c..75c09a5e4f 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt +++ b/core/src/main/java/info/nightscout/androidaps/data/ProfileSealed.kt @@ -212,6 +212,7 @@ sealed class ProfileSealed( if (getTargetLowMgdlTimeFromMidnight(seconds) != profile.getTargetLowMgdlTimeFromMidnight(seconds)) return false if (getTargetHighMgdlTimeFromMidnight(seconds) != profile.getTargetHighMgdlTimeFromMidnight(seconds)) return false if (dia != profile.dia) return false + if ((profile is EPS) && profileName != profile.value.originalProfileName) return false // handle profile name change too } return true } diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileStore.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileStore.kt index 49ad281742..bc821120d6 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileStore.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/ProfileStore.kt @@ -31,8 +31,8 @@ class ProfileStore(val injector: HasAndroidInjector, val data: JSONObject, val d return null } - fun getCreatedAt(): Long { - val iso = JsonHelper.safeGetString(data, "created_at") ?: return 0 + fun getStartDate(): Long { + val iso = JsonHelper.safeGetString(data, "startDate") ?: return 0 return try { dateUtil.fromISODateString(iso) } catch (e: Exception) { diff --git a/core/src/main/java/info/nightscout/androidaps/utils/ToastUtils.java b/core/src/main/java/info/nightscout/androidaps/utils/ToastUtils.java index 5718b80fd3..994998ef90 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/ToastUtils.java +++ b/core/src/main/java/info/nightscout/androidaps/utils/ToastUtils.java @@ -22,6 +22,8 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific public class ToastUtils { + private static Toast lastToast = null; + public static class Long { public static void warnToast(final Context ctx, final String string) { @@ -76,10 +78,11 @@ public class ToastUtils { ImageView toastIcon = toastRoot.findViewById(android.R.id.icon); toastIcon.setImageResource(iconId); - Toast toast = new Toast(ctx); - toast.setDuration(isShort ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG); - toast.setView(toastRoot); - toast.show(); + if (lastToast != null) lastToast.cancel(); + lastToast = new Toast(ctx); + lastToast.setDuration(isShort ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG); + lastToast.setView(toastRoot); + lastToast.show(); }); } From ff1a9b24dbd3a36361171aa85ff8eed54f8cb003 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Nov 2021 13:14:01 +0100 Subject: [PATCH 23/29] Do not use bus for dismissing notification from UI --- .../general/overview/notifications/NotificationStore.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt index 152d9c5b2a..ab30036da3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationStore.kt @@ -14,6 +14,7 @@ import androidx.core.app.NotificationCompat import androidx.recyclerview.widget.RecyclerView import info.nightscout.androidaps.R import info.nightscout.androidaps.databinding.OverviewNotificationItemBinding +import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.interfaces.IconsProvider import info.nightscout.androidaps.interfaces.NotificationHolder import info.nightscout.androidaps.logging.AAPSLogger @@ -150,7 +151,8 @@ class NotificationStore @Inject constructor( } } - inner class NotificationRecyclerViewAdapter internal constructor(private val notificationsList: List) : RecyclerView.Adapter() { + inner class NotificationRecyclerViewAdapter internal constructor(private val notificationsList: List) : + RecyclerView.Adapter() { override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): NotificationsViewHolder = NotificationsViewHolder(LayoutInflater.from(viewGroup.context).inflate(R.layout.overview_notification_item, viewGroup, false)) @@ -182,9 +184,9 @@ class NotificationStore @Inject constructor( init { binding.dismiss.setOnClickListener { val notification = it.tag as Notification - rxBus.send(EventDismissNotification(notification.id)) notification.contextForAction = itemView.context notification.action?.run() + if (remove(notification.id)) rxBus.send(EventRefreshOverview("NotificationCleared")) } } } From 2582240556b75f887e820f4f319bed2c99a847b2 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Nov 2021 13:33:51 +0100 Subject: [PATCH 24/29] fix TDD layout --- core/src/main/res/layout/activity_tdd_stats.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/res/layout/activity_tdd_stats.xml b/core/src/main/res/layout/activity_tdd_stats.xml index f7967bfebf..772859ccd2 100644 --- a/core/src/main/res/layout/activity_tdd_stats.xml +++ b/core/src/main/res/layout/activity_tdd_stats.xml @@ -167,7 +167,7 @@ Date: Tue, 2 Nov 2021 13:38:03 +0100 Subject: [PATCH 25/29] typo --- .../nightscout/androidaps/danars/comm/DanaRSPacketHistory.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistory.kt b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistory.kt index 64eee73f34..e613f7df8c 100644 --- a/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistory.kt +++ b/danars/src/main/java/info/nightscout/androidaps/danars/comm/DanaRSPacketHistory.kt @@ -77,7 +77,7 @@ abstract class DanaRSPacketHistory( dataIndex += dataSize dataSize = 2 totalCount = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - aapsLogger.debug(LTag.PUMPCOMM, "History end. Code: " + error + " Success: " + (error == 0x00) + " Toatal count: " + totalCount) + aapsLogger.debug(LTag.PUMPCOMM, "History end. Code: " + error + " Success: " + (error == 0x00) + " Total count: " + totalCount) } else { val recordCode = byteArrayToInt(getBytes(data, DATA_START, 1)) val historyYear = byteArrayToInt(getBytes(data, DATA_START + 1, 1)) From bc14496cbd8dc3ea0478820c40c3498bcaa80a62 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Nov 2021 13:41:55 +0100 Subject: [PATCH 26/29] do not show notification for old TDD data --- .../androidaps/plugins/pump/PumpSyncImplementation.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt b/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt index 1a92af8ae6..4858bb1c43 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt @@ -51,7 +51,7 @@ class PumpSyncImplementation @Inject constructor( * @param serialNumber serial number of of pump * @return true if data is allowed */ - private fun confirmActivePump(timestamp: Long, type: PumpType, serialNumber: String): Boolean { + private fun confirmActivePump(timestamp: Long, type: PumpType, serialNumber: String, showNotification: Boolean = true): Boolean { val storedType = sp.getString(R.string.key_active_pump_type, "") val storedSerial = sp.getString(R.string.key_active_pump_serial_number, "") val storedTimestamp = sp.getLong(R.string.key_active_pump_change_timestamp, 0L) @@ -70,7 +70,7 @@ class PumpSyncImplementation @Inject constructor( return true } - if ((type.description != storedType || serialNumber != storedSerial) && timestamp >= storedTimestamp) + if (showNotification && (type.description != storedType || serialNumber != storedSerial) && timestamp >= storedTimestamp) rxBus.send(EventNewNotification(Notification(Notification.WRONG_PUMP_DATA, resourceHelper.gs(R.string.wrong_pump_data), Notification.URGENT))) aapsLogger.error(LTag.PUMP, "Ignoring pump history record Allowed: ${dateUtil.dateAndTimeAndSecondsString(storedTimestamp)} $storedType $storedSerial Received: $timestamp ${dateUtil.dateAndTimeAndSecondsString(timestamp)} ${type.description} $serialNumber") return false @@ -397,7 +397,8 @@ class PumpSyncImplementation @Inject constructor( } override fun createOrUpdateTotalDailyDose(timestamp: Long, bolusAmount: Double, basalAmount: Double, totalAmount: Double, pumpId: Long?, pumpType: PumpType, pumpSerial: String): Boolean { - if (!confirmActivePump(timestamp, pumpType, pumpSerial)) return false + // there are probably old data in pump -> do not show notification, just ignore + if (!confirmActivePump(timestamp, pumpType, pumpSerial, showNotification = false)) return false val tdd = TotalDailyDose( timestamp = timestamp, bolusAmount = bolusAmount, From 2ad7d9f4d236ca6adb76b6afa9e51ecd3a354bb4 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Nov 2021 14:36:09 +0100 Subject: [PATCH 27/29] pre-sort data for rendering --- .../androidaps/plugins/general/overview/OverviewData.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt index 2cdd860ce3..c9d2496aee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt @@ -326,6 +326,7 @@ class OverviewData @Inject constructor( if (bg.value > maxBgValue) maxBgValue = bg.value bgListArray.add(GlucoseValueDataPoint(bg, defaultValueHelper, profileFunction, resourceHelper)) } + bgListArray.sortWith { o1: DataPointWithLabelInterface, o2: DataPointWithLabelInterface -> o1.x.compareTo(o2.x) } bgReadingGraphSeries = PointsWithLabelGraphSeries(Array(bgListArray.size) { i -> bgListArray[i] }) maxBgValue = Profile.fromMgdlToUnits(maxBgValue, profileFunction.getUnits()) if (defaultValueHelper.determineHighLine() > maxBgValue) maxBgValue = defaultValueHelper.determineHighLine() @@ -388,6 +389,7 @@ class OverviewData @Inject constructor( if (inMemoryGlucoseValue.timestamp < fromTime || inMemoryGlucoseValue.timestamp > toTime) continue bucketedListArray.add(InMemoryGlucoseValueDataPoint(inMemoryGlucoseValue, profileFunction, resourceHelper)) } + bucketedListArray.sortWith { o1: DataPointWithLabelInterface, o2: DataPointWithLabelInterface -> o1.x.compareTo(o2.x) } bucketedGraphSeries = PointsWithLabelGraphSeries(Array(bucketedListArray.size) { i -> bucketedListArray[i] }) // profiler.log(LTag.UI, "prepareBucketedData() $from", start) } From e715167254a63c00f6577e8af3a83409e7778b4b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Nov 2021 15:11:08 +0100 Subject: [PATCH 28/29] hack for PL language --- .../plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index c551f166ef..0d31e86afd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -1132,6 +1132,7 @@ class SmsCommunicatorPlugin @Inject constructor( var s = str s = Normalizer.normalize(s, Normalizer.Form.NFD) s = s.replace("[\\p{InCombiningDiacriticalMarks}]".toRegex(), "") + s = s.replace("ł", "l") // hack for Polish language (bug in libs) return s } From aea868ac6e24dfa5ee024e17f8d1bb37430c5d30 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Nov 2021 15:43:53 +0100 Subject: [PATCH 29/29] 2.8.2.9-dev --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index da23b2ff7f..faab50b550 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,7 +109,7 @@ android { defaultConfig { multiDexEnabled true versionCode 1500 - version "2.8.2.8-dev" + version "2.8.2.9-dev" buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'