Twelve: ListItem: Allow setting leading/trailing view visibility
Change-Id: Icd355d7d6e9904e4f8d3b9d6f636a65a31991f45
diff --git a/app/src/main/java/org/lineageos/twelve/ui/views/ListItem.kt b/app/src/main/java/org/lineageos/twelve/ui/views/ListItem.kt
index bb6a105..206f76f 100644
--- a/app/src/main/java/org/lineageos/twelve/ui/views/ListItem.kt
+++ b/app/src/main/java/org/lineageos/twelve/ui/views/ListItem.kt
@@ -61,6 +61,12 @@
leadingViewContainerFrameLayout.setChildAndUpdateVisibility(value)
}
+ var leadingViewIsVisible: Boolean
+ get() = leadingViewContainerFrameLayout.isVisible
+ set(value) {
+ leadingViewContainerFrameLayout.updateVisibility(value)
+ }
+
var headlineText: CharSequence?
get() = headlineTextView.text
set(value) {
@@ -91,6 +97,12 @@
trailingViewContainerFrameLayout.setChildAndUpdateVisibility(value)
}
+ var trailingViewIsVisible: Boolean
+ get() = trailingViewContainerFrameLayout.isVisible
+ set(value) {
+ leadingViewContainerFrameLayout.updateVisibility(value)
+ }
+
init {
inflate(context, R.layout.list_item, this)
@@ -103,6 +115,7 @@
}?.let {
setLeadingView(it)
}
+ leadingViewIsVisible = getBoolean(R.styleable.ListItem_leadingViewIsVisible, true)
headlineText = getString(R.styleable.ListItem_headlineText)
supportingText = getString(R.styleable.ListItem_supportingText)
trailingIconImage = getDrawable(R.styleable.ListItem_trailingIconImage)
@@ -112,6 +125,7 @@
}?.let {
setTrailingView(it)
}
+ trailingViewIsVisible = getBoolean(R.styleable.ListItem_trailingViewIsVisible, true)
} finally {
recycle()
}
diff --git a/app/src/main/res/values/attrs_ListItem.xml b/app/src/main/res/values/attrs_ListItem.xml
index c2a729a..8c7ec39 100644
--- a/app/src/main/res/values/attrs_ListItem.xml
+++ b/app/src/main/res/values/attrs_ListItem.xml
@@ -8,10 +8,12 @@
<attr name="headlineText" format="string" />
<attr name="leadingIconImage" format="reference" />
<attr name="leadingText" format="string" />
+ <attr name="leadingViewIsVisible" format="boolean" />
<attr name="leadingViewLayout" format="reference" />
<attr name="supportingText" format="string" />
<attr name="trailingIconImage" format="reference" />
<attr name="trailingSupportingText" format="string" />
+ <attr name="trailingViewIsVisible" format="boolean" />
<attr name="trailingViewLayout" format="reference" />
</declare-styleable>
</resources>