Java Code Examples for com.android.resources.ResourceType#getName()

The following examples show how to use com.android.resources.ResourceType#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceItem.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a formatted string usable in an XML to use for the {@link ResourceItem}.
 *
 * @param system Whether this is a system resource or a project resource.
 * @return a string in the format @[type]/[name]
 */
public String getXmlString(ResourceType type, boolean system) {
    if (type == ResourceType.ID /* && isDeclaredInline()*/) {
        return (system ? ANDROID_NEW_ID_PREFIX : NEW_ID_PREFIX) + "/" + getName();
    }

    return (system ? ANDROID_PREFIX : PREFIX_RESOURCE_REF) + type.getName() + "/" + getName();
}
 
Example 2
Source File: ResourceItem.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a formatted string usable in an XML to use for the {@link ResourceItem}.
 * @param system Whether this is a system resource or a project resource.
 * @return a string in the format @[type]/[name]
 */
public String getXmlString(ResourceType type, boolean system) {
    if (type == ResourceType.ID && isDeclaredInline()) {
        return (system ? "@android:" : "@+") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    return (system ? "@android:" : "@") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
 
Example 3
Source File: ScanDupResTask.java    From atlas with Apache License 2.0 5 votes vote down vote up
private static String getFolderName(ResourceItem resourceItem) {
    ResourceType itemType = resourceItem.getType();
    String folderName = itemType.getName();
    String qualifiers = resourceItem.getQualifiers();
    if (!qualifiers.isEmpty()) {
        folderName = folderName + "-" + qualifiers;
    }

    return folderName;
}
 
Example 4
Source File: MergedResourceWriter.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Calculates the right folder name give a resource item.
 *
 * @param resourceItem the resource item to calculate the folder name from.
 * @return a relative folder name
 */
@NonNull
private static String getFolderName(ResourceItem resourceItem) {
    ResourceType itemType = resourceItem.getType();
    String folderName = itemType.getName();
    String qualifiers = resourceItem.getQualifiers();
    if (!qualifiers.isEmpty()) {
        folderName = folderName + RES_QUALIFIER_SEP + qualifiers;
    }
    return folderName;
}
 
Example 5
Source File: ResourceItem.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a formatted string usable in an XML to use for the {@link ResourceItem}.
 *
 * @param system Whether this is a system resource or a project resource.
 * @return a string in the format @[type]/[name]
 */
public String getXmlString(ResourceType type, boolean system) {
    if (type == ResourceType.ID /* && isDeclaredInline()*/) {
        return (system ? ANDROID_NEW_ID_PREFIX : NEW_ID_PREFIX) + "/" + getName();
    }

    return (system ? ANDROID_PREFIX : PREFIX_RESOURCE_REF) + type.getName() + "/" + getName();
}
 
Example 6
Source File: ResourceItem.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a formatted string usable in an XML to use for the {@link ResourceItem}.
 * @param system Whether this is a system resource or a project resource.
 * @return a string in the format @[type]/[name]
 */
public String getXmlString(ResourceType type, boolean system) {
    if (type == ResourceType.ID && isDeclaredInline()) {
        return (system ? "@android:" : "@+") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    return (system ? "@android:" : "@") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
 
Example 7
Source File: ResourceItem.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a formatted string usable in an XML to use for the {@link ResourceItem}.
 * @param system Whether this is a system resource or a project resource.
 * @return a string in the format @[type]/[name]
 */
public String getXmlString(ResourceType type, boolean system) {
    if (type == ResourceType.ID && isDeclaredInline()) {
        return (system ? "@android:" : "@+") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    return (system ? "@android:" : "@") + type.getName() + "/" + mName; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
 
Example 8
Source File: ResourceUsageAnalyzer.java    From bazel with Apache License 2.0 4 votes vote down vote up
private void parseResourceTxtFile(Path rTxt, Set<String> resourcePackages) throws IOException {
  BufferedReader reader = java.nio.file.Files.newBufferedReader(rTxt, UTF_8);
  String line;
  while ((line = reader.readLine()) != null) {
    String[] tokens = line.split(" ");
    ResourceType type = ResourceType.getEnum(tokens[1]);
    for (String resourcePackage : resourcePackages) {
      String owner = resourcePackage.replace('.', '/') + "/R$" + type.getName();
      Pair<ResourceType, Map<String, String>> pair = resourceObfuscation.get(owner);
      if (pair == null) {
        Map<String, String> nameMap = Maps.newHashMap();
        pair = Pair.of(type, nameMap);
      }
      resourceObfuscation.put(owner, pair);
    }
    if (type == ResourceType.STYLEABLE) {
      if (tokens[0].equals("int[]")) {
        ArrayList<Integer> values = new ArrayList<>();
        for (int i = 4; ; ++i) { // skip tokens "int[] identifier = {"
          String token = tokens[i];
          if (token.equals("}")) {
            // empty set?
            break;
          }

          if (token.endsWith(",")) {
            // strip trailing comma
            token = token.substring(0, token.length() - 1);
            values.add(Integer.decode(token));
          } else {
            values.add(Integer.decode(token));
            // no comma means that this is the last value
            break;
          }
        }

        styleableToAttrs.put(tokens[2], values);
        model.addResource(ResourceType.DECLARE_STYLEABLE, tokens[2], null);
      } else {
        // TODO(jongerrish): Implement stripping of styleables.
      }
    } else {
      model.addResource(type, tokens[2], tokens[3]);
    }
  }
}