Search in sources :

Example 1 with ResourceInjector

use of com.android.tools.build.bundletool.model.ResourceInjector in project bundletool by google.

the class LocaleConfigXmlInjector method injectLocaleConfigXml.

private static ModuleSplit injectLocaleConfigXml(ModuleSplit split, XmlNode xmlNode) {
    ResourceInjector resourceInjector = ResourceInjector.fromModuleSplit(split);
    ResourceId resourceId = resourceInjector.addResource(XML_TYPE_NAME, createXmlEntry());
    ModuleEntry localesConfigEntry = addLocalesConfigEntry(xmlNode);
    return split.toBuilder().setResourceTable(resourceInjector.build()).setEntries(ImmutableList.<ModuleEntry>builder().addAll(split.getEntries()).add(localesConfigEntry).build()).setAndroidManifest(split.getAndroidManifest().toEditor().setLocaleConfig(resourceId.getFullResourceId()).save()).build();
}
Also used : ResourceId(com.android.tools.build.bundletool.model.ResourceId) ModuleEntry(com.android.tools.build.bundletool.model.ModuleEntry) ResourceInjector(com.android.tools.build.bundletool.model.ResourceInjector)

Example 2 with ResourceInjector

use of com.android.tools.build.bundletool.model.ResourceInjector in project bundletool by google.

the class SplitsXmlInjector method injectSplitsXml.

private static ModuleSplit injectSplitsXml(ModuleSplit split, XmlNode xmlNode) {
    ZipPath resourcePath = getUniqueResourcePath(split);
    ResourceInjector resourceInjector = ResourceInjector.fromModuleSplit(split);
    ResourceId resourceId = resourceInjector.addResource(XML_TYPE_NAME, createXmlEntry(resourcePath));
    return split.toBuilder().setResourceTable(resourceInjector.build()).setEntries(ImmutableList.<ModuleEntry>builder().addAll(split.getEntries()).add(ModuleEntry.builder().setPath(resourcePath).setContent(ByteSource.wrap(xmlNode.toByteArray())).build()).build()).setAndroidManifest(split.getAndroidManifest().toEditor().addMetaDataResourceId(METADATA_KEY, resourceId.getFullResourceId()).save()).build();
}
Also used : ResourceId(com.android.tools.build.bundletool.model.ResourceId) ModuleEntry(com.android.tools.build.bundletool.model.ModuleEntry) ZipPath(com.android.tools.build.bundletool.model.ZipPath) ResourceInjector(com.android.tools.build.bundletool.model.ResourceInjector)

Aggregations

ModuleEntry (com.android.tools.build.bundletool.model.ModuleEntry)2 ResourceId (com.android.tools.build.bundletool.model.ResourceId)2 ResourceInjector (com.android.tools.build.bundletool.model.ResourceInjector)2 ZipPath (com.android.tools.build.bundletool.model.ZipPath)1