Skip to content

Instantly share code, notes, and snippets.

@saurabharora90
Last active July 29, 2019 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saurabharora90/69f6b7a5ee2fdef07c1bd6f682541382 to your computer and use it in GitHub Desktop.
Save saurabharora90/69f6b7a5ee2fdef07c1bd6f682541382 to your computer and use it in GitHub Desktop.
Dark Theme Lint Checks
private const val BACKGROUND = "background"
private const val FOREGROUND = "foreground"
private const val SRC = "src"
private const val TEXT_COLOR = "textColor"
private const val TINT = "tint"
//Vector Drawables.
private const val FILL_COLOR = "fillColor"
private const val STROKE_COLOR = "strokeColor"
private const val COLOR = "color"
class DirectColorUseDetector : ResourceXmlDetector() {
override fun getApplicableAttributes(): Collection<String>? {
return listOf(BACKGROUND, FOREGROUND, SRC, TEXT_COLOR, TINT,
FILL_COLOR, STROKE_COLOR, COLOR)
}
override fun visitAttribute(context: XmlContext, attribute: Attr) {
if(attribute.value.startsWith("#")) {
context.report(
DirectColorUseIssue.ISSUE,
context.getLocation(attribute),
DirectColorUseIssue.EXPLANATION)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment