Hi, would like to validate an approach. Some time ...
# android
g
Hi, would like to validate an approach. Some time ago I asked here about kotlinx synthetic and long view ids. To give you an idea, I happened to work on a project with this frankenstein:

https://i.imgur.com/QzedJhB.png

Possible solutions: 1) don't bother with synthetic 2) get rid of id prefixes, have ids with same names in different layouts and let the android to figure out the context As a proof of concept I decided to workaround with kotlin imports aliases, so I can rename my variables regardless of the actual xml id and here is a small demo of the plugin that helps to automate the process.

https://i.imgur.com/Bdg931e.gif

It's pretty much self-explanatory, the
Generate Synthetic
action is added, that imports ids from layout file with alias that can be edited to your taste. Also, it can be configured to convert underscore to camelCase. Now, the real question is, would it benefit anyone or I'm solving nonexistent problem?)
d
You can use already provided solution but as of kotlin intergration in android naming convention changed on XML files. Long story short: XML id's are now camelCase
You can google for new naming convention
g
doesn't solve the long name problem. People use to prefix xml ids so they don't clash. In my kotlin code I know the context and don't need the prefix. Import alias allows you to have clean short names whilst having long xml ids.
another option would be having similar ids in different xmls. Like you have same
R.id.emailTv
in 3 layouts and android will figure out which one is inflated. Not sure if it still works with latest gradle changes from I/O.