Have you any idea HOW TO SHOW DIRECTORY LISTING (dirs and files) in WIDGET, BADGE or DYNAMIC TEXT (best with…

Have you any idea HOW TO SHOW DIRECTORY LISTING (dirs and files) in WIDGET, BADGE or DYNAMIC TEXT (best with scrolling)?

WHY? I’m using dirs as simple GTD and I want to see my tasks directly in LL. πŸ˜‰

Can be updated manually or better when target directory changed.

Sorting simple alphabetical, better also switch to sort by date.

Will be also really great to have a “+” button to add new task into showed directory. πŸ˜€

I never tried scripting in LL, but I hope it can be done by LL.

I still have not found any widget that could do this. Do you know anything?

]]>

11 Commentsto Have you any idea HOW TO SHOW DIRECTORY LISTING (dirs and files) in WIDGET, BADGE or DYNAMIC TEXT (best with…

  1. Anonymous says:

    < ![CDATA[

    Sorry if this answer is too late, but I made a quick ‘file manager’ using only LL.



    In case you want to try it, here is the prototype. You need to add a panel and get its id (long tap the panel, the number at the top of the menu).


    You may configure the panel, set it to 1 column and more rows, multiple-line labels, etc. Then create the following script and change the id to the one of your panel. Don’t forget the ‘0x’! (If your panel was #000ab write 0xab) you can change also the default directory.


    Tell me how you want to improve it, and I’ll try.

    ]]>

  2. Anonymous says:

    < ![CDATA[

    var path=”/”;


    var containerId=0x7b;




    //binds


    LL.bindClass(“java.io.File“);


    LL.bindClass(“java.io.FileWriter“);


    LL.bindClass(“android.os.Environment“);


    LL.bindClass(“android.webkit.MimeTypeMap“);



    var event=LL.getEvent();



    var data= event.getData();


    if(data!=null){


    path=data;


    }else{


    path=Environment.getExternalStorageDirectory()+path;


    }




    var files=(new File(path)).listFiles();



    if(files==null){


    Toast.makeText(LL.getContext(),”Error loading folder “+path,Toast.LENGTH_LONG).show();


    return;


    }



    var container=LL.getContainerById(containerId);




    var items=container.getItems();


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


    container.removeItem(items.getAt(t));


    }



    files.sort(sortingFunction);



    for(var t=-1;t< files.length;++t){


    var intent;


    var name;


    var icon;


    if(t==-1){


    intent=intentFromPath((new File(path)).getParent());


    name=”UP”;


    icon=LL.createImage(“android”, “ic_menu_revert”);


    }else if(files[t].isFile()){


    intent=intentFromFile(files[t]);


    name=”File: “+files[t].getName();


    icon=null;


    }else{


    intent=intentFromPath(files[t].getPath());


    name=”Dir: “+files[t].getName();


    icon=LL.createImage(“android”, “ic_menu_archive”);


    }


    var shr=container.addShortcut(name, intent,0,0);


    shr.setCell(0,t+1,1,t+2,true);


    shr.setCustomIcon(icon);


    }



    container.getOpener().getContainer().setPosition(0,0);





    function intentFromPath(path){


    return Intent.parseUri(“#Intent;component=net.pierrox.lightning_launcher_extreme/net.pierrox.lightning_launcher.activities.Dashboard;i.a=35;S.d=”+ LL.getCurrentScript().getId()+”%2F”+path+”;end”,0);


    }





    function intentFromFile(file){


    var intent = new Intent(Intent.ACTION_VIEW);


    intent.setDataAndType(Uri.fromFile(file),getMimeType(file.getName()));


    var j = Intent.createChooser(intent, “Choose an application to open with:”);


    return j;//startActivity(j);


    }




    function getMimeType(url)


    {


    var parts=url.split(“.”);


    var extension=parts[parts.length-1];


    var type = null;


    if (extension != null) {


    var mime = MimeTypeMap.getSingleton();


    type = mime.getMimeTypeFromExtension(extension);


    }


    return type;


    }





    function sortingFunction(a,b){


    if(a.isFile()!=b.isFile()){


    return a.isFile()?1:-1;


    }



    return a.getName().toLowerCase()>b.getName().toLowerCase()?1:-1;


    }

    ]]>

  3. Anonymous says:

    < ![CDATA[

    WOOOOW!!! It works! Thank you very much! πŸ™‚ πŸ™‚ πŸ™‚

    ]]>

  4. Anonymous says:

    < ![CDATA[

    I make some changes and looking for improve. πŸ™‚


    How to add “+” and make new directory?



    BTW, load/refresh of directory with 90 items/directories on external SD card takes about 21 second (Octa Core MT6753 @ 1,3 GHz) which is ehmmm… not so fast. πŸ™‚

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Try this new version. I optimized it and changed how the items are loaded. It should be noticeable faster.


    I also added a create button that creates an empty file from a given name.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    var path=”/”;


    var containerId=0x7b;





    //binds


    LL.bindClass(“java.io.File“);


    LL.bindClass(“java.io.FileWriter“);


    LL.bindClass(“android.os.Environment“);


    LL.bindClass(“android.webkit.MimeTypeMap“);



    var event=LL.getEvent();


    var scriptId=LL.getCurrentScript().getId();



    var path= event.getData() || event.getItem().getTag() || Environment.getExternalStorageDirectory()+path;




    var current=new File(path);



    if(event.getItem().getTag(“create”)!=null){


    var name;


    if((name=prompt(“Name of file:”,””))!=null){


    var newfile=(new File(current,name));


    newfile.createNewFile();


    LL.startActivity(intentFromFile(newfile));


    }else return;


    }else if(current.isFile()){


    LL.startActivity(intentFromFile(current));


    return;


    }




    var files=current.listFiles();



    if(files==null){


    Toast.makeText(LL.getContext(),”Error loading folder “+path,Toast.LENGTH_LONG).show();


    return;


    }



    var container=LL.getContainerById(containerId);




    var items=container.getItems();


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


    container.removeItem(items.getAt(t));


    }



    files.sort(sortingFunction);



    var icon_folder=LL.createImage(“android”, “ic_menu_archive”);


    var intent= Intent.parseUri(“#Intent;component=net.pierrox.lightning_launcher_extreme/net.pierrox.lightning_launcher.activities.Dashboard;i.a=35;S.d=”+scriptId+”;end”,0);



    for(var t=-1;t< files.length+1;++t){



    var shr=container.addShortcut(“”, intent,0,0);


    shr.setCell(0,t+1,1,t+2,true);



    if(t==-1){


    shr.setTag(current.getParent());


    shr.setLabel(“UP”,true);


    shr.setImage(LL.createImage(“android”, “ic_menu_revert”));


    }else if(t==files.length){


    shr.setTag(path);


    shr.setTag(“create”,”1″);


    shr.setLabel(“CREATE”,true);


    shr.setImage(LL.createImage(“android”, “create_contact”));


    }else if(files[t].isFile()){


    shr.setTag(files[t].getPath());


    shr.setLabel(“File: “+files[t].getName(),true);


    }else{


    shr.setTag(files[t].getPath());


    shr.setLabel(“Dir: “+files[t].getName(),true);


    shr.setImage(icon_folder);


    }



    }



    container.getOpener().getContainer().setPosition(0,0);







    function intentFromFile(file){


    var intent = new Intent(Intent.ACTION_VIEW);


    intent.setDataAndType(Uri.fromFile(file),getMimeType(file.getName()));


    var j = Intent.createChooser(intent, “Choose an application to open with:”);


    return j;//startActivity(j);


    }




    function getMimeType(url)


    {


    var parts=url.split(“.”);


    var extension=parts[parts.length-1];


    var type = null;


    var mime = MimeTypeMap.getSingleton();


    if (extension != null) {


    type = mime.getMimeTypeFromExtension(extension);


    }


    return type;


    }





    function sortingFunction(a,b){


    if(a.isFile()!=b.isFile()){


    return a.isFile()?1:-1;


    }



    return a.getName().toLowerCase()>b.getName().toLowerCase()?1:-1;


    }

    ]]>

  7. Anonymous says:

    < ![CDATA[

    TrianguloY​ Thx for update! πŸ™‚ Wow, it is 4x faster! πŸ˜‰ Now I’m looking for just one improve&change – to create empty directory, not a file, and put in on top of list, under “UP”, it is possible please! πŸ™‚

    ]]>

  8. Anonymous says:

    < ![CDATA[

    var path=”/”;


    var containerId=0x7b;





    //binds


    LL.bindClass(“java.io.File“);


    LL.bindClass(“java.io.FileWriter“);


    LL.bindClass(“android.os.Environment“);


    LL.bindClass(“android.webkit.MimeTypeMap“);



    var event=LL.getEvent();


    var scriptId=LL.getCurrentScript().getId();



    var path= event.getData() || event.getItem().getTag() || Environment.getExternalStorageDirectory()+path;




    var current=new File(path);



    if(event.getItem().getTag(“createFile”)!=null){



    var name;


    if((name=prompt(“Name of file:”,””))!=null){


    var newfile=(new File(current,name));


    newfile.createNewFile();


    LL.startActivity(intentFromFile(newfile));


    }else return;



    }else if(event.getItem().getTag(“createDir”)!=null){



    var name;


    if((name=prompt(“Name of dir:”,””))!=null){


    var newfile=(new File(current,name));


    newfile.mkdir();


    current=newfile;


    }else return;



    }else if(current.isFile()){


    LL.startActivity(intentFromFile(current));


    return;


    }




    var files=current.listFiles();



    if(files==null){


    Toast.makeText(LL.getContext(),”Error loading folder “+path,Toast.LENGTH_LONG).show();


    return;


    }



    var container=LL.getContainerById(containerId);




    var items=container.getItems();


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


    container.removeItem(items.getAt(t));


    }



    files.sort(sortingFunction);



    var icon_folder=LL.createImage(“android”, “ic_menu_archive”);


    var intent= Intent.parseUri(“#Intent;component=net.pierrox.lightning_launcher_extreme/net.pierrox.lightning_launcher.activities.Dashboard;i.a=35;S.d=”+scriptId+”;end”,0);



    for(var t=-2;t< files.length+1;++t){



    var shr=container.addShortcut(“”, intent,0,0);


    shr.setCell(0,t+2,1,t+3,true);



    if(t==-2){


    shr.setTag(current.getParent());


    shr.setLabel(“UP”,true);


    shr.setImage(LL.createImage(“android”, “ic_menu_revert”));


    }else if(t==-1){


    shr.setTag(path);


    shr.setTag(“createDir”,”1″);


    shr.setLabel(“CREATE NEW DIR”,true);


    shr.setImage(LL.createImage(“android”, “create_contact”));


    }else if(t==files.length){


    shr.setTag(path);


    shr.setTag(“createFile”,”1″);


    shr.setLabel(“CREATE NEW FILE”,true);


    shr.setImage(LL.createImage(“android”, “create_contact”));


    }else if(files[t].isFile()){


    shr.setTag(files[t].getPath());


    shr.setLabel(“File: “+files[t].getName(),true);


    }else{


    shr.setTag(files[t].getPath());


    shr.setLabel(“Dir: “+files[t].getName(),true);


    shr.setImage(icon_folder);


    }



    }



    container.getOpener().getContainer().setPosition(0,0);







    function intentFromFile(file){


    var intent = new Intent(Intent.ACTION_VIEW);


    intent.setDataAndType(Uri.fromFile(file),getMimeType(file.getName()));


    var j = Intent.createChooser(intent, “Choose an application to open with:”);


    return j;//startActivity(j);


    }




    function getMimeType(url)


    {


    var parts=url.split(“.”);


    var extension=parts[parts.length-1];


    var type = null;


    var mime = MimeTypeMap.getSingleton();


    if (extension != null) {


    type = mime.getMimeTypeFromExtension(extension);


    }


    return type;


    }





    function sortingFunction(a,b){


    if(a.isFile()!=b.isFile()){


    return a.isFile()?1:-1;


    }



    return a.getName().toLowerCase()>b.getName().toLowerCase()?1:-1;


    }

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Easy πŸ™‚

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Thx! It works like a charm! Great solution! K+! πŸ™‚

    ]]>

Leave a Reply

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