Last active
July 29, 2019 16:25
-
-
Save saurabharora90/69f6b7a5ee2fdef07c1bd6f682541382 to your computer and use it in GitHub Desktop.
Dark Theme Lint Checks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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