User Tools

Site Tools


script_random_lockscreen

====== About the script ====== * Purpose : This lock screen is made of two scripts: one that unlocks the screen if you click the items in order (configurable, uses the id of the items) and the other just place the items in random cells (configurable too). * Author : [[https://plus.google.com/u/1/105066926163073195690|TrianguloY]] * Link: https://plus.google.com/u/1/105066926163073195690/posts/eCZU9HHJX5F (with video) ====== How to use the script ====== Since the items can be whatever you want, you can make the lock screen with apps, pictures, colors, shapes... Of course you can use them separately, perhaps you just want the lock sequence Instructions: * Place some items in cell mode. [If you want to move them randomly] * Set the resumed event to run the 'randomize' script. If you want some items to not move, place them in free mode * IMPORTANT: configure the script with the available cells where you want to place the items. [The lock part] * Set the click event of the items (all that will be part of the 'pattern' ) to run the 'locksequence' script. * Click one item to set your first password * To change it just perform the sequence while unlocked and follow the instructions. (The time to wait is configurable) ====== Script code ====== === Lock Secuence Script === <sxh javascript> var interval = 2000; /* time in milliseconds to wait until new lock set*/ var tag = LL.getScriptTag(); /* in case they don't exist*/ if( tag != undefined ){ var data = JSON.parse( tag ); }else{ var data = new Object(); } if(! ("a" in data)){ data.a=0; } if(! ("secuence" in data)){ data.secuence = []; data.secuence[0]=0; } var item = LL.getEvent().getItem(); /* to notify the click*/ item.setVisibility(false); setTimeout(function(){ item.setVisibility(true) ;},50); if(data.a<0){ /* The set procces: negative numbers*/ data.secuence[ -data.a -1]=item.getId(); --data.a; data.timeout = setTimeout( function(){isDone(data.a);},interval); }else{ /* The unlock procces: positive and zero numbers*/ if(item.getId()!=data.secuence[data.a]){ /* wrong*/ data.a=0; }else{ ++data.a; if(data.a==data.secuence.length){ /* good*/ data.a=0; /* unlock or set new one*/ if(LL.isLocked()){ LL.unlock(); }else{ reset(); } } } } /* if no data found*/ if( data.secuence[0]==0 ) reset(); save(data); function save(tosave){ LL.setScriptTag( JSON.stringify(tosave) ); } function reset(){ if(!confirm("Set a new lock?"))return; data.secuence = []; data.a= -1; Android.makeNewToast("Click the items in order\nWait "+ interval/1000 + " second after the last click to apply" , false ).show() ; } function isDone(old){ var now = JSON.parse( LL.getScriptTag() ); if(old!=now.a)return; now.a=0; Android.makeNewToast("Lock set with "+ data.secuence.length + " steps", false ).show(); save(now); } </sxh> === Randomize Script === <sxh javascript> //Cell: [first position , size ] var h = [1,3]; var v = [1,3]; var all = LL.getEvent().getContainer().getItems(); //Or use the container you want var items = []; var len = 0; for(var i=all.getLength()-1;i>=0;--i){ var p = all.getAt(i); if(p.getProperties().getBoolean("i.onGrid") ) items[len++]=p; } var free = new Array(); if(len > h[1]* v[1] ){ alert("WARNING: a lot of items, or a small layout"); return; } for(var i=0; i<len;++i){ var sh = 0; var sv = 0; do{ sh=Math.floor(Math.random()* h[1] ); sv=Math.floor(Math.random()* v[1] ); } while(free[sv* h[1]+sh]!=undefined) free[sv* h[1]+sh]=0; sh+=h[0]; sv+=v[0]; items[i].setCell(sh,sv,sh+1,sv+1); } </sxh>

script_random_lockscreen.txt · Last modified: 2015/01/04 14:51 by trianguloy