aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ide_common/src/com/android/ide/common/resources/ResourceResolver.java37
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java32
2 files changed, 63 insertions, 6 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 4fb0d3d..ddfe2bc 100644
--- a/ide_common/src/com/android/ide/common/resources/ResourceResolver.java
+++ b/ide_common/src/com/android/ide/common/resources/ResourceResolver.java
@@ -109,11 +109,46 @@ public class ResourceResolver extends RenderResources {
}
@Override
- public StyleResourceValue getTheme() {
+ public StyleResourceValue getCurrentTheme() {
return mTheme;
}
@Override
+ public StyleResourceValue getTheme(String name, boolean frameworkTheme) {
+ ResourceValue theme = null;
+
+ if (frameworkTheme) {
+ Map<String, ResourceValue> frameworkStyleMap = mFrameworkResources.get(RES_STYLE);
+ if (frameworkStyleMap != null) {
+ theme = frameworkStyleMap.get(name);
+ }
+ } else {
+ Map<String, ResourceValue> projectStyleMap = mProjectResources.get(RES_STYLE);
+ if (projectStyleMap != null) {
+ theme = projectStyleMap.get(name);
+ }
+ }
+
+ if (theme instanceof StyleResourceValue) {
+ return (StyleResourceValue) theme;
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean themeIsParentOf(StyleResourceValue parentTheme, StyleResourceValue childTheme) {
+ do {
+ childTheme = mStyleInheritanceMap.get(childTheme);
+ if (childTheme == null) {
+ return false;
+ } else if (childTheme == parentTheme) {
+ return true;
+ }
+ } while (true);
+ }
+
+ @Override
public ResourceValue getFrameworkResource(String resourceType, String resourceName) {
return getResource(resourceType, resourceName, mFrameworkResources);
}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java
index e371d5a..ce86c9a 100644
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java
+++ b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderResources.java
@@ -50,14 +50,35 @@ public class RenderResources {
}
/**
- * Return the {@link StyleResourceValue} representing the current theme.
- * @return the theme or null if there is no theme.
+ * Returns the {@link StyleResourceValue} representing the current theme.
+ * @return the theme or null if there is no current theme.
*/
- public StyleResourceValue getTheme() {
+ public StyleResourceValue getCurrentTheme() {
return null;
}
/**
+ * Returns a theme by its name.
+ *
+ * @param name the name of the theme
+ * @param frameworkTheme whether the theme is a framework theme.
+ * @return the theme or null if there's no match
+ */
+ public StyleResourceValue getTheme(String name, boolean frameworkTheme) {
+ return null;
+ }
+
+ /**
+ * Returns whether a theme is a parent of a given theme.
+ * @param parentTheme the parent theme
+ * @param childTheme the child theme.
+ * @return true if the parent theme is indeed a parent theme of the child theme.
+ */
+ public boolean themeIsParentOf(StyleResourceValue parentTheme, StyleResourceValue childTheme) {
+ return false;
+ }
+
+ /**
* Returns a framework resource by type and name. The returned resource is resolved.
* @param resourceType the type of the resource
* @param resourceName the name of the resource
@@ -83,8 +104,9 @@ public class RenderResources {
* @return the {@link ResourceValue} object or <code>null</code>
*/
public ResourceValue findItemInTheme(String itemName) {
- if (getTheme() != null) {
- return findItemInStyle(getTheme(), itemName);
+ StyleResourceValue currentTheme = getCurrentTheme();
+ if (currentTheme != null) {
+ return findItemInStyle(currentTheme, itemName);
}
return null;