summaryrefslogtreecommitdiff
path: root/layout-inspector/src
diff options
context:
space:
mode:
authorJens Ole Lauridsen <jlauridsen@google.com>2022-02-01 12:56:36 -0800
committerJens Ole Lauridsen <jlauridsen@google.com>2022-02-02 02:11:43 +0000
commit6689beb31a5e8476c52f595119740a651b96d122 (patch)
treebe8279d0233ec3368f134c35c3c233cd94a8592e /layout-inspector/src
parent38d70f67ffc0b54db0cfa06ea1d9ab2f7701ab96 (diff)
downloadidea-6689beb31a5e8476c52f595119740a651b96d122.tar.gz
Do not classify custom views as system views.
In the Layout Inspector we do not get a value for layout for custom views. Use the package name instead for determining if this is a system view. Fixes: 212479333 Test: Unit test added. Change-Id: I3347696fa6d125428e9680c2d41f6cddd82266bd
Diffstat (limited to 'layout-inspector/src')
-rw-r--r--layout-inspector/src/com/android/tools/idea/layoutinspector/model/InspectorModel.kt2
-rw-r--r--layout-inspector/src/com/android/tools/idea/layoutinspector/model/ViewNode.kt4
2 files changed, 4 insertions, 2 deletions
diff --git a/layout-inspector/src/com/android/tools/idea/layoutinspector/model/InspectorModel.kt b/layout-inspector/src/com/android/tools/idea/layoutinspector/model/InspectorModel.kt
index 2aedfc52101..32c296d3e1a 100644
--- a/layout-inspector/src/com/android/tools/idea/layoutinspector/model/InspectorModel.kt
+++ b/layout-inspector/src/com/android/tools/idea/layoutinspector/model/InspectorModel.kt
@@ -58,7 +58,7 @@ class InspectorModel(val project: Project) : ViewNodeAndResourceLookup {
val windows = mutableMapOf<Any, AndroidWindow>()
// synthetic node to hold the roots of the current windows.
- val root = ViewNode("root - hide")
+ val root = ViewNode("android.root - hide")
enum class Posture { HALF_OPEN, FLAT }
enum class FoldOrientation { VERTICAL, HORIZONTAL }
diff --git a/layout-inspector/src/com/android/tools/idea/layoutinspector/model/ViewNode.kt b/layout-inspector/src/com/android/tools/idea/layoutinspector/model/ViewNode.kt
index 1d74c4f3ab2..e0896926e66 100644
--- a/layout-inspector/src/com/android/tools/idea/layoutinspector/model/ViewNode.kt
+++ b/layout-inspector/src/com/android/tools/idea/layoutinspector/model/ViewNode.kt
@@ -34,6 +34,8 @@ import kotlin.concurrent.write
@VisibleForTesting
const val WINDOW_MANAGER_FLAG_DIM_BEHIND = 0x2
+private val systemPackagePrefixes = setOf("android.", "androidx.", "com.android.", "com.google.android.")
+
/**
* A view node represents a view in the view hierarchy as seen on the device.
*
@@ -75,7 +77,7 @@ open class ViewNode(
/** Returns true if this [ViewNode] is found in a layout in the framework or in a system layout from appcompat */
open val isSystemNode: Boolean
get() =
- layout == null ||
+ (layout == null && systemPackagePrefixes.any { qualifiedName.startsWith(it) }) ||
layout?.namespace == ResourceNamespace.ANDROID ||
layout?.name?.startsWith("abc_") == true