slackhq / slack-lints

A collection of custom Android/Kotlin lint checks we use in our Android and Kotlin code bases at Slack.
Apache License 2.0
218 stars 10 forks source link

View#clearOnClickListener() does not actually exist? #267

Closed edenman closed 2 months ago

edenman commented 2 months ago

This fails to also set View#isClickable. Use View#clearOnClickListener() instead

https://github.com/slackhq/slack-lints/blob/main/slack-lint-checks/src/main/java/slack/lint/denylistedapis/DenyListedApiDetector.kt#L301

Is this some internal thing that leaked out?

ZacSweers commented 2 months ago

heh, it is. It's this

/** Clears the current click listener and sets `isClickable` to false. */
@SuppressLint("DenyListedApi") // This is the one place we allow it
fun View.clearOnClickListener() {
  setOnClickListener(null)
  isClickable = false
}

/** Clears the current long click listener and sets `isLongClickable` to false. */
@SuppressLint("DenyListedApi") // This is the one place we allow it
fun View.clearOnLongClickListener() {
  setOnLongClickListener(null)
  isLongClickable = false
}
edenman commented 2 months ago

Another internal thing that leaked is #plz-localization 😂 https://github.com/slackhq/slack-lints/blob/b90f36da013953656f88ecbf163d8021082bcae8/slack-lint-checks/src/main/java/slack/lint/ArgInFormattedQuantityStringResDetector.kt#L32