diff --git a/entities/src/main/java/org/odk/collect/entities/EntitiesFragment.kt b/entities/src/main/java/org/odk/collect/entities/EntitiesFragment.kt
index 700005730d3..f0daa09f365 100644
--- a/entities/src/main/java/org/odk/collect/entities/EntitiesFragment.kt
+++ b/entities/src/main/java/org/odk/collect/entities/EntitiesFragment.kt
@@ -12,6 +12,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import org.odk.collect.entities.databinding.ListLayoutBinding
+import org.odk.collect.lists.RecyclerViewUtils
import org.odk.collect.lists.RecyclerViewUtils.matchParentWidth
class EntitiesFragment(private val viewModelFactory: ViewModelProvider.Factory) : Fragment() {
@@ -29,6 +30,7 @@ class EntitiesFragment(private val viewModelFactory: ViewModelProvider.Factory)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val binding = ListLayoutBinding.bind(view)
binding.list.layoutManager = LinearLayoutManager(requireContext())
+ binding.list.addItemDecoration(RecyclerViewUtils.verticalLineDivider(requireContext()))
val list = EntitiesFragmentArgs.fromBundle(requireArguments()).list
entitiesViewModel.getEntities(list).observe(viewLifecycleOwner) {
diff --git a/entities/src/main/java/org/odk/collect/entities/EntityItemView.kt b/entities/src/main/java/org/odk/collect/entities/EntityItemView.kt
index 81eb6be2965..3c349347fac 100644
--- a/entities/src/main/java/org/odk/collect/entities/EntityItemView.kt
+++ b/entities/src/main/java/org/odk/collect/entities/EntityItemView.kt
@@ -14,7 +14,7 @@ class EntityItemView(context: Context) : FrameLayout(context) {
binding.label.text = entity.label
binding.properties.text = entity.properties
.sortedBy { it.first }
- .joinToString(separator = ", ") { "${it.first}: ${it.second}" }
+ .joinToString(separator = "\n") { "${it.first}: ${it.second}" }
binding.offlinePill.isVisible = entity.state == Entity.State.OFFLINE
}
}
diff --git a/entities/src/main/java/org/odk/collect/entities/EntityListsFragment.kt b/entities/src/main/java/org/odk/collect/entities/EntityListsFragment.kt
index 0b7e88330b6..6e1470fe508 100644
--- a/entities/src/main/java/org/odk/collect/entities/EntityListsFragment.kt
+++ b/entities/src/main/java/org/odk/collect/entities/EntityListsFragment.kt
@@ -22,6 +22,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.odk.collect.entities.databinding.AddEntitiesDialogLayoutBinding
import org.odk.collect.entities.databinding.EntityListItemLayoutBinding
import org.odk.collect.entities.databinding.ListLayoutBinding
+import org.odk.collect.lists.RecyclerViewUtils
class EntityListsFragment(
private val viewModelFactory: ViewModelProvider.Factory,
@@ -41,6 +42,7 @@ class EntityListsFragment(
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val binding = ListLayoutBinding.bind(view)
binding.list.layoutManager = LinearLayoutManager(requireContext())
+ binding.list.addItemDecoration(RecyclerViewUtils.verticalLineDivider(requireContext()))
entitiesViewModel.lists.observe(viewLifecycleOwner) {
binding.list.adapter = ListsAdapter(it, findNavController())
@@ -72,6 +74,7 @@ private class ListsMenuProvider(
val binding = AddEntitiesDialogLayoutBinding.inflate(LayoutInflater.from(context))
MaterialAlertDialogBuilder(context)
.setView(binding.root)
+ .setTitle(org.odk.collect.strings.R.string.add_entity_list)
.setPositiveButton(org.odk.collect.strings.R.string.add) { _, _ ->
entitiesViewModel.addEntityList(binding.entityListName.text.toString())
}
diff --git a/entities/src/main/res/layout/entity_item_layout.xml b/entities/src/main/res/layout/entity_item_layout.xml
index b7a9b680a0e..c862bb186b7 100644
--- a/entities/src/main/res/layout/entity_item_layout.xml
+++ b/entities/src/main/res/layout/entity_item_layout.xml
@@ -4,36 +4,46 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="?android:attr/selectableItemBackground"
- android:paddingHorizontal="@dimen/margin_standard"
- android:paddingTop="@dimen/margin_standard">
+ android:background="?android:attr/selectableItemBackground">
+
+
+
+
-
-
+ tools:text="property1: value1" />
diff --git a/entities/src/test/java/org/odk/collect/entities/EntityItemViewTest.kt b/entities/src/test/java/org/odk/collect/entities/EntityItemViewTest.kt
index 799c9f87786..9199c8b7828 100644
--- a/entities/src/test/java/org/odk/collect/entities/EntityItemViewTest.kt
+++ b/entities/src/test/java/org/odk/collect/entities/EntityItemViewTest.kt
@@ -28,7 +28,7 @@ class EntityItemViewTest {
)
val propertiesView = view.binding.properties
- assertThat(propertiesView.text, equalTo("length: 2:50, name: S.D.O.S"))
+ assertThat(propertiesView.text, equalTo("length: 2:50\nname: S.D.O.S"))
}
@Test
diff --git a/icons/src/main/res/drawable/ic_baseline_wifi_off_24.xml b/icons/src/main/res/drawable/ic_baseline_wifi_off_24.xml
new file mode 100644
index 00000000000..cbcdfdb6f26
--- /dev/null
+++ b/icons/src/main/res/drawable/ic_baseline_wifi_off_24.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/material/src/main/java/org/odk/collect/material/MaterialPill.kt b/material/src/main/java/org/odk/collect/material/MaterialPill.kt
index bd50dc260a8..bb5bb4de4cc 100644
--- a/material/src/main/java/org/odk/collect/material/MaterialPill.kt
+++ b/material/src/main/java/org/odk/collect/material/MaterialPill.kt
@@ -2,6 +2,7 @@ package org.odk.collect.material
import android.content.Context
import android.content.res.ColorStateList
+import android.graphics.drawable.ColorDrawable
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.FrameLayout
@@ -29,14 +30,9 @@ open class MaterialPill(context: Context, attrs: AttributeSet?) :
binding.text.text = text
}
- private val shapeAppearanceModel =
- ShapeAppearanceModel.builder(context, getShapeAppearance(context), -1).build()
-
val binding = PillBinding.inflate(LayoutInflater.from(context), this, true)
init {
- background = createMaterialShapeDrawable(getDefaultBackgroundColor(context))
-
context.withStyledAttributes(attrs, R.styleable.MaterialPill) {
text = getString(R.styleable.MaterialPill_text)
@@ -44,6 +40,12 @@ open class MaterialPill(context: Context, attrs: AttributeSet?) :
if (iconId != -1) {
setIcon(iconId)
}
+
+ val backgroundColor = getColor(
+ R.styleable.MaterialPill_pillBackgroundColor,
+ getDefaultBackgroundColor(context)
+ )
+ setPillBackgroundColor(backgroundColor)
}
}
@@ -61,26 +63,37 @@ open class MaterialPill(context: Context, attrs: AttributeSet?) :
}
fun setPillBackgroundColor(@ColorInt color: Int) {
- background = createMaterialShapeDrawable(color)
+ if (isInEditMode) {
+ /**
+ * For some reason `ShapeAppearanceModel` can't be built in Android Studio's design
+ * preview (even when using a Material 3 theme). It could be that some of the
+ * attibutes used here are not available in the basic themes, but are set in the real
+ * ones we use. For now, just setting a "unshaped" background is an easier option than
+ * deep diving.
+ */
+ background = ColorDrawable(color)
+ return
+ }
+
+ val shapeAppearance = getThemeAttributeValue(
+ context,
+ com.google.android.material.R.attr.shapeAppearanceCornerSmall
+ )
+
+ val shapeAppearanceModel =
+ ShapeAppearanceModel.builder(context, shapeAppearance, -1).build()
+
+ background = MaterialShapeDrawable(shapeAppearanceModel).also {
+ it.fillColor = ColorStateList.valueOf(color)
+ }
}
fun setTextColor(@ColorInt color: Int) {
binding.text.setTextColor(color)
}
- private fun getShapeAppearance(context: Context) = getThemeAttributeValue(
- context,
- com.google.android.material.R.attr.shapeAppearanceCornerSmall
- )
-
private fun getDefaultBackgroundColor(context: Context) = getThemeAttributeValue(
context,
com.google.android.material.R.attr.colorPrimaryContainer
)
-
- private fun createMaterialShapeDrawable(@ColorInt color: Int): MaterialShapeDrawable {
- return MaterialShapeDrawable(shapeAppearanceModel).also {
- it.fillColor = ColorStateList.valueOf(color)
- }
- }
}
diff --git a/material/src/main/res/values/attrs.xml b/material/src/main/res/values/attrs.xml
index c8664f74137..a034395b332 100644
--- a/material/src/main/res/values/attrs.xml
+++ b/material/src/main/res/values/attrs.xml
@@ -16,5 +16,6 @@
+