diff --git a/app/src/main/java/it/danieleverducci/lunatracker/adapters/LunaEventRecyclerAdapter.kt b/app/src/main/java/it/danieleverducci/lunatracker/adapters/LunaEventRecyclerAdapter.kt index a69bcf8..23ab1ba 100644 --- a/app/src/main/java/it/danieleverducci/lunatracker/adapters/LunaEventRecyclerAdapter.kt +++ b/app/src/main/java/it/danieleverducci/lunatracker/adapters/LunaEventRecyclerAdapter.kt @@ -1,6 +1,8 @@ package it.danieleverducci.lunatracker.adapters import android.content.Context +import android.icu.util.LocaleData +import android.icu.util.ULocale import android.text.format.DateFormat import android.view.LayoutInflater import android.view.View @@ -10,13 +12,36 @@ import androidx.recyclerview.widget.RecyclerView import it.danieleverducci.lunatracker.entities.LunaEvent import it.danieleverducci.lunatracker.R import java.util.Date +import java.util.Locale class LunaEventRecyclerAdapter: RecyclerView.Adapter { private val context: Context val items = ArrayList() + val measurement_unit_liquid_base: String + val measurement_unit_weight_base: String + val measurement_unit_weight_tiny: String constructor(context: Context) { this.context = context + val measurementSystem = LocaleData.getMeasurementSystem(ULocale.getDefault()) + this.measurement_unit_liquid_base = context.getString( + if (measurementSystem == LocaleData. MeasurementSystem.SI) + R.string.measurement_unit_liquid_base_metric + else + R.string.measurement_unit_liquid_base_imperial + ) + this.measurement_unit_weight_base = context.getString( + if (measurementSystem == LocaleData. MeasurementSystem.SI) + R.string.measurement_unit_weight_base_metric + else + R.string.measurement_unit_weight_base_imperial + ) + this.measurement_unit_weight_tiny = context.getString( + if (measurementSystem == LocaleData. MeasurementSystem.SI) + R.string.measurement_unit_weight_tiny_metric + else + R.string.measurement_unit_weight_tiny_imperial + ) } override fun onCreateViewHolder( @@ -35,8 +60,18 @@ class LunaEventRecyclerAdapter: RecyclerView.Adapter 0) item.quantity.toString() else "" holder.time.text = formatTimeAgo(context, item.time) + val qtyText = if ((item.quantity ?: 0) > 0) { + item.quantity.toString() + " " + when (item.type) { + LunaEvent.TYPE_BABY_BOTTLE -> measurement_unit_liquid_base + LunaEvent.TYPE_WEIGHT -> measurement_unit_weight_base + LunaEvent.TYPE_MEDICINE -> measurement_unit_weight_tiny + else -> "" + } + } else { + "" + } + holder.quantity.text = qtyText } override fun getItemCount(): Int { @@ -68,9 +103,9 @@ class LunaEventRecyclerAdapter: RecyclerView.Adapter 0) { + if (formattedTime.isNotEmpty()) + formattedTime.append(", ") formattedTime.append(minutesAgo).append(" ") if (minutesAgo.toInt() == 1) formattedTime.append(context.getString(R.string.minute_ago)) diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 96015b7..809bc8d 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -10,17 +10,6 @@ Pesata Inserisci il peso rilevato - 🍼 - βš–οΈ - 🀱 ← - 🀱 ↔ - 🀱 β†’ - 🚼 πŸ’© - 🚼 πŸ’§ - πŸ’Š - πŸͺ  - - - πŸ’Š Medicina πŸͺ  Clistere βž• Aggiungi evento personalizzato diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8e320bf..d5a6af0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -10,16 +10,16 @@ Weight Insert the weight - 🍼 - βš–οΈ - 🀱 ← - 🀱 ↔ - 🀱 β†’ - 🚼 πŸ’© - 🚼 πŸ’§ - πŸ’Š - πŸͺ  - \? + 🍼 + βš–οΈ + 🀱 ← + 🀱 ↔ + 🀱 β†’ + 🚼 πŸ’© + 🚼 πŸ’§ + πŸ’Š + πŸͺ  + \? Baby bottle Weight @@ -80,4 +80,11 @@ Medicine name, quantity, type, notes…: Integer quantity, or leave blank + ml + g + mg + fl oz. + oz + gr + \ No newline at end of file