diff options
author | Jens Ole Lauridsen <jlauridsen@google.com> | 2022-02-09 09:09:45 -0800 |
---|---|---|
committer | Jens Ole Lauridsen <jlauridsen@google.com> | 2022-02-09 20:29:31 +0000 |
commit | b87f28a5a84ab3bf58d36f42f25f0b9da350820b (patch) | |
tree | 1b9e22dd161c512007e0d0071362b4af4c242314 /layout-inspector/src | |
parent | f050a32ea621971ab648a977f226f0e916c2e37e (diff) | |
download | idea-b87f28a5a84ab3bf58d36f42f25f0b9da350820b.tar.gz |
Do not display expandable attributes when unavailable
If we are unable to create a resource resolver, then we are also
unable to augment the attribute values with info from the design
resources.
Make sure that we do not display expandable attributes in this case.
Bug: 218685380
Test: Added unit test
Change-Id: I996234631fb758ff555572eccca25cefd023a00c
Diffstat (limited to 'layout-inspector/src')
2 files changed, 12 insertions, 7 deletions
diff --git a/layout-inspector/src/com/android/tools/idea/layoutinspector/pipeline/appinspection/AppInspectionPropertiesProvider.kt b/layout-inspector/src/com/android/tools/idea/layoutinspector/pipeline/appinspection/AppInspectionPropertiesProvider.kt index 47346f341a4..f68e80a9aad 100644 --- a/layout-inspector/src/com/android/tools/idea/layoutinspector/pipeline/appinspection/AppInspectionPropertiesProvider.kt +++ b/layout-inspector/src/com/android/tools/idea/layoutinspector/pipeline/appinspection/AppInspectionPropertiesProvider.kt @@ -95,13 +95,15 @@ class AppInspectionPropertiesProvider( properties.values.forEach { it.resolveDimensionType(view) } - runReadAction { - propertiesData.classNames.cellSet().mapNotNull { cell -> - properties.getOrNull(cell.rowKey!!, cell.columnKey!!)?.let { convertToItemWithClassLocation(it, cell.value!!) } - }.forEach { properties.put(it) } - propertiesData.resolutionStacks.cellSet().mapNotNull { cell -> - properties.getOrNull(cell.rowKey!!, cell.columnKey!!)?.let { convertToResolutionStackItem(it, view, cell.value!!) } - }.forEach { properties.put(it) } + if (model.resourceLookup.hasResolver) { + runReadAction { + propertiesData.classNames.cellSet().mapNotNull { cell -> + properties.getOrNull(cell.rowKey!!, cell.columnKey!!)?.let { convertToItemWithClassLocation(it, cell.value!!) } + }.forEach { properties.put(it) } + propertiesData.resolutionStacks.cellSet().mapNotNull { cell -> + properties.getOrNull(cell.rowKey!!, cell.columnKey!!)?.let { convertToResolutionStackItem(it, view, cell.value!!) } + }.forEach { properties.put(it) } + } } addInternalProperties(properties, view, properties.getOrNull(ANDROID_URI, ATTR_ID)?.value ,model) } diff --git a/layout-inspector/src/com/android/tools/idea/layoutinspector/resource/ResourceLookup.kt b/layout-inspector/src/com/android/tools/idea/layoutinspector/resource/ResourceLookup.kt index 536b6bce639..f1fc94033a9 100644 --- a/layout-inspector/src/com/android/tools/idea/layoutinspector/resource/ResourceLookup.kt +++ b/layout-inspector/src/com/android/tools/idea/layoutinspector/resource/ResourceLookup.kt @@ -57,6 +57,9 @@ class ResourceLookup(private val project: Project) { var resolver: ResourceLookupResolver? = null private set + val hasResolver: Boolean + get() = resolver != null + /** * The dpi of the device we are currently inspecting or -1 if unknown. */ |