User Tools

Site Tools


script_loop_wallpaper

====== About the script ====== * Purpose : This script loops horizontally through a wallpaper image * Author : F43nd1r * Current Version : 1.0 * Link (with video): https://plus.google.com/+LukasMorawietz/posts/gEmTGrFjNUr ====== Changelog ====== * Version 1.0 (28/6/2016): initial release in wiki ====== How to use the script ====== * Set this script in the load event of your desktop * Set up configuration ====== Issues and Hints ====== //please report all bugs in the g+ community!// ====== Script ====== <sxh javascript;>//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<interval/2?time*2/interval:(interval-time)*2/interval; 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(); } </sxh>

script_loop_wallpaper.txt · Last modified: 2016/06/28 12:39 by f43nd1r