Web Shortcuts for all devices without installing other apps π
Web Shortcuts for all devices without installing other apps π
Script is in the first post after copying it open the script editor application and paste the script slide out the script editor drawer and tick the lightning menu checkbox so it appears under the scripts menu as shown in the video.
]]>
< ![CDATA[
/*
* Web Shortcuts
* Create shortcuts to your favourite websites
*/
LL.bindClass(“android.widget.LinearLayout”);
LL.bindClass(“android.widget.EditText”);
LL.bindClass(“android.app.AlertDialog”);
LL.bindClass(“android.content.DialogInterface”);
LL.bindClass(“android.content.Intent”);
var mctx = LL.getContext();
var ll = new LinearLayout(mctx);
with(ll){
setOrientation(LinearLayout.VERTICAL);
setBackgroundColor(0xffff);
setLayoutParams(new LinearLayout.LayoutParams(200, 100));
}
var title = new EditText(mctx);
with(title){
setHint(“Title”);
setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
}
ll.addView(title);
var url = new EditText(mctx);
with(url){
setHint(“Url”);
setText(getClip());
setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
}
ll.addView(url);
adb = new AlertDialog.Builder(mctx);
adb.setTitle(“Configure Web Shortcut”);
adb.setCancelable(false);
adb.setView(ll);
adb.setPositiveButton(“Create”, new DialogInterface.OnClickListener(){
onClick:function(dialog, id){
if(title.length() >= 3 && url.length() >= 3){
try{
var i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url.getText().toString().trim()));
var d = LL.getCurrentDesktop();
d.addShortcut(title.getText().toString().trim(), i, 500, 800);
var item = d.getItemByName(title.getText().toString().trim());
item.setDefaultIcon(Image.createTextIcon(“n”, 250, 0xff000000, 0xffffffff, null));
Android.makeNewToast(“Shortcut was created”, false).show();
//LL.startActivity(i);
}catch(anfe){
Android.makeNewToast(“” + anfe, true).show();
}
}
}
});
adb.setNegativeButton(“Cancel”, new DialogInterface.OnClickListener(){
onClick:function(dialog, id){
dialog.dismiss();
}
});
var alert = adb.create();
alert.show();
function getClip(){
var manager = mctx.getSystemService(Context.CLIPBOARD_SERVICE);
var clip = manager.getPrimaryClip();
if(clip != null){
var text = clip.getItemAt(0).getText();
return text;
}
return;
}
]]>
< ![CDATA[
SWEET!
Even my-non-scripting-self can figure out how to work this!
No idea HOW it works, mind you, but I can operate it, like the average soccer mom operates a minivan. π
Is it possible to use a similar (dialog box) interface to set a web shortcut for long touch or for a swipe action, on an existing desktop item?
This is great!
]]>
< ![CDATA[
Haha π yeah i made it as user friendly as i could i think thats possible but you would probably need to give the existing item an id or label something i can reference it by in the script. Will check the API later and have a go at writing something.
]]>
< ![CDATA[
Multiling o
]]>
< ![CDATA[
Coming soon
https://lh3.googleusercontent.com/JcFm2g9DDEZNFC_K1qsBijtFDwAnQqfcwF0n0mENa3TXLh58pPIoKYmJACokVrBRiO84tCYFzw
]]>
< ![CDATA[
Well this^ aint coming soon i was experimenting with a video player widget again and managed to break the launcher. My setups super lazy/crappy so i just uninstalled/installed for a quick fix and as usual forgot to back up my scripts π
]]>
< ![CDATA[
That’s rough.
]]>
< ![CDATA[
yup but i suppose it teaches me not to have a crappy setup lol but this is about the 4th time ive did this now so im not learning my lesson. Its not all bad though i still have my assistant script on my TV.
]]>
< ![CDATA[
Looks like a few people have found this script useful so i’ve updated it to be a little nicer. Now you can just copy the website url to clipboard and the url field will be filled in automatically. The default icon was kinda wank so i’ve replaced it with something sexy π enjoy
]]>