Excuse me…. Can we make toogle with LLX script? something like vibrateSilent-Ring toogle? < SOLVED >

Excuse me…. Can we make toogle with LLX script? something like vibrateSilent-Ring toogle? < SOLVED >

#toogle  

]]>

19 Commentsto Excuse me…. Can we make toogle with LLX script? something like vibrateSilent-Ring toogle? < SOLVED >

  1. Anonymous says:

    < ![CDATA[

    LL.bindClass(“android.media.AudioManager”);


    LL.bindClass(“android.app.AlertDialog”);


    LL.bindClass(“android.content.DialogInterface”);



    var state = LL.getContext().getSystemService(LL.getContext().AUDIO_SERVICE);



    var adb = new AlertDialog.Builder(LL.getContext());


    adb.setTitle(“Profile”);


    adb.setCancelable(true);


    adb.setNegativeButton(“Silent”, new DialogInterface.OnClickListener(){


    onClick:function(Dialog, id){


    state.setRingerMode(AudioManager.RINGER_MODE_SILENT);


    Android.makeNewToast(“Profile changed to Silent/Vibrate”, true).show();


    }


    });



    adb.setPositiveButton(“Loud”, new DialogInterface.OnClickListener(){


    onClick:function(Dialog, id){


    state.setRingerMode(AudioManager.RINGER_MODE_NORMAL);


    Android.makeNewToast(“Profile changed to Loud”, true).show();


    }



    });




    var a = adb.create();


    adb.show();

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Thank you Jay M , I’ll try it 🙂

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Jay M​ It’s not “a.show()” at the end?

    ]]>

  4. Anonymous says:

    < ![CDATA[

    Whoops never noticed that nice catch, it still works though for some reason :/

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Cool it works with adb.show(); or a.show();



    I also disabled every bindClass statement and it still works.



    I gotta feeling it might cause problems after a reboot though 🙂



    Abednego JS​ change the last line to a.show();

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Jay M , I tried the script.. That show alert dialog to choose between LOUD and SILENT, but what I need is toogle (press to make phone SilentVibrate and press again to make phone RING / LOUD)



    With Tasker I do something like this:


    If ( %var_sound = 1)


    then


    {


      if ( %VOLUME > 0);


      then VIBRATE;


       %var_sound to 0;


    }


    else


    {


     if ( %SILENT isSet )


     then unset SILENT;


     %var_sound to 1;


    }



    How build toogle with pure LLX script?

    ]]>

  7. Anonymous says:

    < ![CDATA[

    Press silent again it should switch to vibrate.



    I was gunna use 3 buttons Silent/Vibrate/Loud but when I got the mode it was telling me that vibrate and silent were both 0 and that loud was 2 so I couldn’t do anything.



    On lolipop

    ]]>

  8. Anonymous says:

    < ![CDATA[

    Yeah I actually wrote this for myself I flashed CM12 and there was no profiles toggle in the powermenu and I need them and I really like AlertDialogs for some reason.

    ]]>

  9. Anonymous says:

    < ![CDATA[

    all LL.bindClass are needed only once ! then they are loaded in the js environnement.. In fact you only need to import them when LLX starts !! I tried to do a “class” loading system, but I don’t have time towork on…

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Jay M that’s really cool! You should add it the script repository.

    ]]>

  11. Anonymous says:

    < ![CDATA[

    Aye could do, cheers 🙂

    ]]>

  12. Anonymous says:

    < ![CDATA[

    Then Jay M what I learn from your script is I need these to make toogle widget VIBRATE-RING:



    LL.bindClass(“android.media.AudioManager”);



    var state = LL.getContext().getSystemService(LL.getContext().AUDIO_SERVICE);



    state.setRingerMode(AudioManager.RINGER_MODE_SILENT);


    Android.makeNewToast(“Profile changed to Silent/Vibrate”, true).show();



    state.setRingerMode(AudioManager.RINGER_MODE_NORMAL);


    Android.makeNewToast(“Profile changed to Loud”, true).show();



    Now…. how to make the toogle?


    😀



    if (RINGER_MODE_NORMAL) // How to get system audio status?


    then state.setRingerMode(AudioManager.RINGER_MODE_SILENT);


    else state.setRingerMode(AudioManager.RINGER_MODE_NORMAL);

    ]]>

  13. Anonymous says:

    < ![CDATA[

    IIRC to get the status i used var status = state.getRingerMode();



    But like i said it was telling me that loud was 2 and vibrate and silent were both 0, but tbh I could of just did it wrong my skills/knowledge are very limited and I still find the Android documentation hard to understand.

    ]]>

  14. Anonymous says:

    < ![CDATA[

    I see android documentation and find:



    public static final int RINGER_MODE_VIBRATE


    Ringer mode that will be silent and will vibrate. (This will cause the phone ringer to always vibrate, but the notification vibrate to only vibrate if set.)


     Constant Value: 1 (0x00000001)



    How about that? Constant value for VIBRATE is 1?



    So the script will be:



    LL.bindClass(“android.media.AudioManager”);



    var state = LL.getContext().getSystemService(LL.getContext().AUDIO_SERVICE);


    var ac = state.getRingerMode();



    if (ac = 2) // Is this right for checking phone audio’s state?


    {


       state.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);


    }


    else


    {


       state.setRingerMode(AudioManager.RINGER_MODE_NORMAL);


    }

    ]]>

  15. Anonymous says:

    < ![CDATA[

    Try it, if it doesn’t work I’ll have another go at it when i wake up. Its 9am here and I ain’t been to sleep yet :/

    ]]>

  16. Anonymous says:

    < ![CDATA[

    It’s WORKING!


    XD



    Thank you very much for your script Jay M I just adjust it to be more simple as I need, toogle to switch between “silent vibrate” to “normal” fixed.



    My previous script have wrong if statement, this is the right script for VIBRATE-RING TOOGLE:



    LL.bindClass(“android.media.AudioManager”);



    var state = LL.getContext().getSystemService(LL.getContext().AUDIO_SERVICE);


    var ac = state.getRingerMode();



    if (ac == 2)


    {


     state.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);


    }


    else


    {


     state.setRingerMode(AudioManager.RINGER_MODE_NORMAL);


    }

    ]]>

  17. Anonymous says:

    < ![CDATA[

    Nice 🙂 glad it was helpfull yeah I see what happened you used if (ac = 2 ) and it should be if (ac == 2)

    ]]>

  18. Anonymous says:

    < ![CDATA[

    Well I tried adding this to the wiki but the instructions confused me so it’s not happening lol.



    Unless someone else wants to add it. I don’t need credit for it just wanna share it and as a bonus having it there in the wiki means I’ll never lose it, i lost my Quick Note script twice now 🙁 free storage FTW 😉

    ]]>

  19. Anonymous says:

    < ![CDATA[

    Ugh, so LL have “Script Repository” and Wiki too


    But I also didn’t know how to fill it… lol


    XD

    ]]>

Leave a Reply

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