Would a `Contract` for deprecation be a good idea?...
# android
s
Would a
Contract
for deprecation be a good idea? Take
Html.fromHtml
for example, even though we have
HtmlCompat
we wont have to go and create a
XxxCompat
for everyone if something like this was possible. Consider this snippet:
Copy code
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                Html.fromHtml(contactToDisplay, Html.FROM_HTML_MODE_LEGACY)
            } else {
                @Suppress("DEPRECATION") // maybe we can do something to avoid this? 
                Html.fromHtml(contactToDisplay)
            }
If we could wrap this in a contract maybe, plus android SDKs mostly have when a particular api was deprecated, even though below a particular SDK level, it was completely fine using it. Also, looking at a bigger picture we could maybe not just use primal checks like
implies x != null
there could be some other annotation with retention policy of runtime or something and maybe we could do
implies x is NotDeprecated::class.java
or something. Just a thought.
s
Like I mentioned, there's a htmlcompat, but wouldn't this be a good addition? Even for writing those compat classes?
i
it is up to Google to create those Compat Classes. eventually, SDK classes get less while AndroidX will grow by 200% more