avocado icon indicating copy to clipboard operation
avocado copied to clipboard

Avocado removes @string paths

Open FrancoisBlavoet opened this issue 7 years ago • 3 comments

I ran Avocado on this xml :

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:width="108dp"
        android:height="108dp"
        android:viewportHeight="108.0"
        android:viewportWidth="108.0">
    <group
        android:translateX="23"
        android:translateY="23">
        <path
            android:fillColor="#2A7618"
            android:fillType="nonZero"
            android:pathData="@string/ic__core_path_carrot"
            tools:targetApi="n"/>
        <path
            android:fillColor="#2A7618"
            android:fillType="nonZero"
            android:pathData="@string/ic__core_path_carrot_leaves"
            tools:targetApi="n"/>
    </group>
</vector>

Here is the output I got :

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="108dp"
        android:height="108dp"
        android:viewportHeight="108.0"
        android:viewportWidth="108.0"/>

In all fairness, it is smaller, but I did lose a bit of info there :p

FrancoisBlavoet avatar Jan 22 '18 23:01 FrancoisBlavoet

Oops, good catch. The tool doesn't know how to optimize string resources yet, but until then it should just ignore them instead of deleting them entirely.

alexjlockwood avatar Jan 23 '18 00:01 alexjlockwood

haha, no pb I just wanted to see if it was going to bake this translation into the path for me and it does 🎉 (as long as it is not a string reference anyway, but that's fair)

FrancoisBlavoet avatar Jan 23 '18 00:01 FrancoisBlavoet

For future reference, I need to update the regex string in the removeHiddenElems plugin to detect string resources: https://github.com/alexjlockwood/avocado/blob/master/src/plugins/removeHiddenElems.ts#L4

I also need to update the mergePaths plugin so that it doesn't attempt to concatenate paths that reference string resources: https://github.com/alexjlockwood/avocado/blob/master/src/plugins/mergePaths.ts

Probably worth double checking the convertPathData plugin as well to make sure it isn't making any assumptions about the validity of the path data attribute value: https://github.com/alexjlockwood/avocado/blob/master/src/plugins/convertPathData.ts

alexjlockwood avatar Jan 23 '18 01:01 alexjlockwood