misakuo / svgtoandroid

Converting SVG to VectorDrawable
https://plugins.jetbrains.com/plugin/8103
MIT License
528 stars 45 forks source link

Select target dependency configuration (Android studio scope) #20

Open igorwojda opened 7 years ago

igorwojda commented 7 years ago

Now all assets go to default scope (main dependency configuration), but sometimes we want to add new resource to other configuration e.g change logo/icons when rebranding app.

It would be nice to have combibox containing list of all avialable configurations to select target of generated resource

misakuo commented 7 years ago

Uhhh...could you provide some examples to explain it? I do not quite understand what you mean

igorwojda commented 7 years ago

Sure, so basically there are different product favours inside android application (product flavour is used to create different branding e.g. different logo or free/paid versions - basically the same app but with few differences in behaviour or appearance)

By default you put all the resources into (this is what this plugin does) \app\src\main\res\drawable\logo.xml

You can place the resources also in different product flavours folders, build variant folders or built type folders. This basically means that when you building app the resource from \app\src\main\res\drawable is used, but when you are building free product flavour resource from this flavour will override resource from main resulting in having free logo in the app.

Product flavour are combined with build types:

build variant = product flavour + built type
e.g. freeDebug = free + Debug

Example: Assume we have 2 product flavours: free & paid Assume we have 2 build types: Release & Debug

We can have multiple locations for our logo based on:

  1. Build type

    \app\src\main\res\drawable\logo.xml (this is default name for mainRelease)
    \app\src\debug\res\drawable\logo.xml
    \app\src\release\res\drawable\logo.xml
  2. Product flavour

    \app\src\free\res\drawable\logo.xml
    \app\src\paid\res\drawable\logo.xml
  3. Build variant = product flavour + built type

    \app\src\freeDebug\res\drawable\logo.xml
    \app\src\freeRelease\res\drawable\logo.xml
    \app\src\paidDebug\res\drawable\logo.xml
    \app\src\paidRelease\res\drawable\logo.xml

I believe the best thing to address this problem would be to add ComboBox Build type containing list of all buildtypes avialable in the project (attach). Also we woudl change 'XML to' to 'Module name'

https://drive.google.com/file/d/0B4hXruznbpCVOXZhd1BibThMbEk/view

Here is a example updating icon http://blog.brainattica.com/how-to-work-with-flavours-on-android/

Android build variants https://developer.android.com/studio/build/build-variants.html

Feel free to ask if you need more explanation.

misakuo commented 7 years ago

Yes, I understand, it is build variants.
So, I only need to list of all subdirectories for src directory on each module? if I have a project like img

I need to list the androidTest, debug, main, test to allow user to choose, is it?

igorwojda commented 7 years ago

Generally yes although I am not sure if there is a point of adding resources to 'test' folders, so I am 90% sure they should not be on the list.

Also keep in mind that there may be case where folder for particular build type does not exist although build type actually exists, so if you want to handle this you should get full of product flavours from build.gradle and generate proper build types (folder names) + add default ones (main, debug, release) (mabye we should have 'show only existing folders' checkbox)

productFlavors {
        free {
        }
        main {
        }
    }