TrianguloY
now browsing by tag
Pierre Hébert: we have setTimeout…but what about clearTimeout? Is it possible to add?
From another post:
Pierre Hébert, when you run a script from the position changed event…what return event.getTouchX and getTouchScreenX? (and Y)
Not the finger position…The container position? My tests says no but…
]]>Customizable Wheel of items
Customizable Wheel of items
First Bogdan Tautu wrote the script to put shortcuts in a circle, then he improved it to make a rotating one (availables in the wiki)…I decided to go a bit far modifying it. This is a customizable wheel of items. It can be improved more, but I think this is enough.
This script will use all the items in the container, that’s why I recommend to use a panel.
Challenge to scripters: can you imagine how I made to rotate the items relative to the wheel (so they always look to the center) without looking at the script?
Settings:
– X position: -1 left ; 0 center ; 1 right
– Y position: -1 bottom ; 0 center ; 1 top
– Rotation: the rotation the items will have relative to itself (recommended 0 or 180)
– Sensitivity: the velocity of rotating (the more, the faster)
Instructions:
– copy paste the script.
set it in the ‘position changed’ of the panel (or desktop).
– IMPORTANT: pin the items, and detach them from the grid.
– In the panel settings, check the ‘no scroll limit’ under scroll options.
– Wheeeeeeeel
Of course you can ask in the comments any problem you could have.
—————————————–
/*Config: */
var h = -1; //horizontal alignment (-1 , 0 , 1 )
var v = 0; //vertical alignment ( -1 , 0 , 1 )
var r = 0; //rotation offset ( 0 = default) in angles, not very implemented (0 or 180 recommended)
var f = 2; //sensitivity
var event = LL.getEvent();
var desktop = event.getContainer();
var a = desktop.getItems();
var na = a.getLength();
var radius = Math.min( desktop.getHeight()/ (v==0?4:2) , desktop.getWidth()/ (h==0?4:2) );
var alt = 0.5;
var size = [ radius*(2-alt)*Math.PI/na , radius*2 ];
var desf = (desktop.getPositionX()*(v>0?-1:1)+desktop.getPositionY() *(h>0?-1:1) )*Math.PI/desktop.getWidth();
desf*=f;
for ( var i=0; i var angle = Math.PI*2*i/na-desf; var x = Math.cos( angle -Math.PI/2 ) * radius; var y = Math.sin( angle -Math.PI/2 ) * radius; var rot = angle*180/Math.PI+r; x+= (h<0? 0 : desktop.getWidth()/ (h==0? 2 : 1) ) ; y+= (v>0? 0 : desktop.getHeight()/ (v==0? 2 : 1) ); x-= size[0]/2; y-= size[1]/2; var t = a.getAt(i); t.setRotation(0); t.setSize(size[0] ,size[1]); t.setPosition(x, y); t.setRotation(rot); }
The autocompletion popup is bigger, good.
The autocompletion popup is bigger, good.
But…how about an intermediate size? Maybe at the right, no full width.
]]>Pierre Hébert: container.getType() returns e,d instead of desktop, container…you should check the obfuscate part :P
Just two little things:
Just two little things:
-In the editor, don’t know others but the popup with the suggestions is almost invisible. ( at the top the screen, yes that) It is shown well when I swipe down from it.
-Now we have the line where errors happens…how about make numbered lines in the editor?
]]>Tree info
Well, you can’t click anywere, just see the tree of items, their name (or type) and the id.
Hey, I made this in 30 minutes. Not bad 😀
Just run it from where you want. By default it will also replace the output log with the information. comment the bottom line to avoid this (add // at the beginning of the sentence)
WARNING: If you have a loooooot of items it could crash, but I’m almost sure you don’t have as much as I have. 😉
————————–
var str = “List:”;
var str2 = “”;
function addToStr(cont,h){
var items=cont.getItems();
var l = items.getLength();
for(var i = 0;i var item = items.getAt(i); var type = item.getType(); str+=h+ ( type==”Shortcut” || type == “Folder” ? item.getLabel() : “{“+type+”}” ) ; if( item.getType()==”Panel” || item.getType()==”Folder” ) { str+=”¦ Id:” + item.getId() + “\n”; addToStr(item.getContainer() , h+” ¦”); }else{str+=” Id:”+ item.getId() + “\n”;} } } var desktops = LL.getAllDesktops(); var len = desktops.getLength(); for(var j = 0 ; j var desktop = LL.getContainerById(desktops.getAt(j)); str+=”\n”+desktop.getName()+” Id:” + desktop.getId() + “\n”; addToStr(desktop , ” ¦” ); str2+=str; str=””; } var appdrawer = LL.getContainerById(99); str+=”\nApp drawer Id:99\n”; addToStr( appdrawer , ” ¦” ); LL.writeToLogFile(str2+str, true ); //this will add the string to a file, true to clear before, false to append alert(str2+str); //this will display the tree in one popup (alert)
Find items script
This script will go through all the items in the container were it was launched. It will show basic info about it, and the item will be in the topleft corner. ( then a zoom out will shows you where it is)
Also, the script automatically make the items with Alpha 255, the frontmost and will unpin it. To keep these modifications (in case the item was lost somewere) stop the script from the popup. If not, the original settings will go back.
(to sum up: in the “continue?” popup, Yes->no changes; No->changes and stop)
Any suggestions about more info to show, or changes to make are welcomed. Feel free to comment.
Instructions: Just copy\paste and run.
—————————————
var desk=LL.getEvent().getContainer();
var px = desk.getPositionX();
var py = desk.getPositionY();
var ps = desk.getPositionScale();
var items=desk.getItems();
for(var i=items.getLength()-1;i>=0;–i){
var item = items.getAt(i);
var data = [];
data[0] = item.getProperties().getInteger(“i.alpha”);
data[1] = item.getProperties().getString(“i.pinMode”);
data[2] = desk.getItemZIndex( item.getId() );
desk.setItemZIndex(item.getId() , 100000);
item.getProperties().edit().
setInteger( “i.alpha” , 255).
setString(“i.pinMode”,”NONE”).
commit();
var zoom = Math.min( desk.getWidth() / item.getScaleX() / item.getWidth(), desk.getHeight() / item.getScaleY() / item.getHeight());
desk.setPosition( item.getPositionX() , item.getPositionY() , zoom,true );
var type = item.getType();
var info = “Item found:”;
info+=”\n-Type: “+ type;
if(type==”Shortcut” || type==”Folder”) info+=”\n-Label: “+item.getLabel();
info+=”\n-Id: “+item.getId();
info+=”\n-Pin Mode: “+data[1];
info+=”\n-Alpha: “+data[0];
info+=”\n-Tag: “+item.getTag();
info+=”\n-Visibility: “+item.isVisible();
info+=”\n-Z Index: “+data[2];
alert(info);
var n = 3;//zoom out
desk.setPosition( item.getPositionX()-desk.getWidth()/zoom*(n-1)/2,item.getPositionY()-desk.getHeight()/zoom*(n-1)/2,zoom/n,true );
if( !confirm(“Continue? (If not, Zindex,alpha and PinMode won’t get back)”) )return;
desk.setItemZIndex(item.getId() , data[2]);
item.getProperties().edit().
setInteger( “i.alpha” , data[0]).
setString(“i.pinMode”, data[1]).
commit();
}
desk.setPosition(px,py,ps,true);
Android.makeNewToast(“no more items found”,false).show();
]]>For some reason, when I change the size of an item(in free mode) from a script, it is not updated until I go to edit…
Launch item with password
Keep in mind it’s very easy to break this lock, just launching the item from another gesture, change the script, change the tap gesture…But here it is.
This script allows you to store a password (string) in the item, needed to launch it (so it can be a folder, shortcut, bookmark)
Instructions:
– Copy/paste this script
– Set it as the tap action of the item you want, if you want to set it to all remember to go to the container setting.
-If no password are found you will be asked to make a new one.
-You need to write the exact String to launch the item
-If you want to change an already set password write “reset:” + [your old password] example “reset:1234”
———————————-
var item = LL.getEvent().getItem();
if(item==null)return;
pin = item.getTag();
if(pin==null){
if(confirm(“No password saved found.\nDo you want to make a new one?”)){reset();}else{item.launch();}
}else{
var inp = prompt(“Insert Password:”,””);
if(inp==null){return;}
else if(inp==pin){item.launch();}
else if(inp==”reset:”+pin){reset();}
else{ Android.makeNewToast(“Wrong password”,true).show();}
}
function reset(){
var newPin = prompt(“Write the new custom password:”,””);
if(newPin==null)return;
var new2Pin = prompt(“Write again the new custom password to confirm:”,””);
if(new2Pin==null)return;
if(newPin==new2Pin){
item.setTag(newPin);
Android.makeNewToast(“pasword saved”,true).show();
}else{
Android.makeNewToast(“the passwords are not the same”,true).show();
reset();
}
}
]]>
D5 Creation