From 5f59e1c43068861b07d72280859734c855a9b468 Mon Sep 17 00:00:00 2001 From: Andrew Pellegrini Date: Wed, 23 Nov 2016 18:03:23 +0000 Subject: Remove limitation of only analyzing files with known extensions as resources. -- MOS_MIGRATED_REVID=140044141 --- .../devtools/build/android/ResourceShrinker.java | 23 +++++++--------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/tools/android/java/com/google/devtools') diff --git a/src/tools/android/java/com/google/devtools/build/android/ResourceShrinker.java b/src/tools/android/java/com/google/devtools/build/android/ResourceShrinker.java index c2c2751e8a..51312600b1 100644 --- a/src/tools/android/java/com/google/devtools/build/android/ResourceShrinker.java +++ b/src/tools/android/java/com/google/devtools/build/android/ResourceShrinker.java @@ -20,11 +20,6 @@ import static com.android.SdkConstants.ATTR_NAME; import static com.android.SdkConstants.ATTR_PARENT; import static com.android.SdkConstants.ATTR_TYPE; import static com.android.SdkConstants.DOT_CLASS; -import static com.android.SdkConstants.DOT_GIF; -import static com.android.SdkConstants.DOT_JPEG; -import static com.android.SdkConstants.DOT_JPG; -import static com.android.SdkConstants.DOT_PNG; -import static com.android.SdkConstants.DOT_SVG; import static com.android.SdkConstants.DOT_XML; import static com.android.SdkConstants.FD_RES_VALUES; import static com.android.SdkConstants.PREFIX_ANDROID; @@ -32,7 +27,6 @@ import static com.android.SdkConstants.STYLE_RESOURCE_PREFIX; import static com.android.SdkConstants.TAG_ITEM; import static com.android.SdkConstants.TAG_RESOURCES; import static com.android.SdkConstants.TAG_STYLE; -import static com.android.utils.SdkUtils.endsWith; import static com.android.utils.SdkUtils.endsWithIgnoreCase; import static java.nio.charset.StandardCharsets.UTF_8; @@ -285,7 +279,7 @@ public class ResourceShrinker { } /** - * Write stub values for IDs to values.xml to match those available in public.xml. + * Write stub values for IDs to values.xml to match those available in public.xml. */ private void createStubIds(File values, Map rewritten) throws IOException, ParserConfigurationException, SAXException { @@ -310,7 +304,7 @@ public class ResourceShrinker { } /** - * Remove public definitions of unused resources. + * Remove public definitions of unused resources. */ private void trimPublicResources(File publicXml, Set deleted, Map rewritten) throws IOException, ParserConfigurationException, SAXException { @@ -640,19 +634,16 @@ public class ResourceShrinker { boolean isXml = endsWithIgnoreCase(path, DOT_XML); Resource from = null; // Record resource for the whole file - if (folderType != ResourceFolderType.VALUES - && (isXml - || endsWith(path, DOT_PNG) //also true for endsWith(name, DOT_9PNG) - || endsWith(path, DOT_JPG) - || endsWith(path, DOT_GIF) - || endsWith(path, DOT_JPEG) - || endsWith(path, DOT_SVG))) { + if (folderType != ResourceFolderType.VALUES) { List types = FolderTypeRelationship.getRelatedResourceTypes( folderType); ResourceType type = types.get(0); assert type != ResourceType.ID : folderType; String name = file.getName(); - name = name.substring(0, name.indexOf('.')); + int extension = name.indexOf('.'); + if (extension > 0) { + name = name.substring(0, extension); + } Resource resource = getResource(type, name); if (resource != null) { resource.addLocation(file); -- cgit v1.2.3