====== About the script ====== * Purpose : This script will allow you to set up a calendar widget replacement * Author : F43nd1r * Current Version : 1.3 * Link : https://plus.google.com/+LukasMorawietz/posts/ENEoGArx8D4 ====== Changelog ====== * Version 1.0 (19/4/2015): initial release in wiki * Version 1.1 (20/4/2015): fixed showing yesterday's all-day-appointments, reduced minimum API level to 14 * Version 1.2 (21/4/2015): added fix for devices using 23:59 instead of 00:00 (manual) * Version 1.3 (21/4/2015): Fix memory leaks ====== How to use the script ==== * Either install Calendar package from [[http://www.pierrox.net/android/applications/lightning_launcher/permissions/|here]] or grant READ_ CALENDAR permission using Lightning Permission Manager * Create a text item * set this script in its resumed event * set up your configuration at the beginning of the script * set the Max lines of the item to showMax or higher * customize the items style to your needs ====== Issues and hints ====== * //please report all bugs in the g+ community// ====== Script code ====== //config var pattern = "dd. MM. HH:mm";//format has to match http://developer.android.com/reference/java/text/SimpleDateFormat.html var showEnd = true; var patternEnd = "HH:mm"; //used when entry ends on same day var patternAllDay = "dd. MM.";//used for all-day-entries var showMax = 3; var days = 90; //how far to search from today (might be not exact) var dayOffFix=false; //when true adds one to all-day entries //endconfig LL.bindClass("android.provider.CalendarContract"); LL.bindClass("java.util.Calendar"); LL.bindClass("android.content.ContentUris"); LL.bindClass("java.text.SimpleDateFormat"); LL.bindClass("android.app.AlertDialog"); LL.bindClass("android.widget.SimpleCursorAdapter"); LL.bindClass("android.R"); LL.bindClass("android.content.DialogInterface"); LL.bindClass("android.widget.AbsListView"); var Calendars = CalendarContract.Calendars; var Instances = CalendarContract.Instances; var item=LL.getEvent().getItem(); var saved = item.getTag("calendar"); var cx = LL.getContext(); var cr = cx.getContentResolver() if(saved==null){ var projection = [Calendars._ID,Calendars.NAME]; var calCursor = cr.query(Calendars.CONTENT_URI, projection, Calendars.VISIBLE + " = 1", null, Calendars._ID + " ASC"); if (!calCursor.moveToFirst()){ AndroiSD. makeNewToast("No Calendar found").show(); calCursor.close(); return; } var adapter = new SimpleCursorAdapter(cx,R.layout.simple_list_item_multiple_choice,calCursor,[Calendars.NAME],[R.id.text1],0); var dialog = new AlertDialog.Builder(cx) .setAdapter(adapter,null) .setPositiveButton("Confirm", new DialogInterface.OnClickListener(){ onClick:function(dialog,which){ var checked = dialog.getListView().getCheckedItemPositions(); var cals = []; for(var i=0;i