public boolean isStyleReference() { return isStyleReference(trimmedValue); }
public static ResName getStyleReference(String value, String defPackage, String defType) { if (!isStyleReference(value)) throw new IllegalArgumentException("not a style reference: " + value); return ResName.qualifyResName(value.substring(1), defPackage, defType); }
public ResName getStyleReference() { if (!isStyleReference()) throw new RuntimeException("not a style reference: " + this); return ResName.qualifyResName(value.substring(1), contextPackageName, "attr"); }
@Nullable public static ResType inferType(String itemString) { ResType itemResType = ResType.inferFromValue(itemString); if (itemResType == ResType.CHAR_SEQUENCE) { if (AttributeResource.isStyleReference(itemString)) { itemResType = ResType.STYLE; } else if (itemString.equals("@null")) { itemResType = ResType.NULL; } else if (AttributeResource.isResourceReference(itemString)) { // This is a reference; no type info needed. itemResType = null; } } return itemResType; }
public String qualify(String value) { if (value == null) return null; if (AttributeResource.isResourceReference(value)) { return "@" + ResName.qualifyResourceName(value.trim().substring(1).replace("+", ""), packageName, "attr"); } else if (AttributeResource.isStyleReference(value)) { return "?" + ResName.qualifyResourceName(value.trim().substring(1), packageName, "attr"); } else { return StringResources.processStringResources(value); } }
private ResName dereferenceAttr(AttributeResource attr) { if (attr.isResourceReference()) { return attr.getResourceReference(); } else if (attr.isStyleReference()) { return attr.getStyleReference(); } throw new RuntimeException("Found a " + attr + " but can't cast it :("); }
@Override public int getStyleAttribute() { String attr = getAttribute(null, "style"); if (attr == null || (!AttributeResource.isResourceReference(attr) && !AttributeResource.isStyleReference(attr))) { return 0; } int style = getResourceId(attr, packageName, "style"); if (style == 0) { // try again with underscores... style = getResourceId(attr.replace('.', '_'), packageName, "style"); } return style; }
} else if (AttributeResource.isStyleReference(value)) { ResName resRef = AttributeResource.getStyleReference(value, packageName, "attr"); Integer valueResId = resourceResolver.getIdentifier(resRef.name, resRef.type, resRef.packageName);
while (defStyleAttribute.isStyleReference()) { AttributeResource other = themeStyleSet.getAttrValue(defStyleAttribute.getStyleReference()); if (other == null) { } else if (attrValue.isStyleReference()) { styleAttributeResName = attrValue.getStyleReference(); while (attribute != null && attribute.isStyleReference()) { ResName otherAttrName = attribute.getStyleReference(); if (attribute.resName.equals(otherAttrName)) {
@HiddenApi @Implementation(minSdk = LOLLIPOP) public boolean getThemeValue(long themePtr, int ident, TypedValue outValue, boolean resolveRefs) { ResName resName = resourceTable.getResName(ident); ThemeStyleSet themeStyleSet = getNativeTheme(themePtr).themeStyleSet; AttributeResource attrValue = themeStyleSet.getAttrValue(resName); while(attrValue != null && attrValue.isStyleReference()) { ResName attrResName = attrValue.getStyleReference(); if (attrValue.resName.equals(attrResName)) { Logger.info("huh... circular reference for %s?", attrResName.getFullyQualifiedName()); return false; } attrValue = themeStyleSet.getAttrValue(attrResName); } if (attrValue != null) { convertAndFill(attrValue, outValue, config, resolveRefs); return true; } return false; }
private int getResourceId(String possiblyQualifiedResourceName, String defaultPackageName, String defaultType) { if (AttributeResource.isNull(possiblyQualifiedResourceName)) return 0; if (AttributeResource.isStyleReference(possiblyQualifiedResourceName)) { ResName styleReference = AttributeResource.getStyleReference(possiblyQualifiedResourceName, defaultPackageName, "attr"); Integer resourceId = resourceTable.getResourceId(styleReference); if (resourceId == null) { throw new Resources.NotFoundException(styleReference.getFullyQualifiedName()); } return resourceId; } if (AttributeResource.isResourceReference(possiblyQualifiedResourceName)) { ResName resourceReference = AttributeResource.getResourceReference(possiblyQualifiedResourceName, defaultPackageName, defaultType); Integer resourceId = resourceTable.getResourceId(resourceReference); if (resourceId == null) { throw new Resources.NotFoundException(resourceReference.getFullyQualifiedName()); } return resourceId; } possiblyQualifiedResourceName = removeLeadingSpecialCharsIfAny(possiblyQualifiedResourceName); ResName resName = ResName.qualifyResName(possiblyQualifiedResourceName, defaultPackageName, defaultType); Integer resourceId = resourceTable.getResourceId(resName); return resourceId == null ? 0 : resourceId; }
if (attribute.isStyleReference()) { return;
} else if (AttributeResource.isStyleReference(value)) { ResName resRef = AttributeResource.getStyleReference(value, packageName, "attr"); Integer valueResId = resourceResolver.getIdentifier(resRef.name, resRef.type, resRef.packageName);
public ResName getStyleReference() { if (!isStyleReference()) throw new RuntimeException("not a style reference: " + this); return ResName.qualifyResName(value.substring(1), contextPackageName, "attr"); }
public String qualify(String value) { if (value == null) return null; if (AttributeResource.isResourceReference(value)) { return "@" + ResName.qualifyResourceName(value.substring(1).replace("+", ""), packageName, "attr"); } else if (AttributeResource.isStyleReference(value)) { return "?" + ResName.qualifyResourceName(value.substring(1), packageName, "attr"); } else { return value; } }
public String qualify(String value) { if (value == null) return null; if (AttributeResource.isResourceReference(value)) { return "@" + ResName.qualifyResourceName(value.substring(1).replace("+", ""), packageName, "attr"); } else if (AttributeResource.isStyleReference(value)) { return "?" + ResName.qualifyResourceName(value.substring(1), packageName, "attr"); } else { return value; } }
private ResName dereferenceAttr(AttributeResource attr) { if (attr.isResourceReference()) { return attr.getResourceReference(); } else if (attr.isStyleReference()) { return attr.getStyleReference(); } throw new RuntimeException("Found a " + attr + " but can't cast it :("); }
private ResName dereferenceAttr(AttributeResource attr) { if (attr.isResourceReference()) { return attr.getResourceReference(); } else if (attr.isStyleReference()) { return attr.getStyleReference(); } throw new RuntimeException("Found a " + attr + " but can't cast it :("); }
@Override public int getStyleAttribute() { String attr = getAttribute(null, "style"); if (attr == null || (!AttributeResource.isResourceReference(attr) && !AttributeResource.isStyleReference(attr))) { return 0; } return getResourceId(attr, packageName, "style"); }
@Override public int getStyleAttribute() { String attr = getAttribute(null, "style"); if (attr == null || (!AttributeResource.isResourceReference(attr) && !AttributeResource.isStyleReference(attr))) { return 0; } return getResourceId(attr, packageName, "style"); }