Fix Oreo icons

Fix Oreo icons

This script was created to fix the ‘items without icons on android Oreo’ bug until Pierre implements it.

The script sets the adaptive icons of the shortcuts apps that uses them, unsupported on lighting 14.2b1.

This script ONLY WORKS on android Oreo.

Configuration:

You can change the roundness of the icons changing the ROUNDVAL value on the first line of the script. A value of 0 means no round, aka square. A value of 1 means all round, aka circle. Any value inbetween makes a rounded square. Also, a value of -1 uses the system default shape (whatever that is).

By default 0.35 because I find that good enough.

You can also change the relative size of the inner icon by changing the ZOOM value. A value of 1 means no scale, but the icon is very small. A value of 2 make the icon double size, but it is too big. Any other value correspond to the specified scale.

By default 1.25 because that seems the best size for me.

How to use:

After copying it and paste as a new script in the script editor REMEMBER to enable the lighting menu and item menu categories (swipe from the left). Then you can:

Run from an item to change that item’s icon. If the icon already have a custom icon it will ask to override.

Run from a container to change all item’s icon from that container and subcontainers recursively. It will ask to override custom icons or not.

Run from any other event to change items’s icons from that container recursively without asking for overriding (won’t override). Use this for automation.

If you have any issues write a comment and I’ll try to help. Also if you want to improve the script feel free to do so and share it! A mention is just enough.

]]>

18 Commentsto Fix Oreo icons

  1. Anonymous says:

    < ![CDATA[

    var ROUNDVAL=0.35; //radius of corners. 0 to have square items. 1 to have circle ones. Any inbetween to have rounded squares. -1 for system setting


    var ZOOM=1.25; //zoom of the foreground icon relative to background. 1 for original size (small). 2 for double size (big). Any inbetween for different size.






    bindClass(“android.graphics.drawable.LayerDrawable“);


    var cntx=LL.getContext();


    var ask=false;


    var override=false;



    var event=getEvent();


    var source=event.getSource();



    if(source==”MENU_APP”){


    ask=false;


    override=confirm(“Do you want to override all icons found? Cancel to change only unset ones”);


    fixContainer(event.getContainer());


    }else if(source==”MENU_ITEM”){


    ask=true;


    fixIcon(event.getItem());


    }else{


    fixContainer(event.getContainer());


    }



    function canOverride(){


    if(ask){


    return confirm(“This will override the custom icon. You want to continue?”);


    }else{


    return override;


    }


    }



    function fixContainer(c){


    var items=c.getItems();


    for(var t=0;t< items.getLength();++t){


    var item=items.getAt(t);


    if(item.getType()==”Shortcut”) fixIcon(item);


    if(item.getType()==”Panel”||item.getType()==”Folder”) fixContainer(item.getContainer());


    }


    }



    function fixIcon(i){


    try{


    var icon = cntx.getPackageManager().getApplicationIcon(i.getIntent().getComponent().getPackageName());


    }catch(e){


    return;


    }



    if(icon.class.toString()==”class android.graphics.drawable.AdaptiveIconDrawable” && ( i.getCustomIcon()==null || canOverride())){



    try{


    var layerDrawable = new LayerDrawable([icon.getBackground(),icon.getForeground()]);


    var width = layerDrawable.getIntrinsicWidth()/ZOOM;


    var height = layerDrawable.getIntrinsicHeight()/ZOOM;




    var image=Image.createImage(width,height);


    var canv=image.draw();



    var path = new Path();


    if(ROUNDVAL>=1){


    path.addCircle(width / 2, height/ 2, Math.min(width/2, height / 2), Path.Direction.CCW);


    }else if(ROUNDVAL>=0){


    path.addRoundRect(0,0,width,height,width*ROUNDVAL/2,height*ROUNDVAL/2,Path.Direction.CCW)


    }else{


    var matrix=new Matrix();


    matrix.setScale(width/100,height/100);


    path=icon.getIconMask()


    path.transform(matrix);


    }


    canv.clipPath(path);



    layerDrawable.setBounds(-width*(ZOOM-1)/ZOOM, -height*(ZOOM-1)/ZOOM, width*(2*ZOOM-1)/ZOOM, height*(2*ZOOM-1)/ZOOM);


    layerDrawable.draw(canv);



    i.setDefaultIcon(image);


    //Android.makeNewToast(“icon changed: “+i,true).show();


    }catch(e){


    Android.makeNewToast(“error on icon: “+i,true).show();


    alert(e)


    }


    }


    }

    ]]>

  2. Anonymous says:

    < ![CDATA[

    im not on oreo but this is awesome 👍

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Really 😎👐

    ]]>

  4. Anonymous says:

    < ![CDATA[

    TrianguloY Worked like a charm!

    ]]>

  5. Anonymous says:

    < ![CDATA[

    TrianguloY Thank you! It works. #Nexus6P

    ]]>

  6. Anonymous says:

    < ![CDATA[

    This almost works. The background ends up #fff instead of transparent, and that background takes up some of the space that the icon should.


    https://lh3.googleusercontent.com/1MFgf9m0PvZf1JOdqcQqnwoa7Mqs0Yz18pJh8HN5w62LQLDtcGqNeTwbzGbKBpJOpoWDpkoEInE

    ]]>

  7. Anonymous says:

    < ![CDATA[

    Bearcat Şándor on your screenshot, what is the icon/icons that are incorrectly set? I didn’t check the exact icon drawables, are you sure they are transparent instead of opaque?

    ]]>

  8. Anonymous says:

    < ![CDATA[

    Yes. Look at the Google cloud icon on the lower right (not in the bar). They’re all like that.

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Oreo icons consist on two layers: a background (normally a color) and a foreground. That background color isn’t transparent, it is an opaque color. Go to the stock launcher and you will see the same.


    The ‘issue’ is that the script only fixes the broken icons, and doesn’t change the others. Stock launcher adds a custom background color to all icons.

    ]]>

  10. Anonymous says:

    < ![CDATA[

    TrianguloY Now i am hopeful to find a way to switch background to transparent… It can be possible? I don’t like background around icons, i think it is outdated style.:(

    ]]>

  11. Anonymous says:

    < ![CDATA[

    You can change this line:



    var layerDrawable = new LayerDrawable([icon.getBackground(),icon.getForeground()]);



    And replace it with this one:



    var layerDrawable = new LayerDrawable([icon.getForeground()]);



    But I warn you: icons will have a strange shadow in the corner, and even some icons will lost details (try maps and calculator for example)

    ]]>

  12. Anonymous says:

    < ![CDATA[

    TrianguloY Thank you!!! I think maps and some other icon kept its circle shape (keep), so whatever :).

    ]]>

  13. Anonymous says:

    < ![CDATA[

    Stupid question: how do I run the script?

    ]]>

  14. Anonymous says:

    < ![CDATA[

    Jon Haugen Long tap on icon / Scripts… / [fix_oreo_script or whatever you named]

    ]]>

  15. Anonymous says:

    < ![CDATA[

    TrianguloY​ possible to run on Resumed event of the Drawer, right ?

    ]]>

  16. Anonymous says:

    < ![CDATA[

    Yes, but may lag the drawer opening. Just try it.

    ]]>

  17. Anonymous says:

    < ![CDATA[

    TrianguloY​ just trying to help on the user community and checking here

    ]]>

  18. Anonymous says:

    < ![CDATA[

    Thanks. Works as it should and fixes the icon problems I had for quite some while.

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *