use of com.android.tools.build.bundletool.model.AndroidManifest.META_DATA_ELEMENT_NAME in project bundletool by google.
the class ManifestEditor method setMetadataValue.
private ManifestEditor setMetadataValue(String name, XmlProtoAttributeBuilder valueAttr) {
XmlProtoElementBuilder applicationEl = manifestElement.getOrCreateChildElement(APPLICATION_ELEMENT_NAME);
Optional<XmlProtoElementBuilder> existingMetadataEl = applicationEl.getChildrenElements(META_DATA_ELEMENT_NAME).filter(metadataEl -> metadataEl.getAndroidAttribute(NAME_RESOURCE_ID).map(nameAttr -> name.equals(nameAttr.getValueAsString())).orElse(false)).collect(toOptional());
if (existingMetadataEl.isPresent()) {
existingMetadataEl.get().removeAndroidAttribute(VALUE_RESOURCE_ID).addAttribute(valueAttr);
} else {
applicationEl.addChildElement(XmlProtoElementBuilder.create(META_DATA_ELEMENT_NAME).addAttribute(createAndroidAttribute("name", NAME_RESOURCE_ID).setValueAsString(name)).addAttribute(valueAttr));
}
return this;
}
Aggregations