This commit is contained in:
Theo van Elsberg 2021-10-30 01:14:17 +02:00
parent b645185005
commit d966254815

View file

@ -56,47 +56,48 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
private fun groupForCommandType(type: OmnipodCommandType): PumpHistoryEntryGroup { private fun groupForCommandType(type: OmnipodCommandType): PumpHistoryEntryGroup {
return when (type) { return when (type) {
OmnipodCommandType.INITIALIZE_POD -> OmnipodCommandType.INITIALIZE_POD ->
PumpHistoryEntryGroup.Prime PumpHistoryEntryGroup.Prime
OmnipodCommandType.INSERT_CANNULA -> OmnipodCommandType.INSERT_CANNULA ->
PumpHistoryEntryGroup.Prime PumpHistoryEntryGroup.Prime
OmnipodCommandType.DEACTIVATE_POD -> OmnipodCommandType.DEACTIVATE_POD ->
PumpHistoryEntryGroup.Prime PumpHistoryEntryGroup.Prime
OmnipodCommandType.DISCARD_POD -> OmnipodCommandType.DISCARD_POD ->
PumpHistoryEntryGroup.Prime PumpHistoryEntryGroup.Prime
OmnipodCommandType.CANCEL_TEMPORARY_BASAL -> OmnipodCommandType.CANCEL_TEMPORARY_BASAL ->
PumpHistoryEntryGroup.Basal PumpHistoryEntryGroup.Basal
OmnipodCommandType.SET_BASAL_PROFILE -> OmnipodCommandType.SET_BASAL_PROFILE ->
PumpHistoryEntryGroup.Basal PumpHistoryEntryGroup.Basal
OmnipodCommandType.SET_TEMPORARY_BASAL -> OmnipodCommandType.SET_TEMPORARY_BASAL ->
PumpHistoryEntryGroup.Basal PumpHistoryEntryGroup.Basal
OmnipodCommandType.RESUME_DELIVERY -> OmnipodCommandType.RESUME_DELIVERY ->
PumpHistoryEntryGroup.Basal PumpHistoryEntryGroup.Basal
OmnipodCommandType.SUSPEND_DELIVERY -> OmnipodCommandType.SUSPEND_DELIVERY ->
PumpHistoryEntryGroup.Basal PumpHistoryEntryGroup.Basal
OmnipodCommandType.SET_BOLUS -> OmnipodCommandType.SET_BOLUS ->
PumpHistoryEntryGroup.Bolus PumpHistoryEntryGroup.Bolus
OmnipodCommandType.CANCEL_BOLUS -> OmnipodCommandType.CANCEL_BOLUS ->
PumpHistoryEntryGroup.Bolus PumpHistoryEntryGroup.Bolus
OmnipodCommandType.ACKNOWLEDGE_ALERTS -> OmnipodCommandType.ACKNOWLEDGE_ALERTS ->
PumpHistoryEntryGroup.Alarm PumpHistoryEntryGroup.Alarm
OmnipodCommandType.CONFIGURE_ALERTS -> OmnipodCommandType.CONFIGURE_ALERTS ->
PumpHistoryEntryGroup.Alarm PumpHistoryEntryGroup.Alarm
OmnipodCommandType.PLAY_TEST_BEEP -> OmnipodCommandType.PLAY_TEST_BEEP ->
PumpHistoryEntryGroup.Alarm PumpHistoryEntryGroup.Alarm
OmnipodCommandType.GET_POD_STATUS -> OmnipodCommandType.GET_POD_STATUS ->
PumpHistoryEntryGroup.Configuration PumpHistoryEntryGroup.Configuration
OmnipodCommandType.SET_TIME -> OmnipodCommandType.SET_TIME ->
PumpHistoryEntryGroup.Configuration PumpHistoryEntryGroup.Configuration
OmnipodCommandType.READ_POD_PULSE_LOG -> OmnipodCommandType.READ_POD_PULSE_LOG ->
PumpHistoryEntryGroup.Unknown PumpHistoryEntryGroup.Unknown
} }
} }
private fun filterHistory(group: PumpHistoryEntryGroup) { private fun filterHistory(group: PumpHistoryEntryGroup) {
filteredHistoryList.clear() filteredHistoryList.clear()
aapsLogger.debug(LTag.PUMP, "Items on full list: {}", fullHistoryList.size) aapsLogger.debug(LTag.PUMP, "Items on full list: {}", fullHistoryList.size)
@ -227,7 +228,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
OmnipodCommandType.DISCARD_POD, OmnipodCommandType.DISCARD_POD,
OmnipodCommandType.SUSPEND_DELIVERY, OmnipodCommandType.SUSPEND_DELIVERY,
OmnipodCommandType.RESUME_DELIVERY, OmnipodCommandType.RESUME_DELIVERY,
OmnipodCommandType.SET_BASAL_PROFILE -> { OmnipodCommandType.SET_BASAL_PROFILE -> {
android.graphics.Color.CYAN android.graphics.Color.CYAN
} }
// User action // User action
@ -241,6 +242,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
OmnipodCommandType.SET_TEMPORARY_BASAL -> { OmnipodCommandType.SET_TEMPORARY_BASAL -> {
android.graphics.Color.WHITE android.graphics.Color.WHITE
} }
else -> else ->
// Other // Other
android.graphics.Color.LTGRAY android.graphics.Color.LTGRAY
@ -251,7 +253,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
private fun setType(record: HistoryRecord, typeView: TextView) { private fun setType(record: HistoryRecord, typeView: TextView) {
typeView.text = resourceHelper.gs(record.commandType.resourceId) typeView.text = resourceHelper.gs(record.commandType.resourceId)
// Set some color, include result // Set some color, include result
setTextViewColor(check_result=true, typeView, record) setTextViewColor(check_result = true, typeView, record)
} }
private fun setValue(historyEntry: HistoryRecord, valueView: TextView) { 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) resourceHelper.gs(R.string.omnipod_common_history_tbr_value, it.rate, it.duration)
} ?: "n/a" } ?: "n/a"
} }
OmnipodCommandType.SET_BOLUS -> {
OmnipodCommandType.SET_BOLUS -> {
val bolus = historyEntry.record as BolusRecord val bolus = historyEntry.record as BolusRecord
bolus?.let { bolus?.let {
resourceHelper.gs(R.string.omnipod_common_history_bolus_value, it.amout) resourceHelper.gs(R.string.omnipod_common_history_bolus_value, it.amout)
} ?: "n/a" } ?: "n/a"
} }
OmnipodCommandType.SET_BASAL_PROFILE, OmnipodCommandType.SET_BASAL_PROFILE,
OmnipodCommandType.SET_TIME, OmnipodCommandType.SET_TIME,
OmnipodCommandType.INSERT_CANNULA, OmnipodCommandType.INSERT_CANNULA,
OmnipodCommandType.RESUME_DELIVERY -> { OmnipodCommandType.RESUME_DELIVERY -> {
val basal = historyEntry.record as BasalValuesRecord val basal = historyEntry.record as BasalValuesRecord
ProfileUtil.getBasalProfilesDisplayable(basal.segments.toTypedArray(), PumpType.OMNIPOD_DASH) ProfileUtil.getBasalProfilesDisplayable(basal.segments.toTypedArray(), PumpType.OMNIPOD_DASH)
} }
else ->
else ->
"" ""
} }
// Set some color // Set some color
setTextViewColor(check_result=false, valueView, historyEntry) setTextViewColor(check_result = false, valueView, historyEntry)
} }
override fun getItemCount(): Int { override fun getItemCount(): Int {
@ -293,6 +298,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
} }
inner class HistoryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { inner class HistoryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val timeView: TextView = itemView.findViewById(R.id.omnipod_history_time) val timeView: TextView = itemView.findViewById(R.id.omnipod_history_time)
val typeView: TextView = itemView.findViewById(R.id.omnipod_history_source) val typeView: TextView = itemView.findViewById(R.id.omnipod_history_source)
val valueView: TextView = itemView.findViewById(R.id.omnipod_history_description) val valueView: TextView = itemView.findViewById(R.id.omnipod_history_description)
@ -303,17 +309,18 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() {
return when { return when {
historyEntry.initialResult == InitialResult.FAILURE_SENDING -> historyEntry.initialResult == InitialResult.FAILURE_SENDING ->
R.string.omnipod_dash_failed_to_send R.string.omnipod_dash_failed_to_send
historyEntry.initialResult == InitialResult.NOT_SENT -> historyEntry.initialResult == InitialResult.NOT_SENT ->
R.string.omnipod_dash_command_not_sent R.string.omnipod_dash_command_not_sent
historyEntry.initialResult == InitialResult.SENT && historyEntry.initialResult == InitialResult.SENT &&
historyEntry.resolvedResult == ResolvedResult.FAILURE -> historyEntry.resolvedResult == ResolvedResult.FAILURE ->
R.string.omnipod_dash_command_not_received_by_the_pod R.string.omnipod_dash_command_not_received_by_the_pod
else -> else ->
R.string.omnipod_dash_unknown R.string.omnipod_dash_unknown
} }
} }
companion object { companion object {
private var selectedGroup: PumpHistoryEntryGroup = PumpHistoryEntryGroup.All private var selectedGroup: PumpHistoryEntryGroup = PumpHistoryEntryGroup.All
const val DAYS_TO_DISPLAY = 5 const val DAYS_TO_DISPLAY = 5
} }