====== About the script ====== * Purpose : This script is will use an item as gesture detection area, so you can launch any shortcut by a gesture! * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] * Current Version : 1.1 * Link (with video): https://plus.google.com/115366157037831519359/posts/ZzXD1hKNrf2 ====== Changelog ====== * Version 1.0 (31/8/2014): initial release in wiki * Version 1.1 (2/9/2014): More stable loading, First gesture Bug fix (hopefully) ====== How to use the script ====== * create a shortcut and hide it's label and icon * Resize it to the wished drawport size * set this script to the Touchevent * enable it in item menu * Change the configuration to your data, especially the itemID * to add or change a gesture: launch this script on the shortcut you want to assign a gesture to, then draw the new gesture. * to remove a gesture: delete the shortcut to which the gesture was assigned ====== Issues and hints ====== * With too much gestures it may stop working * the first gesture after LL started may be not fully drawn or not detected. * if more than one gesture is matching, one is selected by database, so avoid similar gestures * straight horizontal or vertical lines may not work as gesture. //please report all bugs in the g+ community// ====== Script ====== //config var tolerance=7; var itemID=0x060029; var bgColor=0x10ffffff; var gestureColor=0xffffffff; //endconfig if(typeof add==='undefined')add=null; try{ switch(event.getAction()) { case MotionEvent.ACTION_DOWN: paint=new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(gestureColor); paint.setStrokeWidth(5); paint.setStrokeJoin(Paint.Join.ROUND); image=item.getBoxBackground("n"); if(image.getWidth()!=item.getWidth()||image.getHeight()!=item.getHeight())image=LL.createImage(item.getWidth(),item.getHeight()); canvas=image.draw(); image.getBitmap().eraseColor(Color.TRANSPARENT); canvas.drawColor(bgColor); this.gesture=[]; this.gesture.push([event.getX(),event.getY()]); image.update(); item.setBoxBackground(image,"n"); done=false; setTimeout(loadGestures,0); break; case MotionEvent.ACTION_MOVE: this.gesture.push([event.getX(),event.getY()]); canvas.drawLine(this.gesture[this.gesture.length-2][0],this.gesture[this.gesture.length-2][1],event.getX(),event.getY(),paint); image.update();item.setBoxBackground(image,"n"); break; case MotionEvent.ACTION_UP: this.gesture.push([event.getX(),event.getY()]); canvas.drawLine(this.gesture[this.gesture.length-2][0],this.gesture[this.gesture.length-2][1],event.getX(),event.getY(),paint); while(!done); if(add!=null) { gestures.push([scaleGesture(this.gesture),add]); item.setTag(JSON.stringify(gestures)); add=null; Android.makeNewToast("Saved!",true).show(); } else { var sg=scaleGesture(this.gesture); schleife:for(var x=0;xtolerance*4) { continue schleife; } gesDiff=gesDiff+diff; } if(gesDiff/sg.lengthmaxx)maxx=GESTURE[i][0]; if(GESTURE[i][1]maxy)maxy=GESTURE[i][1]; } var scaled=[]; for(var i=0;i