diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt index d07225a77e..16d1029843 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt @@ -128,7 +128,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() { override fun onBindViewHolder(holder: UserEntryViewHolder, position: Int) { val current = entries[position] holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) - + holder.binding.action.text = userEntryPresentationHelper.actionToColoredString(current.action) if (current.s != "") { holder.binding.s.text = current.s holder.binding.s.visibility = View.VISIBLE @@ -170,8 +170,6 @@ class TreatmentsUserEntryFragment : DaggerFragment() { holder.binding.iconSource.visibility = View.VISIBLE holder.binding.values.text = valuesWithUnitString.trim() holder.binding.values.visibility = if (holder.binding.values.text != "") View.VISIBLE else View.GONE - holder.binding.action.text = translator.translate(current.action) - holder.binding.action.setTextColor(resourceHelper.gc(userEntryPresentationHelper.colorId(current.action.colorGroup))) } inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { diff --git a/core/src/main/java/info/nightscout/androidaps/utils/UserEntryPresentationHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/UserEntryPresentationHelper.kt index 18e23695b2..2b4ac94401 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/UserEntryPresentationHelper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/UserEntryPresentationHelper.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.utils +import android.text.Spanned import dagger.Reusable import info.nightscout.androidaps.Constants import info.nightscout.androidaps.core.R @@ -64,6 +65,13 @@ class UserEntryPresentationHelper @Inject constructor( Sources.Unknown -> R.drawable.ic_generic_icon } + fun actionToColoredString(action: Action): Spanned = when (action) { + Action.TREATMENT -> HtmlHelper.fromHtml(coloredAction(Action.BOLUS) + " + " + coloredAction(Action.CARBS)) + else -> HtmlHelper.fromHtml(coloredAction(action)) + } + + private fun coloredAction(action: Action): String = "${translator.translate(action)}" + fun listToPresentationString(list: List) = list.joinToString(separator = " ", transform = this::toPresentationString)