LLXperiment: most launched apps
This script is something I made some weeks ago, and I’ve been testing it myself since then. It seems to work, but unfortunately I don’t use it too much to fully test it…and it crash the launcher if you do a specify thing 😛 (don’t worry, it’s a specific and predictable thing)
So, instead of leave it in the list of scripts I never published I’m going to share it as a beta LLXperiment. Yea, that will be better.
The script is specially designed for those who use the app drawer a lot.
What the script does: it creates a panel in the app drawer with the most launched (clicked) apps from the app drawer.
More details: when you click an app from the app drawer (or from a folder from the app drawer) a copy of the app will be placed in the panel (If there is not one). That list is sorted by the most used one, based on a very simple algorithm that seems to work.
Even more details: each app has an internal value from 2 to 0,5. Each time you click an app its value is raised a bit, and all the other apps decrease a bit. Those ‘multiplier’ values are in the script, and I plan to tune then from your suggestions.
How to use it: first run the script from the app drawer, and the panel and all the necessary events will be set. You can run again to reinstall or to uninstall.
If you want to remove an app from the panel run the script from the item.
IMPORTANT!!!!!!
If you try to enter edit mode in the panel, the launcher will crash.
It will also crash when using the search app feature of the app drawer.
Also make a backup before, just in case. (I never had any issues, even when it crash, but just in case)
]]>
< ![CDATA[
//start config
var increase = 1.2
var decrease = 0.99;
var name=”most used”;
var tag=”most used”;
var id=99;//id of the container where the panel will be placed
//end config
var event=LL.getEvent();
var item=event.getItem();
var source=event.getSource();
var scriptid=LL.getCurrentScript().getId();
var drawer=LL.getContainerById(99);
var panel=LL.getContainerById(id).getItemByName(name);
if(source==”MENU_APP” || panel==null || item==null){
var noexist= (panel==null);
if(!confirm(“This will set all the tap action of all the containers from the app drawer to run this script.” + ( noexist?” And will add a ‘most used apps’ panel at the top.”:””) + “\n Do you want to continue?”)){
if(confirm(“Do you want instead to uninstall the script?”)){
uninstall();
}
return;
}
install();
return;
}
panel=panel.getContainer();
if(source==”I_CLICK”){
if(item.getType()==”Folder”)tappedFolder(item);
if(item.getType()==”Shortcut”)tappedItem(item);
return;
}
if(source==”MENU_ITEM” && item.getParent()==panel){
deleteItem(item);
return;
}
//else
Android.makeNewToast(“Run the script from the menu app”, true).show();
function install(){
if(noexist){
panel=LL.getContainerById(id).addPanel(0,0,drawer.getWidth(),1);
LL.save();
panel.setName(name);
panel.getContainer().getProperties().edit().setInteger(“gridPRowNum”,1).commit();
prepareContainer(panel.getContainer(),true);
}
//LL.save();
prepareContainer(drawer,true);
}
function uninstall(noexist){
if(!noexist)LL.getContainerById(id).removeItem(panel);
LL.save();
prepareContainer(drawer,false);
}
function prepareContainer(cont,install){
var handler= install? EventHandler.RUN_SCRIPT : EventHandler.UNSET;
var items=cont.getItems();
for(var t=0;t
var item=items.getAt(t);
if(item.getType()==”Folder” || item.getType()==”Panel”)prepareContainer(item.getContainer(),install);
}
cont.setTag(tag, install? 1 : null);
cont.getProperties().edit().setEventHandler(“i.tap”,handler,scriptid).commit();
}
function tappedItem(tapped){
var component=tapped.getIntent();
var items=panel.getItems();
var list=[];
var exists=false;
for(var t=0;t
var item=items.getAt(t);
list[t]=item;
if(component==item.getIntent()){
item.setTag(tag, Math.min(item.getTag(tag)*increase,2) );
exists=true;
}else{
item.setTag(tag, Math.max(item.getTag(tag)*decrease,0.5) );
}
//item.setLabel(item.getTag(tag));
}//end for
if(!exists){
var added=panel.addShortcut(tapped.getLabel(),tapped.getIntent(),0,0);
added.setTag(tag,1);
added.setDefaultIcon(tapped.getDefaultIcon());
list.push(added);
}
update(list);
tapped.launch()
}
function update(list){
if(list==null){
var items=panel.getItems();
list=[];
for(var t=0;t
}
list.sort(function(a,b){return b.getTag(tag)-a.getTag(tag);});
for(var t=0;t
list[t].setCell(t,0,t+1,1,true);
}//end for
}//end function
function tappedFolder(folder){
if(folder.getContainer().getTag(tag)==null) prepareContainer(folder.getContainer(),true);
folder.launch();
}
function deleteItem(item){
if(confirm(“Do you want to delete this item?”))panel.removeItem(item);
update();
}
]]>
< ![CDATA[
TrianguloY This code has come at the right time. I will try to merge it with the floating desktop to have my most used apps available everywhere.
]]>
< ![CDATA[
TrianguloY​​ how can I install the panel in the floating desktop. 
How can I uninstall from the app drawer, when I confirm uninstallation it gives an error at line 79. If I disable I cannot launch any app from the drawer.
]]>
< ![CDATA[
What’s your level of script knowledge?
An easy way (not tested) will be:
– Install the script
– move the panel to the desired desktop
– change the 99 of the script (firsts lines) to the id of the desktop.
]]>
< ![CDATA[
TrianguloY​ I tried moving the panel to the desktop but it isn’t movable.
I will try changing the id.
With regards my knowledge, very basic.
]]>
< ![CDATA[
oh, so better create a new panel in the desktop and change the 99 as I said.
Oh! and you need to set the name of that panel to ‘most used’
]]>
< ![CDATA[
I did the following :
1. Change the id to the desktop id in this case is (1).
2. Created a new panel and set the name to ‘most used’ and changed the id to 10001
In both cases the apps aren’t copied to the most used panel.
]]>
< ![CDATA[
no, no.
the id must be 1, the container that contains the panel
]]>
< ![CDATA[
Yes, this is the 1st scenario. I set the id to (1), the panel most used is created by the script. However, when I click on the apps, nothing is copied there.
]]>
< ![CDATA[
The script overrides the click action of the items, you need to install it with the 99 as id so the ones in the app drawer react.
THEN you can change the id to 1 and you don’t need to run the script again.
The apps that are created are only the ones that you click at least once. So you need to start some apps and the panel should be populated
]]>
< ![CDATA[
Awesome!!
]]>
< ![CDATA[
So i installed this script and now everytime I press the search button LL crashes. Any idea for a possible solution? Also I wasn’t able to remove the panel (uninstalling) by running the script again, although I may have done something wrong trying to do that. I reset the app drawer and now everything is working fine again, but I would really like this script to work. Here is the crash report:
Android 4.4.4 REL 19 / ECOO E04 ECOO E04
net.pierrox.lightning_launcher_extreme v12.5.1 (r2298) – 2257
java.lang.NullPointerException
at net.pierrox.lightning_launcher.data.aq.b(Shortcut.java:222)
at net.pierrox.lightning_launcher.activities.AppDrawerX.a(AppDrawerX.java:993)
at net.pierrox.lightning_launcher.activities.AppDrawerX.onTextChanged(AppDrawerX.java:1742)
at android.widget.TextView.sendOnTextChanged(TextView.java:7815)
at android.widget.TextView.setText(TextView.java:3981)
at android.widget.TextView.setText(TextView.java:3711)
at android.widget.EditText.setText(EditText.java:81)
at android.widget.TextView.setText(TextView.java:3686)
at net.pierrox.lightning_launcher.activities.AppDrawerX.d(AppDrawerX.java:1140)
at net.pierrox.lightning_launcher.activities.AppDrawerX.onClick(AppDrawerX.java:1326)
at android.view.View.performClick(View.java:4485)
at android.view.View$PerformClick.run(View.java:18827)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5322)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)
Statistics
3 page(s) loaded
page 0: 64 item(s)
61 shortcut(s) – icons: 1,34 MB, drawable: 0,00 B
3 widget(s): 2,12 MB
page 99: 117 item(s)
117 shortcut(s) – icons: 9,18 MB, drawable: 0,00 B
0 widget(s): 0,00 B
page 101: 2 item(s)
2 shortcut(s) – icons: 0,00 B, drawable: 0,00 B
0 widget(s): 0,00 B
total shortcuts: 180
total widgets: 3
total icon size: 10,52 MB
total drawable size: 0,00 B
total widget size: 2,12 MB
widgets drawable size: 2,12 MB
max: 256 MB
]]>
< ![CDATA[
Colin de Roos​ didn’t I wrote….nop I didn’t, my mistake.
It also crash when using the search button, sorry. I can’t do anything (well, I can but it will make other errors)
For the removing panel, it should have been removed when running the script again, and choosing uninstall. Anyway, you could also enter edit mode of the app drawer and remove it by long click.
]]>
< ![CDATA[
Oh that’s a pity. Do you know why it does that, or is that a bit hard to explain?
]]>
< ![CDATA[
The problem is that the app drawer is not expected to have any item other than an app, a folder or a page indicator.
This script uses a panel, so it crashes in some actions (luckily it does not in all of them)
]]>
< ![CDATA[
Ah, that’s quite understandable. Thanks for your help :).
]]>
< ![CDATA[
+TrianguloY​ I have decided to put this panel in my home screen to have easy access to the most used apps. However, the more I launch the longer the panel and scrolling. So, it came to me that I should have the most 10-15 apps only.
I tried below code (in line 123) to remove the last app in the panel on the left side. But it is removing from the middle.
if (items.getLength() == 10) { panel.removeItem(items.getAt(9)); }
As you know, my scripting skill is not good enough to sort this out. Could you help.
]]>
< ![CDATA[
Abdullah Alahdal if you remove apps, the algorithm of the most used one won’t work.
If you don’t want the panel to scroll you can simply disable scrolling, or even set a stop point to stop scrolling at an specific point.
But if not: are you sure you really want to delete always the 10th item?
]]>
< ![CDATA[
Yes, I want to delete the 10th item. Based on the code I added, there won’t be more than ten as it is checking in every tap. Right?
]]>
< ![CDATA[
Abdullah Alahdal didn’t tested, but this should work. Just replace the function
function update(list){
if(list==null){
var items=panel.getItems();
list=[];
for(var t=0;t
}
list.sort(function(a,b){return b.getTag(tag)-a.getTag(tag);});
for(var t=0;t
if(t>9)panel.removeItem(list[t]);
else list[t].setCell(t,0,t+1,1,true);
}//end for
}//end function
]]>
< ![CDATA[
Thanks TrianguloY​
]]>