Пример #1
0
  protected List<Attr> findAttributes(Node root) {
    List<Attr> result = new ArrayList<Attr>();
    NamedNodeMap attributes = root.getAttributes();
    for (int i = 0, n = attributes.getLength(); i < n; i++) {
      Node attributeNode = attributes.item(i);

      String name = attributeNode.getLocalName();
      if (!name.startsWith(ATTR_LAYOUT_PREFIX)
          && ANDROID_URI.equals(attributeNode.getNamespaceURI())) {
        result.add((Attr) attributeNode);
      }
    }

    return result;
  }
  @Override
  public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) {
    String value = attribute.getValue();
    if (!value.isEmpty() && (value.charAt(0) != '@' && value.charAt(0) != '?')) {
      // Make sure this is really one of the android: attributes
      if (!ANDROID_URI.equals(attribute.getNamespaceURI())) {
        return;
      }

      context.report(
          ISSUE,
          attribute,
          context.getLocation(attribute),
          String.format("[I18N] Hardcoded string \"%1$s\", should use `@string` resource", value));
    }
  }