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. ====== Script code ====== <sxh javascript> var e = LL.getEvent(); var it = e.getItem(); if(it==null){ var c = e.getContainer(); c.getProperties().edit().setEventHandler("i.longTap", EventHandler.RUN_SCRIPT, LL.getCurrentScript().getId()).commit(); }else{ LL.bindClass("java.io.File"); LL.bindClass("android.content.Context"); LL.bindClass("java.io.FileInputStream") LL.bindClass("java.io.FileOutputStream") LL.bindClass("android.graphics.BitmapFactory") LL.bindClass("android.graphics.Bitmap") LL.bindClass("android.graphics.Canvas") LL.bindClass("android.graphics.ColorMatrix") LL.bindClass("android.graphics.ColorMatrixColorFilter") var context = LL.getContext(); var storeDir = new File(context.getFilesDir(), "unfreezeColorImages"); if(!storeDir.exists())storeDir.mkdir(); function saveImage(bmp){ var out = null; try { out = new FileOutputStream(storeDir.getPath()+"/"+it.getId()+".png"); bmp.compress(Bitmap.CompressFormat.PNG, 100, out); // PNG is a lossless format, the compression factor (100) is ignored } catch (e) { throw(e); } finally { try { if (out != null) out.close(); } catch (e) { throw(e); } } } function toGrayscale(bmpOriginal) { var imgGrayscale = LL.createImage(bmpOriginal.getWidth(), bmpOriginal.getHeight()) var canv = imgGrayscale.draw(); var paint = new Paint(); var cm = new ColorMatrix(); cm.setSaturation(0); var f = new ColorMatrixColorFilter(cm); paint.setColorFilter(f); canv.drawBitmap(bmpOriginal, 0, 0, paint); return imgGrayscale; } 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="+it.getIntent().getComponent().getPackageName()+";end") var frozen = it.getTag("frozen"); if(frozen=="true"){ if(it.getTag("customIcon")=="true"){ var path = storeDir.getPath()+"/"+it.getId()+".png"; it.setCustomIcon(LL.createImage(path)); it.getCustomIcon().save(); var bmp = new File(path); bmp.delete(); }else{ it.setCustomIcon(null); } it.setTag("frozen",false); }else{ var img = it.getCustomIcon(); if(img==null){ img = it.getDefaultIcon(); it.setTag("customIcon", false); }else{ it.setTag("customIcon", true); } var bmp = img.getBitmap(); saveImage(bmp); it.setCustomIcon(toGrayscale(bmp)) it.setTag("frozen",true); } } </sxh>

script_autosetupappfreeze.1447194906.txt.gz · Last modified: 2015/11/10 22:35 by cdfa