There is always a way!

There is always a way!

Update of my last script: customize menu

Now with:

– Changing the selection color

– Hiding specific elements

]]>

18 Commentsto There is always a way!

  1. Anonymous says:

    < ![CDATA[

    //config


    var color=0xFF707070;


    var selectionColor=0xFF202020;


    var hide=[“Android settings”];


    //endconfig



    LL.bindClass(“android.R”);


    LL.bindClass(“android.view.ViewGroup”);


    LL.bindClass(“android.graphics.PorterDuff”);


    LL.bindClass(“android.view.ViewTreeObserver”);


    LL.bindClass(“android.graphics.drawable.ColorDrawable”);


    LL.bindClass(“android.graphics.drawable.StateListDrawable”);


    LL.bindClass(“android.util.StateSet”);




    var menuRoot=LL.getContext().getWindow().getDecorView().findViewById(R.id.content).getChildAt(0).getChildAt(2).getChildAt(2);


    var menu = menuRoot.getChildAt(0);


    var triangleDown = menuRoot.getChildAt(1);


    var triangleUp = menuRoot.getChildAt(2);



    menu.setBackgroundColor(0xFF707070);



    var tDown=LL.createImage(40,20);


    var c=tDown.draw();


    var path=new Path();


    path.moveTo(0,0);


    path.lineTo(20,20);


    path.lineTo(40,0);


    path.lineTo(0,0);


    path.close();


    var paint = new Paint();


    paint.setColor(color); paint.setStyle(Paint.Style.FILL_AND_STROKE);


    paint.setAntiAlias(true);


    c.drawPath(path,paint);



    triangleDown.setImageBitmap(tDown.getBitmap());



    var tUp=LL.createImage(40,20);


    var c=tUp.draw();


    var path=new Path();


    path.moveTo(0,20);


    path.lineTo(20,0);


    path.lineTo(40,20);


    path.lineTo(0,20);


    path.close();


    c.drawPath(path,paint);



    triangleUp.setImageBitmap(tUp.getBitmap());



    var obs=menuRoot.getViewTreeObserver();


    obs.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener(){


    onGlobalLayout:function()


    {


    var list=menu.getChildAt(0);


    for(var i=0;i


    var item=list.getChildAt(i);


    if(hide.indexOf(item.getText())!=-1){


    list.removeView(item);


    continue;


    }


    var drawable= new StateListDrawable();


    drawable.addState([R.attr.state_pressed],new ColorDrawable(selectionColor)); drawable.addState(StateSet.WILD_CARD,new ColorDrawable(0x00000000));


    item.setBackground(drawable);


    }


    return true;


    }


    });

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Wow


    So we are able to hide : Add item


    And edit layout



    Could we hide 2 elements ?



    Are you able to check if Lock mode is on ?

    ]]>

  3. Anonymous says:

    < ![CDATA[

    The hidden variable is an array. You can add more than one: [“Add item”,”edit Layout”]



    Be careful and check for case. It has to be exactly the displayed text.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    Yes, you could check for lock mode. You’d have to modify the onGlobalLayout function to achieve that

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Now that you can remove items… Can you add new ones?

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Ren Shore of course. Shouldn’t be hard anymore

    ]]>

  7. Anonymous says:

    < ![CDATA[

    Ren Shore good idea but how to set a function behind the new option ?


    Lukas Morawietz​ could you help me to find if we are on lock mode ? I don’t understand the onGlobalLayout

    ]]>

  8. Anonymous says:

    < ![CDATA[

    I’d imagine a function something like addChild(“title”,intent());



    (Made that up)

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Bruno-Isa LAMOUR-ARNOULD change



    if(hide.indexOf(item.getText())!=-1){



    To



    if(hide.indexOf(item.getText())!=-1&&LL.isLocked()){

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Ah, ah, ah! Good! I like when people know how to dig always deeper and read documentation!

    ]]>

  11. Anonymous says:

    < ![CDATA[

    Pierre Hébert actually most of what I read for this was stackoverflow 😁

    ]]>

  12. Anonymous says:

    < ![CDATA[

    I love/hate SO some of the people are goons though closing questions saying its unclear what people are asking when its actually crystal clear. Here’s an example.



    http://stackoverflow.com/questions/20943407/create-an-android-lock-screen



    Unless your stevie wonder its very clear what hes asking. Straight away you can see hes not lazy he mentions he’s done some research and that hes even found example code and tested it, but found its not working the way he thought it would, so now he’s asking for help, which is what SO is for right? I mean a lockscreen dev could read his post and say hi I’m the dev of xxxx lock screen I can help you. then he might share a sample project, give him a few tips, or just link him to some info he found usefull when developing his lockscreen.



    Is it just me that feels this way or am I missing something I see this a lot on that website and based on the comments from people trying to help its obviously clear to them what the OP is asking so why say its unclear :/

    ]]>

  13. Anonymous says:

    < ![CDATA[

    Jay M I don’t understand… to what are you referring?

    ]]>

  14. Anonymous says:

    < ![CDATA[

    Im just on about some of the people at Stackoverflow closing questions I think are actually very clear, don’t worry about it just needed to voice my opinion lol. nice work on the script btw works great.

    ]]>

  15. Anonymous says:

    < ![CDATA[

    Jay M ah you were talkin about stackoverflow… thought you mean sth in this community…

    ]]>

  16. Anonymous says:

    < ![CDATA[

    Yeah Stackoverflow, na this community’s great

    ]]>

  17. Anonymous says:

    < ![CDATA[

    Jay M regarding this specific question, I guess that nobody answer because of two reasons:


    – there are several non compatible ways to implement a lock screen


    – all of these implementations are no more than a stack of ugly hacks


    (And believe me, I know what I am talking about, lol!)



    SO is nevertheless one of the tool without which a developer cannot live anymore.

    ]]>

  18. Anonymous says:

    < ![CDATA[

    Quite a few people answered just about 7 people voted it to be closed because they said it was unclear what was being asked.

    ]]>

Leave a Reply

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