In IntelliJ-based IDEs like Android Studio, in Java source codes, there is an option to extract things as constants when possible (final static
). It is in Refactor -> Extract -> Constant
and is accessible via Ctrl+Alt+C.
But I can't find it for Kotlin source codes!
Note 1: I can do it manually as you can see about NUMBER
in the above screenshot (by defining it as a const val
in companion object
).
Note 2: The reverse-action is accomplishable by IDE; it means you can inline NUMBER
with Ctrl+Alt+N.
Unfortunately, this is a known missing feature for now. It's being tracked on the official issue tracker. You can vote for it there =)