/** * Returns true if the given element should be an empty tag * * @param element the element to test * @return true if this element should be an empty tag */ @SuppressWarnings("MethodMayBeStatic") // Intentionally instance method so it can be overridden protected boolean isEmptyTag(Element element) { if (element.getFirstChild() != null) { return false; } String tag = element.getTagName(); if (TAG_STRING.equals(tag)) { return false; } return true; }
private boolean isMarkupElement(Element element) { // The documentation suggests that the allowed tags are <u>, <b> and <i>: // developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling // However, the full set of tags accepted by Html.fromHtml is much larger. Therefore, // instead consider *any* element nested inside a <string> definition to be a markup // element. See frameworks/base/core/java/android/text/Html.java and look for // HtmlToSpannedConverter#handleStartTag. if (mStyle != XmlFormatStyle.RESOURCE) { return false; } Node curr = element.getParentNode(); while (curr != null) { if (TAG_STRING.equals(curr.getNodeName())) { return true; } curr = curr.getParentNode(); } return false; }