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.
/*
* 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;
}
I like it⊠Thanks for sharing
Iâm sorry to bring up an older topic, but I canât get this to work. I added the script and when I run it, Iâm able to enter the title and url and it creates an icon, but when I try to open it, it says it canât find the application. If I go to select an application and choose my browser, it just opens the existing browser window and not the desired url.
Thats weird :/ i dunno why it wont work its just a standard Android intent aslong as you have an app that can handle it, this should work. Do you get the message âActivity not found Exceptionâ or something else? can you screen record?
It did say activity not found. But I was able to adjust the code to work for my purposes so no worries! I created a new script for each link I needed.
nice glad it was kinda useful
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