User Tools

Site Tools


script_autosetupappfreeze

**This is an old revision of the document!** ----

A PCRE internal error occured. This might be caused by a faulty plugin

====== About the script ====== * Purpose : this script automatically sets up app freezing on long tap * Author : cdfa * Link: https://plus.google.com/+JaroslavGrochal/posts/BDKDMrTMfxt ====== How to use the script ====== This script uses 3C toolbox: https://play.google.com/store/apps/details?id=ccc71.at.free If you know any other app that has a shortcut for freezing of apps i can make that work too if you want :). After you've installed 3C toolbox ,run the script from a container and all items in that container which don't already have a custom long tap eventhandler will now freeze on long tap. Running the script in that container again will revert the long tap eventHandler for the items in that container. Running the script from the lightning menu will do that for all containers. ====== Script code ====== <sxh javascript> LL.bindClass("android.app.AlertDialog"); LL.bindClass("android.content.DialogInterface"); function loanEventHandler(ob, name, action, data){ var prop = ob.getProperties(); var ed = prop.edit(); var evHa = prop.getEventHandler(name); evHa = [evHa.getAction(), evHa.getData()]; ob.setTag("old "+name+" evHa", JSON.stringify(evHa)); ed.setEventHandler(name, action, data); ed.commit(); } function returnEventHandler(ob, name){ var ed = ob.getProperties().edit(); var evHa = JSON.parse(ob.getTag("old "+name+" evHa")); ed.setEventHandler(name, evHa[0], evHa[1]); ed.commit(); script.setTag("name", null); } function customConfirmDialog(title,onPositiveFunction){ var builder=new AlertDialog.Builder(LL.getContext()); builder.setCancelable(true); builder.setTitle(title); builder.setNegativeButton("Cancel",new DialogInterface.OnClickListener(){onClick:function(dialog,id){dialog.dismiss();}}); builder.setPositiveButton("Confirm",new DialogInterface.OnClickListener(){onClick:function(dialog,id){dialog.dismiss();setTimeout(onPositiveFunction,0);}}); builder.show(); } function uninstall(c){ if(c!=null){ c.setTag("longTapFreeze",false); returnEventHandler(c,"i.longTap"); var frozenItIds = JSON.parse(c.getTag("frozenItIds")); if(frozenItIds!=null){ for(var i=0;i<frozenItIds.length;i++){ var it = c.getItemById(frozenItIds[i]) if(it!=null){ it.getProperties().edit().setInteger("s.iconColorFilter",0xffffffff).commit(); it.setTag("frozen",false); } } c.setTag("frozenItIds",null); } } } var e = LL.getEvent(); var it = e.getItem(); var script = LL.getCurrentScript(); if(it==null){ var c = e.getContainer(); var cIds = JSON.parse(script.getTag("cIds")); if(c!=null){ cId = c.getId(); if(cIds==null) cIds=[]; if(c.getTag("longTapFreeze")=="true"){ customConfirmDialog("Are you sure you want to uninstall?", function(){ uninstall(c); cIds.splice(cIds.indexOf(c.getId()),1); }) }else{ cIds.push(c.getId()); c.setTag("longTapFreeze",true); loanEventHandler(c, "i.longTap", EventHandler.RUN_SCRIPT, script.getId()); } script.setTag("cIds", JSON.stringify(cIds)); }else{ customConfirmDialog("Are you sure you want to uninstall from every container?", function(){ //var l = cIds.length; for(var i=0;i<cIds.length;i++){ uninstall(LL.getContainerById(cIds[i])); } script.setTag("cIds",null); }) } }else{ var c = it.getParent(); var frozenItIds = JSON.parse(c.getTag("frozenItIds")); if(frozenItIds==null)frozenItIds=[]; var pkgName = it.getIntent().getComponent().getPackageName(); if(pkgName!="net.pierrox.lightning_launcher_extreme") LL.runAction(EventHandler.LAUNCH_SHORTCUT, "#Intent;action=ccc71.at.freeze;launchFlags=0x34000000;component=ccc71.at.free/ccc71.at.activities.tweaks.at_tweaker_activity;S.ccc71.at.packagename="+pkgName+";end"); if(it.getTag("frozen")=="true"){ it.getProperties().edit().setInteger("s.iconColorFilter",0xffffffff).commit(); it.setTag("frozen",false); frozenItIds.splice(frozenItIds.indexOf(it.getId()),1); }else{ it.getProperties().edit().setInteger("s.iconColorFilter",0x00ffffff).commit(); it.setTag("frozen",true); frozenItIds.push(it.getId()); } c.setTag("frozenItIds", JSON.stringify(frozenItIds)); } </sxh>

script_autosetupappfreeze.1447512636.txt.gz · Last modified: 2015/11/14 14:50 by cdfa