Wallpaper changing
Wallpaper changing
Changes the wallpaper repeatedly to a part of a larger image. Image automatically gets scaled if it doesn’t fit.
How to use:
– set up configuration
– run once after phone restart
Video: I used a far lower interval for demonstration purposes
Hint: Device and/or LL might turn inresponsible for up to 30 seconds (normal: 1-2) while the wallpaper gets changed.
]]>
< ![CDATA[
//config
var path =”/sdcard/Download/tree-stars-night.jpg”;
var steps = 48;
var interval = 60 * 60 * 24; //seconds for one run-through, has to be >= steps, max. 1 day
//endconfig
LL.bindClass(“android.app.WallpaperManager”);
LL.bindClass(“android.util.DisplayMetrics”);
LL.bindClass(“android.graphics.Bitmap”);
LL.bindClass(“android.app.AlarmManager”);
LL.bindClass(“android.app.PendingIntent”);
LL.bindClass(“java.util.Calendar”);
LL.bindClass(“android.content.Context”);
LL.bindClass(“android.os.Bundle”);
var script = LL.getCurrentScript();
if(LL.getEvent().getSource()!=”BACKGROUND”){
var metrics = new DisplayMetrics();
var ctx=LL.getContext();
ctx.getWindowManager().getDefaultDisplay().getMetrics(metrics);
var height = metrics.heightPixels;
var width = metrics.widthPixels;
script.setTag(“width”,width);
script.setTag(“height”,height);
var intent = new Intent(“com.twofortyfouram.locale.intent.action.FIRE_SETTING”);
intent.setClassName(ctx.getPackageName(),”net.pierrox.lightning_launcher.util.FireReceiver”);
var b= new Bundle();
b.putInt(“a”,EventHandler.RUN_SCRIPT);
b.putString(“d”,script.getId().toString());
b.putInt(“t”,3);
intent.putExtra(“com.twofortyfouram.locale.intent.extra.BUNDLE”,b);
var p = PendingIntent.getBroadcast(ctx,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
var cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY,0);
cal.set(Calendar.MINUTE,0);
cal.set(Calendar.SECOND,0);
cal.set(Calendar.MILLISECOND,0);
var am = ctx.getSystemService(Context.ALARM_SERVICE);
am.setInexactRepeating(AlarmManager.RTC,cal.getTimeInMillis(),1000 * (interval/steps),p);
}
else{
var width = script.getTag(“width”);
var height = script.getTag(“height”);
var img = LL.createImage(path).getBitmap();
var newWidth = height/img.getHeight()*img.getWidth();
var tmp = Bitmap.createScaledBitmap(img,newWidth,height,true);
var cal = Calendar.getInstance();
var time = ((cal.get(Calendar.HOUR_OF_DAY)*60+cal.get(Calendar.MINUTE))*60+cal.get(Calendar.SECOND))%interval;
var percent =time
var cutAt = (newWidth-width)*percent;
var cut = Bitmap.createBitmap(tmp,cutAt,0,width,height);
WallpaperManager.getInstance(LL.getContext()).setBitmap(cut);
img.recycle();
tmp.recycle();
cut.recycle();
}
]]>
< ![CDATA[
That’s pretty cool..
]]>
< ![CDATA[
Would it be possible to switch between live wallpapers?
]]>
< ![CDATA[
James Coyle no. The Android system forbids that.
]]>
< ![CDATA[
Evelien Wijbenga
]]>
< ![CDATA[
Wow Lukas Morawietz that was fast. Awesome. Thanks.
]]>