aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Andrew Pellegrini <apell@google.com>2016-11-23 18:03:23 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-11-23 19:13:13 +0000
commit5f59e1c43068861b07d72280859734c855a9b468 (patch)
treedfd3ff7bb4279b503acbe367844911122d1edde9 /src
parent4956d3207f8d055405b214f01ce571f84a47f6e4 (diff)
Remove limitation of only analyzing files with known extensions as resources.
-- MOS_MIGRATED_REVID=140044141
Diffstat (limited to 'src')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/ResourceShrinker.java23
1 files changed, 7 insertions, 16 deletions
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<File, String> 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<Resource> deleted,
Map<File, String> 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<ResourceType> 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);