From 1de033c15701bd4f35e80ab1d51a45bce561f537 Mon Sep 17 00:00:00 2001 From: Luke De Feo Date: Mon, 31 Jul 2023 10:53:03 -0700 Subject: [PATCH] Add bounds to fragment Summary: Previously the bounds was 0, the trick is to steel the offset from the view and then use offsetchild zero so it doesnt get applied twice Reviewed By: lblasa Differential Revision: D47915115 fbshipit-source-id: ff771470dcf1720ca265fc9017ff0ea3b0bc1ca1 --- .../descriptors/FragmentFrameworkDescriptor.kt | 13 +++++++++++-- .../descriptors/FragmentSupportDescriptor.kt | 10 ++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/FragmentFrameworkDescriptor.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/FragmentFrameworkDescriptor.kt index 5b30654a807..399501f3fa7 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/FragmentFrameworkDescriptor.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/FragmentFrameworkDescriptor.kt @@ -27,10 +27,19 @@ class FragmentFrameworkDescriptor(val register: DescriptorRegister) : return node.javaClass.simpleName } - override fun onGetBounds(node: android.app.Fragment): Bounds? = Bounds(0, 0, 0, 0) + override fun onGetBounds(node: android.app.Fragment): Bounds { + return node.view?.let { + val descriptor = register.descriptorForClassUnsafe(it.javaClass) + return descriptor.getBounds(it) + } + ?: Bounds(0, 0, 0, 0) + } override fun onGetChildren(node: android.app.Fragment): List = - node.view?.let { view -> listOf(view) } ?: listOf() + node.view?.let { view -> + listOf(OffsetChild.zero(view, register.descriptorForClassUnsafe(view.javaClass))) + } + ?: listOf() override fun onGetAttributes( node: android.app.Fragment, diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/FragmentSupportDescriptor.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/FragmentSupportDescriptor.kt index e9116b4aa46..fcce243791e 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/FragmentSupportDescriptor.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/FragmentSupportDescriptor.kt @@ -47,12 +47,18 @@ class FragmentSupportDescriptor(val register: DescriptorRegister) : return node.javaClass.simpleName } - override fun onGetBounds(node: Fragment): Bounds = Bounds(0, 0, 0, 0) + override fun onGetBounds(node: Fragment): Bounds { + return node.view?.let { + val descriptor = register.descriptorForClassUnsafe(it.javaClass) + return descriptor.getBounds(it) + } + ?: Bounds(0, 0, 0, 0) + } override fun onGetChildren(node: androidx.fragment.app.Fragment): List { val view = node.view return if (view != null && node.isVisible) { - listOf(view) + listOf(OffsetChild.zero(view, register.descriptorForClassUnsafe(view.javaClass))) } else { listOf() }