diff --git a/entities/src/main/java/org/odk/collect/entities/browser/EntityItemView.kt b/entities/src/main/java/org/odk/collect/entities/browser/EntityItemView.kt index 88e60c2d0da..12eb2a77188 100644 --- a/entities/src/main/java/org/odk/collect/entities/browser/EntityItemView.kt +++ b/entities/src/main/java/org/odk/collect/entities/browser/EntityItemView.kt @@ -1,5 +1,6 @@ package org.odk.collect.entities.browser +import android.annotation.SuppressLint import android.content.Context import android.view.LayoutInflater import android.widget.FrameLayout @@ -11,8 +12,10 @@ class EntityItemView(context: Context) : FrameLayout(context) { val binding = EntityItemLayoutBinding.inflate(LayoutInflater.from(context), this, true) + @SuppressLint("SetTextI18n") fun setEntity(entity: Entity.Saved) { binding.label.text = entity.label + binding.id.text = "${entity.id} (${entity.version})" binding.properties.text = entity.properties .sortedBy { it.first } .joinToString(separator = "\n") { "${it.first}: ${it.second}" } diff --git a/entities/src/main/res/layout/entity_item_layout.xml b/entities/src/main/res/layout/entity_item_layout.xml index c862bb186b7..2743cd8ed74 100644 --- a/entities/src/main/res/layout/entity_item_layout.xml +++ b/entities/src/main/res/layout/entity_item_layout.xml @@ -34,6 +34,17 @@ app:layout_constraintTop_toBottomOf="@id/offline_pill" tools:text="Label" /> + + diff --git a/entities/src/test/java/org/odk/collect/entities/browser/EntityItemViewTest.kt b/entities/src/test/java/org/odk/collect/entities/browser/EntityItemViewTest.kt index 9a1fc045879..23bce3f603a 100644 --- a/entities/src/test/java/org/odk/collect/entities/browser/EntityItemViewTest.kt +++ b/entities/src/test/java/org/odk/collect/entities/browser/EntityItemViewTest.kt @@ -44,4 +44,13 @@ class EntityItemViewTest { view.setEntity(entity.copy(state = Entity.State.ONLINE)) assertThat(view.binding.offlinePill.isVisible, equalTo(false)) } + + @Test + fun `shows id and version`() { + val view = EntityItemView(context) + val entity = Entity.Saved("songs", "1", "S.D.O.S", version = 11, index = 0) + + view.setEntity(entity.copy(state = Entity.State.OFFLINE)) + assertThat(view.binding.id.text, equalTo("${entity.id} (${entity.version})")) + } }