is it possible to add an scriptable image as the shortcut icon persistently?
is it possible to add an scriptable image as the shortcut icon persistently?
I tried with:
itm.setDefaultIcon(img);
itm.setCustomIcon(img);
itm.setImage(img);
Only the setImage seems to be working. But according to the documentation it’s not persistent, and the image I got was cramped into 1×1 cell (the size of the default android icon), when the the size of the shortcut was 3×1.
So far I have been able to successfully get the scriptable image working using:
itm.setBoxBackground(img, “ns”, true);
but, it’s not persistent neither.
if doing the scriptable icon persistent is not possible, how can I make the box background persistent or act in a persistent like behavior?
Persistent setBoxBackground works after all, that is, it creates an image that survives restarts and relaunches:
var d = LL.getDesktopByName(“myTop”);
var i = d.getItemByName(“myItem”);
var pic = LL.createImage(“/path/myPic.png”);
var b = i.setBoxBackground(pic, “n”,true);
Thanks, but I meant this type of image below…
it creates and arc and above it adds the current day and date following the curvature of the arc
var drawing = {
draw: function(context) {
var canvas = context.getCanvas();
var itm_w = context.getWidth();
var itm_h = context.getHeight();
var itm_sz = Math.min(itm_w,itm_h);
var stk_w=6;
var color_end=0x00000000;
var color_start=0xFF33B5E5;
//canvas.save();
// create a paint object
//var tile_mode=Shader.TileMode.MIRROR;
//var tile_mode=Shader.TileMode.REPEAT;
var tile_mode=Shader.TileMode.CLAMP;
var p = new Paint(Paint.ANTI_ALIAS_FLAG);
p.setStyle(Paint.Style.STROKE);
p.setStrokeWidth(stk_w);
//p.setShader(new LinearGradient(0, (itm_sz-stk_w)/2, 0, 2*itm_sz/3, color_start, color_end, tile_mode));
//canvas.drawArc(new RectF(stk_w, itm_h/3,(itm_w-stk_w), itm_h), -180, 180, true, p);
//canvas.drawOval(new RectF(stk_w, itm_h/2,(itm_w-stk_w), itm_h * 1.5), p);
p.setShader(new LinearGradient(0, (itm_sz-stk_w)*(2/3), 0, itm_sz, color_start, color_end, tile_mode));
canvas.drawOval(new RectF(stk_w, itm_h *(2/3),(itm_w-stk_w), itm_h *(1+2/3)), p);
//p.setShader(new LinearGradient(0, (itm_sz-stk_w)/2, 0, itm_sz, color_start, color_end, tile_mode));
//canvas.drawCircle(itm_w/2,itm_sz *1.5,(itm_sz-stk_w),p);
var myvars = LL.getVariables();
var mytxt = myvars.getString(“ll_day_name”) + “, ” + myvars.getString(“ll_month_name”) + ” ” + myvars.getInteger(“ll_day”);
//var mytxt = myvars.getString(“ll_day_name”) + “, ” + myvars.getString(“ll_month_name”) + ” ” + myvars.getInteger(“ll_day”) + ” ” + myvars.getInteger(“ll_second”);
//var mytxt = “Wednesday, September 30”;
var myarc = new Path();
myarc.addArc(new RectF(stk_w, itm_h/6,(itm_w-stk_w), itm_h), -180, 180);
pt = new Paint(Paint.ANTI_ALIAS_FLAG);
pt.setStyle(Paint.Style.FILL_AND_STROKE);
pt.setColor(Color.WHITE);
pt.setTextSize(68);
pt.setTextAlign(Paint.Align.CENTER); //LEFT, RIGHT
pt.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
//canvas.drawTextOnPath(mytxt.toUpperCase(), myarc, 0, itm_h/4, pt);
canvas.drawTextOnPath(mytxt.toUpperCase(), myarc, 0, itm_h*(7/16), pt);
canvas.save(); canvas.restore();
}
}
var img = Image.createImage(drawing, -1, -1);
//var img = Image.createImage(drawing, itm.getWidth()*2, itm.getHeight());
//var img = LL.createImage(drawing, -1, -1);
itm.setBoxBackground(img, “ns”, true);