aboutsummaryrefslogtreecommitdiffstats
path: root/ide_common/src
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2011-05-20 20:41:35 -0700
committerTor Norbye <tnorbye@google.com>2011-05-23 12:52:37 -0700
commit8c224181ef61400338120015d1228513104a19e3 (patch)
treee8e38aeae9e74c92705f13ad05e5883322a60de6 /ide_common/src
parent1f03a6d703421d94c392c5afc74f7036d4c71167 (diff)
downloadsdk-8c224181ef61400338120015d1228513104a19e3.zip
sdk-8c224181ef61400338120015d1228513104a19e3.tar.gz
sdk-8c224181ef61400338120015d1228513104a19e3.tar.bz2
Detect and add special warning for wrong themes
If you open a layout designed for a particular theme in another theme, you can get many confusing error messages. Instead of "attribute missing" it may tell you that it failed to convert a resource to a color or drawable, and so on. To help guide users to the root problem (wrong theme chosen) this changeset detects the scenario where theme attributes can't be resolved, and when these are found the top of the error log will start with a bold message stating that theme resources were not found and to check whether the correct theme is chosen. To do this, the resource resolver emits a new sub-type of the resource missing tag into the error log, which is used in the IDE to prefix the errors with the special error message. Change-Id: Ic29c9af37da4b5cc2c9fb1ca5670c8b8f79bf852
Diffstat (limited to 'ide_common/src')
-rw-r--r--ide_common/src/com/android/ide/common/resources/ResourceResolver.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/ide_common/src/com/android/ide/common/resources/ResourceResolver.java b/ide_common/src/com/android/ide/common/resources/ResourceResolver.java
index 89a4cba..938a6ef 100644
--- a/ide_common/src/com/android/ide/common/resources/ResourceResolver.java
+++ b/ide_common/src/com/android/ide/common/resources/ResourceResolver.java
@@ -67,14 +67,13 @@ public class ResourceResolver extends RenderResources {
}
/**
- * Creates a new ResourceResolver object.
+ * Creates a new {@link ResourceResolver} object.
*
- * @param IFrameworkResourceIdProvider an optional framework resource ID provider
* @param projectResources the project resources.
* @param frameworkResources the framework resources.
* @param themeName the name of the current theme.
* @param isProjectTheme Is this a project theme?
- * @return
+ * @return a new {@link ResourceResolver}
*/
public static ResourceResolver create(
Map<ResourceType, Map<String, ResourceValue>> projectResources,
@@ -231,12 +230,22 @@ public class ResourceResolver extends RenderResources {
}
// Now look for the item in the theme, starting with the current one.
+ ResourceValue item;
if (frameworkOnly) {
// FIXME for now we do the same as if it didn't specify android:
- return findItemInStyle(mTheme, referenceName);
+ item = findItemInStyle(mTheme, referenceName);
+ } else {
+ item = findItemInStyle(mTheme, referenceName);
+ }
+
+ if (item == null && mLogger != null) {
+ mLogger.warning(LayoutLog.TAG_RESOURCES_RESOLVE_THEME_ATTR,
+ String.format("Couldn't find theme resource %1$s for the current theme",
+ reference),
+ new ResourceValue(ResourceType.ATTR, referenceName, frameworkOnly));
}
- return findItemInStyle(mTheme, referenceName);
+ return item;
} else if (reference.startsWith(PREFIX_RESOURCE_REF)) {
boolean frameworkOnly = false;