Send invisible as hidden attribute
Summary: This allows UIDebugger to draw them differently in tree and visualiser Reviewed By: lblasa Differential Revision: D47915505 fbshipit-source-id: a4d2ef9d653233e3ff24bc26cfe8017f9b51dd2b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0aa6d7832c
commit
413f85964b
@@ -13,6 +13,8 @@ import com.facebook.flipper.plugins.uidebugger.model.InspectableObject
|
||||
import com.facebook.flipper.plugins.uidebugger.model.MetadataId
|
||||
import com.facebook.flipper.plugins.uidebugger.util.Immediate
|
||||
import com.facebook.flipper.plugins.uidebugger.util.MaybeDeferred
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
/**
|
||||
* A chained descriptor is a special type of descriptor that models the inheritance hierarchy in
|
||||
@@ -78,6 +80,32 @@ abstract class ChainedDescriptor<T> : NodeDescriptor<T> {
|
||||
|
||||
open fun onGetBounds(node: T): Bounds? = null
|
||||
|
||||
final override fun getHiddenAttributes(node: T): JsonObject? {
|
||||
|
||||
val descriptors = mutableListOf(this)
|
||||
|
||||
var curDescriptor: ChainedDescriptor<T>? = mSuper
|
||||
|
||||
while (curDescriptor != null) {
|
||||
descriptors.add(curDescriptor)
|
||||
curDescriptor = curDescriptor.mSuper
|
||||
}
|
||||
|
||||
// reverse the list so that subclasses can override attributes of the base class if they wish to
|
||||
descriptors.reverse()
|
||||
val builder = mutableMapOf<String, JsonElement>()
|
||||
|
||||
descriptors.forEach { it.onGetHiddenAttributes(node, builder) }
|
||||
|
||||
return if (builder.isNotEmpty()) {
|
||||
JsonObject(builder)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
open fun onGetHiddenAttributes(node: T, attributes: MutableMap<String, JsonElement>) {}
|
||||
|
||||
final override fun getChildren(node: T): List<Any> {
|
||||
val children = onGetChildren(node) ?: mSuper?.getChildren(node)
|
||||
return children ?: listOf()
|
||||
|
||||
@@ -25,6 +25,8 @@ import com.facebook.flipper.plugins.uidebugger.common.*
|
||||
import com.facebook.flipper.plugins.uidebugger.model.*
|
||||
import com.facebook.flipper.plugins.uidebugger.util.ResourcesUtil
|
||||
import java.lang.reflect.Field
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.json.JsonPrimitive
|
||||
|
||||
object ViewDescriptor : ChainedDescriptor<View>() {
|
||||
|
||||
@@ -434,6 +436,13 @@ object ViewDescriptor : ChainedDescriptor<View>() {
|
||||
return InspectableObject(params)
|
||||
}
|
||||
|
||||
override fun onGetHiddenAttributes(node: View, attributes: MutableMap<String, JsonElement>) {
|
||||
|
||||
if (node.visibility != View.VISIBLE) {
|
||||
attributes["invisible"] = JsonPrimitive(true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getViewTags(node: View): MutableMap<Int, Inspectable> {
|
||||
val tags = mutableMapOf<Int, Inspectable>()
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ object ViewGroupDescriptor : ChainedDescriptor<ViewGroup>() {
|
||||
node: ViewGroup,
|
||||
attributeSections: MutableMap<MetadataId, InspectableObject>
|
||||
) {
|
||||
|
||||
val props = mutableMapOf<Int, Inspectable>()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
props[LayoutModeAttributeId] = LayoutModeMapping.toInspectable(node.layoutMode)
|
||||
|
||||
Reference in New Issue
Block a user