diff --git a/app/src/main/java/com/yacgroup/yacguide/TableActivity.kt b/app/src/main/java/com/yacgroup/yacguide/TableActivity.kt index bd24b8cf..f926432c 100644 --- a/app/src/main/java/com/yacgroup/yacguide/TableActivity.kt +++ b/app/src/main/java/com/yacgroup/yacguide/TableActivity.kt @@ -67,7 +67,7 @@ abstract class TableActivity : BaseNavigationActiv Comment( text = it.text.orEmpty(), properties = listOf( - CommentProperty(R.id.qualityLayout, R.string.relevance, RegionComment.QUALITY_MAP, it.qualityId) + CommentProperty(R.string.relevance, RegionComment.QUALITY_MAP, it.qualityId) ) ) }) @@ -78,7 +78,7 @@ abstract class TableActivity : BaseNavigationActiv Comment( text = it.text.orEmpty(), properties = listOf( - CommentProperty(R.id.qualityLayout, R.string.relevance, SectorComment.QUALITY_MAP, it.qualityId) + CommentProperty(R.string.relevance, SectorComment.QUALITY_MAP, it.qualityId) ) ) }) @@ -89,7 +89,7 @@ abstract class TableActivity : BaseNavigationActiv Comment( text = it.text.orEmpty(), properties = listOf( - CommentProperty(R.id.qualityLayout, R.string.nature, RockComment.RELEVANCE_MAP, it.qualityId) + CommentProperty(R.string.nature, RockComment.RELEVANCE_MAP, it.qualityId) ) ) }) @@ -100,10 +100,10 @@ abstract class TableActivity : BaseNavigationActiv Comment( text = it.text.orEmpty(), properties = listOf( - CommentProperty(R.id.qualityLayout, R.string.route_quality, RouteComment.QUALITY_MAP, it.qualityId), - CommentProperty(R.id.gradeLayout, R.string.grade, RouteComment.GRADE_MAP, it.gradeId), - CommentProperty(R.id.protectionLayout, R.string.protection, RouteComment.PROTECTION_MAP, it.securityId), - CommentProperty(R.id.dryingLayout, R.string.drying, RouteComment.DRYING_MAP, it.wetnessId) + CommentProperty(R.string.route_quality, RouteComment.QUALITY_MAP, it.qualityId), + CommentProperty(R.string.grade, RouteComment.GRADE_MAP, it.gradeId), + CommentProperty(R.string.protection, RouteComment.PROTECTION_MAP, it.securityId), + CommentProperty(R.string.drying, RouteComment.DRYING_MAP, it.wetnessId) ) ) }) @@ -121,24 +121,31 @@ abstract class TableActivity : BaseNavigationActiv val commentDialogBinding = CommentDialogBinding.inflate(dialog.layoutInflater) dialog.setView(commentDialogBinding.root) + // FIXME: Why is this divider code necessary? val dividerResource = TypedValue() theme.resolveAttribute(android.R.attr.listDivider, dividerResource, true) comments.forEach { comment -> - CommentBinding.inflate(dialog.layoutInflater, commentDialogBinding.commentLayout, false).let { view -> + CommentBinding.inflate(dialog.layoutInflater).let { view -> view.commentDivider.setBackgroundResource(dividerResource.resourceId) - comment.properties.forEach { prop -> - _property2String(prop.qualityMap, prop.qualityId)?.let { - view.root.findViewById(prop.layoutResource).apply { - CommentPropertyBinding.inflate(dialog.layoutInflater).apply { - propertyNameTextView.setText(prop.nameResource) - propertyValueTextView.text = it - } - visibility = View.VISIBLE + comment.properties.forEachIndexed { viewIndex, prop -> + _property2String(prop.qualityMap, prop.qualityId)?.let { propValue -> + val propBinding = CommentPropertyBinding.inflate(dialog.layoutInflater).apply { + propertyNameTextView.setText(prop.nameResource) + propertyValueTextView.text = propValue } + // The layout margins are not considered, if the view is add programmatically. + propBinding.root.layoutParams = ConstraintLayout.LayoutParams( + ConstraintLayout.LayoutParams.MATCH_PARENT, + ConstraintLayout.LayoutParams.WRAP_CONTENT + ).apply { + bottomMargin = 10 + } + // +1 because the divider is the first element in the linear view + view.root.addView(propBinding.root, viewIndex + 1) } } view.commentTextView.text = comment.text - commentDialogBinding.commentLayout.addView(view.singleCommentLayout) + commentDialogBinding.commentLayout.addView(view.root) } } dialog.show() diff --git a/app/src/main/java/com/yacgroup/yacguide/utils/CommentUtils.kt b/app/src/main/java/com/yacgroup/yacguide/utils/CommentUtils.kt index 52cbaeec..b586fdd3 100644 --- a/app/src/main/java/com/yacgroup/yacguide/utils/CommentUtils.kt +++ b/app/src/main/java/com/yacgroup/yacguide/utils/CommentUtils.kt @@ -23,8 +23,7 @@ class Comment( ) class CommentProperty( - val layoutResource: Int, val nameResource: Int, val qualityMap: Map, val qualityId: Int -) \ No newline at end of file +) diff --git a/app/src/main/res/layout/comment.xml b/app/src/main/res/layout/comment.xml index 86a4e5e3..a034044c 100644 --- a/app/src/main/res/layout/comment.xml +++ b/app/src/main/res/layout/comment.xml @@ -17,21 +17,17 @@ --> - + - - - - - - - + . --> - + android:layout_gravity="center" + android:paddingTop="@dimen/activity_vertical_margin" + android:paddingLeft="@dimen/activity_horizontal_margin" + android:paddingRight="@dimen/activity_horizontal_margin"> - + android:id="@+id/commentLayout"/> - - - - - + diff --git a/app/src/main/res/layout/comment_property.xml b/app/src/main/res/layout/comment_property.xml index d46fb67f..bbcd6e48 100644 --- a/app/src/main/res/layout/comment_property.xml +++ b/app/src/main/res/layout/comment_property.xml @@ -20,8 +20,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="10dp"> + android:layout_height="wrap_content"> - \ No newline at end of file +