Closed JotraN closed 5 years ago
Maybe something worth looking at is the Android Studio templates. I Just created one real quick like this
and you can in the project view just choose the root and select the template. Not as automated as I would like but maybe we can do something with it. Food for thought.
@AlecMedina, that feels slightly weird to me since we only need to generate the above files once per screen. Live templates seem like stuff we'd consistently type a lot.
Would definitely be helpful for tests though (https://medium.com/buffer-engineering/using-live-templates-to-write-tests-8d8041e390d3) - given how often we do the whole Given x, when y, then z
format.
This might be worth taking a look at as well: https://riggaroo.co.za/custom-file-template-group-android-studiointellij/. Having a custom wizard through the Android Studio IDE would be pretty nice. Whatever we implement should be user friendly-ish and I think file > new > MVI (or whatever we want to call it)
and just fill in some details would be pretty nice but I'm unsure about how to scale the distribution of a custom wizard. Making sure everyone gets the same template and in a manner that can be easily updated is still unknown to me.
Also are these multiple files really needed? To me it looks like the sealed classes Action
and Change
, along with the State
class can all be bundled into the ViewModel
file. There is still some repetition but you no longer need to create 5 files for every screen
@curioustechizen thanks for the suggestion! It does make sense to define Action
, Change
and State
in the ViewModel
class for that feature. I can go with either approach.
There are several examples of Android Studio templates on Github that we can review to figure out how to set up our own.
Some good starting points: https://github.com/gabrielemariotti/AndroidStudioTemplate https://github.com/benoitletondor/Android-Studio-MVP-template
Should we include the template in this repo or create a new repo specifically for the template?
Here is another good example https://proandroiddev.com/how-i-automated-creating-files-for-a-new-screen-with-my-own-android-studio-plugin-5d54b14ba6fa. It could be a separate module in this repo or a separate repo. Looking at these examples, there is a lot of code and tests to write and maintain--not sure if there is an immediate need for it.
Apparently, with GitHub you can now create a Template repository which could be useful for a brand new project (not sure how long it's been there). https://help.github.com/en/articles/creating-a-repository-from-a-template
Here is an example repo: https://github.com/square/workflow-android-template
😮 that looks amazing.
I actually got around to implementing android studio templates - just haven't pushed it anywhere yet. I migggggght try to push something for review at some point in my life, but all I did was follow some medium article tutorial 😁.
Essentially just had to create a couple files in AS plugins folder - so if anyone would want to use them, they'd have to copy it over to their folder themselves (this was also another reason why I haven't pushed them yet because I never got around to copying them over to my latest AS installation).
Roxie is pretty lightweight, but I'm also lazy so having to create different files each time I start up a new screen sometimes becomes a bit of copy/paste work from other screens.
Not sure how to go about this (probably just some shell script), but most likely it would generate these initial files for us:
Action
Change
State
ViewModel
ViewModelTest
👍 👍 👍Possibly dagger related jazz too.