android / android-studio-poet

Large Android projects generator
Apache License 2.0
702 stars 85 forks source link

Generate Android library modules with resources #11

Closed borisf closed 6 years ago

borisf commented 6 years ago

Generate Android library module with Android resources, while controlling programatically:

Strings, layouts, manifest, images

Several approaches:

  1. Easy, Duplicating the basic elements
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme1" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

Can be easily cut of by the toolchain

  1. More challenging, making sure that all the generated elements are get called, need to keep a model of everything in the project, loses simplicity
borisf commented 6 years ago
  1. Pull sufficiently interesting modules from github. Requires some kind of analysis over github. Here is how to do it https://stackoverflow.com/questions/33066582/how-to-download-a-folder-from-github
borisf commented 6 years ago

Compromise between the first and the second ways, is to have one configurable number of activities == results in same number of auto generated layouts ==> same number of auto generated say text views inside a layout.

Thus we add one number to UI, that results in all project generation

borisf commented 6 years ago

@NikitaKozlov

NikitaKozlov commented 6 years ago

Yeah, let's go for a mix. If we can generate activity with recycler view that has an adjustable number of types, then we can have as many different ViewHolders (aka layouts) as we want. To call all strings/images we will reference them from the layout. Generating images would be a bit trickier, although we can do both, jpeg generation and vector generation.

borisf commented 6 years ago

Generating images shouldn't be difficult, either we take one image and reuse it by different names or use BufferedImage API (https://docs.oracle.com/javase/tutorial/2d/images/drawonimage.html)

borisf commented 6 years ago

Fixed - https://github.com/borisf/java-generator/commit/eaab426faaafe538a0ec7f18f4acdca255351480