now browsing by category
Hi, I was wondering if there was any way to set a live wallpaper as a desktop screen through script?
System wallpaper?
(There’s a similar thread, but problem seems different.)
I can set a system wallpaper (bg) image, BUT LL desktops always seem to appear over the ‘grout line’ between image tiles. (Cropped to screen size, and set as ‘fixed’.)
The only workaround I’ve found, thus far, is setting wallpaper (bg) image, per wallpaper of LL setup. This works flawlessly, but is less efficient, as it must be set separately for drawers & each LL wallpaper.
]]>I have made another script listening directly to Location API.
I use it in my car’s head unit for GPS speedometer.
Although GPS speed can be obtained with my other script that takes data from Torque, this one makes it unnecessary to use Torque, and may get data updates just a little bit sooner.
The variables set by script are:
gps_live – boolean – indicates that location API is ready (i.e. enabled and ready)
gps_speed – float – the speed in m/s (must be multiplied by 3.6 to get km/h)
To use, make text with binding like follows:
($gps_speed * 3.6).toFixed(0)
Also, text display can be bound to $gps_live
The script requires a permission which is missing in LLX:
android.permission.ACCESS_FINE_LOCATION
To make it work, either wait for developers to add a permission APK for that, or use this xposed module by Lukas Morawietz (if you are using xposed framework): https://play.google.com/store/apps/details?id=com.faendir.lightning_launcher.permission_manager
— cut —
LL.bindClass(“android.location.LocationManager”);
LL.bindClass(“android.location.LocationProvider”);
LL.bindClass(“android.location.LocationListener”);
LL.getVariables()
.edit()
.setBoolean(“gps_live”, true)
.setFloat(“gps_speed”, 0)
.commit();
var locationManager = LL.getContext().getSystemService(Context.LOCATION_SERVICE);
var locationListener = new LocationListener({
onLocationChanged: function(location) {
if(!location.hasSpeed()) return;
var speed = location.getSpeed();
LL.getVariables()
.edit()
.setFloat(“gps_speed”, speed)
.commit();
},
onProviderDisabled: function(provider) {
LL.getVariables()
.edit()
.setBoolean(“gps_live”, false)
.commit();
},
onProviderEnabled: function(provider) {
LL.getVariables()
.edit()
.setBoolean(“gps_live”, true)
.commit();
},
onStatusChanged: function(provider, status, extras) {
LL.getVariables()
.edit()
.setBoolean(“gps_live”, status == LocationProvider.AVAILABLE)
.commit();
}
});
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
— cut –
I would like to share my script for users of Torque https://play.google.com/store/apps/details?id=org.prowl.torque
This script allows reading any PIDs from Torque service, for latter use in bindings.
Set it to be run on desktop load.
It will set the following variables:
tq_live – boolean – whether we are connected to Torque service
tq_ecu – boolean – whether Torque is connected to Engine ECU
tq_version – integer – the version of Torque
tq_xxx – float – the value of pid, where xxx is a name of pid as configured at the top of script, you may configure multiple PIDs; see below
— cut —
var refreshInterval = 200;
var pids = [
{pid: 0xff1001, name: “gps_speed”},
{pid: 0xff123A, name: “gps_locked”},
{pid: 0x0c, name: “rpm”},
{pid: 0x42, name: “voltage”}
];
LL.bindClass(“android.os.Parcel”);
LL.bindClass(“android.content.ServiceConnection”);
var binder = null;
var timer = null;
function callSvc(code, fp, fr, def) {
if (binder == null) return def;
var p = Parcel.obtain();
var r = Parcel.obtain();
try {
p.writeInterfaceToken(“org.prowl.torque.remote.ITorqueService”);
if (fp != null) fp(p);
binder.transact(code, p, r, 0);
return r.readExceptionCode() == 0 && (fr != null) ? fr(r) : def;
}
catch (err) {
return def;
}
finally {
r.recycle();
p.recycle();
}
}
// int getVersion()
function getVersion() { return callSvc(
1,
null,
function(r) { return r.readInt(); },
0
); }
// float getValueForPid(long pid, boolean triggersDataRefresh);
function getValueForPid(pid, refresh) { return callSvc(
2,
function(p) { p.writeLong(pid); p.writeByte(refresh ? 1 : 0); },
function(r) { return r.readFloat(); },
0
); }
// boolean isConnectedToECU();
function isConnectedToECU() { return callSvc(
15,
null,
function(r) { return r.readByte() != 0; },
false
); }
function reset() {
var v = LL.getVariables().edit();
v.setBoolean(“tq_live”, false);
v.setBoolean(“tq_ecu”, false);
v.setInteger(“tq_version”, 0);
for(var i = 0; i < pids.length; i++)
v.setFloat(“tq_” + pids[i].name, 0);
v.commit();
}
function refresh() {
if (binder == null) return;
var v = LL.getVariables().edit();
v.setBoolean(“tq_ecu”, isConnectedToECU());
for(var i = 0; i < pids.length; i++)
v.setFloat(“tq_” + pids[i].name, getValueForPid(pids[i].pid, true));
v.commit();
timer = setTimeout(refresh, refreshInterval);
}
var conn = new ServiceConnection({
onServiceConnected: function (n, b) {
binder = b;
var v = LL.getVariables().edit();
v.setBoolean(“tq_live”, true);
v.setInteger(“tq_version”, getVersion());
v.commit();
refresh();
},
onServiceDisconnected: function(n) {
binder = null;
reset();
}
});
reset();
var intent = new Intent();
intent.setClassName(“org.prowl.torque”, “org.prowl.torque.remote.TorqueService”);
var success = LL.getContext().bindService(intent, conn, 1);
— cut —
]]>Hello
I have an advanced question about scripting.
Is it possible at all to communicate with a 3rd party remote service from a script? You know, Context.bindService() and all those things. Provided I have that service’s AIDL file.
I understand that AIDL is for generation of stub and proxy for “real” Java code. But maybe it can be done from JavaScript using bare Binder/Parcel classes?
I’m not as experienced developer to figure it out myself, sadly 🙁
What’s on my mind – is to communicate to famous Torque application, which provides API for plugins:
https://torque-bhp.com/forums/?wpforumaction=viewtopic&t=438.0
https://torque-bhp.com/ITorqueService.aidl
What I would like to call on this service is:
float getValueForPid(long pid, boolean triggersDataRefresh);
Thanks in advance for any clue 🙂
]]>Circular Battery Indicator
Use this in a custom view:
Comment #1: Create script
Comment #2: Dummy Binding
You can also take this script as an inspiration to create circular progressbars for other things.
]]>Metadata script for any player. Requires android.permission.MEDIA_CONTENT_CONTROL !
Albumart works too, but is currently saved as an Image object in the global variable globalAA, because bindings can’t hold images.
This should work with any player on any device with Lollipop or higher.
]]>I updated my Music Metadata script.
I’m writing about this now specifically (most of my updates go silent), because it is a relatively simple yet practical example on how to utilize JavaAdapter. Check it out if you’re curious or if you just want to see the Syntax.
http://www.lightninglauncher.com/wiki/doku.php?id=script_music_metadata
]]>/*
Quick Message
This script will send a preformatted message to someone.
you will need to install this sweet apk by the dev himself to give the launcher permission to send sms messages
http://www.lightninglauncher.com/permissions//
If your running Marshmallow just installing the apk is not enough there is 1 more step you need to take, go to your device settings and open your application manager press the cog icon on the toolbar and choose app permissions find the sms permission tap it and flick the switch on the new permission and your good to go.
Note: This step will probably be a little diferent on your device but should be nearly the same.
*/
LL.bindClass(“android.net.Uri”);
LL.bindClass(“android.content.Intent”);
LL.bindClass(“java.language.IllegalArgumentException”);
LL.bindClass(“android.telephony.TelephonyManager”);
LL.bindClass(“android.telephony.SmsManager”);
var mctx = LL.getContext();
var num = “######”; // replace with phone#
var message = “This is is a test”; // replace with your message
function check()
{
var service = mctx.getSystemService(Context.TELEPHONY_SERVICE);
// Check if device supports telephony
if (service.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE)
{
alert(“This device doesnt support telephony”);
}
else
{
// continue
}
}
check();
try{
var textMan = SmsManager.getDefault();
textMan.sendTextMessage(num, null, message, null,null);
Android.makeNewToast(“Sent”, false).show();
}catch(e){
alert(e)
}
]]>//Quick Dial
LL.bindClass(“android.net.Uri”);
LL.bindClass(“android.content.Intent”);
LL.bindClass(“android.content.ActivityNotFoundException”);
LL.bindClass(“android.telephony.TelephonyManager”);
var mctx = LL.getContext();
var num = “4444”; // replace with phone#
function check()
{
var service = mctx.getSystemService(Context.TELEPHONY_SERVICE);
// Check if device supports telephony
if (service.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE)
{
alert(“This device doesnt support telephony”);
}
else
{
// continue
}
}
check();
try
{
var i = new Intent(Intent.ACTION_DIAL);
i.setData(Uri.parse(“tel:” + num));
mctx.startActivity(i);
}
catch (anfe)
{
alert(anfe);
}
]]>