FORUMS
Remove All Ads from XDA

[MOD/GUIDE] X-Recents

201 posts
Thanks Meter: 838
 
By XYunknown, Retired Recognized Developer on 1st September 2012, 11:18 AM
Post Reply Email Thread
Hey Guys!
After a few requests I decided to share my X-Recents mod with you, so that other developers get the ability to add it to their Rom. This is just for Developers building Roms from Source! Also, medium skills on java coding are recommended!

What is X-Recents mod?
It's a mod improving the stock android recents, to make them more user-friendly and feature-rich. It was already implemented in my X-Bean Rom for i9000

Please note:
- you can use this for all ICS/JB Roms and for all devices
- just add me to the credits, if you want to use it, and notify me: [email protected]
- The swype FC Bug (occurs when swyping over the Button) still exists, to fix it just add try/catch blocks at all points that cause the FC it (use adb/logcat for analysis)


Okay, so let's get started: You can find all files in: system/frameworks/base/packages/SystemUI/src/com/android/systemui/recent (in your working directory)

At first, we modify the RecentTasksLoader.java:

l.260: final int first = 1;
to : final int first = 0;

This loads the current activity into the recents list.. Only problem: The launcher shall not be shown in the recents list, so we have to make a exeption for it:

l.270: if (item != null) {
to : if (item != null && item.packageName!="com.cyanogenmod.trebuchet") { // You can add as many exeptions for apps as you want

Next point: Adding the Taskmanager button:
At first, open RecentsVerticalScrollView.java:

Insert this at line 95:
Code:
private void opentaskmanager() {
    	PackageManager pm = getContext().getPackageManager();
    	Intent appStartIntent = pm.getLaunchIntentForPackage("com.sec.android.app.controlpanel");
    	if (null != appStartIntent)
    	{
    	    getContext().startActivity(appStartIntent);
    	}
    }
Now, wrap a try/catch block around the loop content in line 107:
Code:
for (int i = 0; i < mLinearLayout.getChildCount(); i++) {
            try {
	    View v = mLinearLayout.getChildAt(i);
            addToRecycledViews(v);
            mAdapter.recycleView(v);
            } catch (Exception ex) {
	    }
        
        }
Also add a try here (I can't give you a line, because you inserted something before) :
Code:
for (int i = 0; i < mAdapter.getCount(); i++) {
            try {
            View old = null;
And a catch here:
Code:
calloutLine.setOnTouchListener(noOpListener);
            mLinearLayout.addView(view);
            } catch (Exception ex) {
            }
        }
To add the button, insert this:
Code:
Button bt_taskmanager = new Button(getContext());
        bt_taskmanager.setText("Task Manager");
        bt_taskmanager.setWidth(mLinearLayout.getWidth());
        bt_taskmanager.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                opentaskmanager();
            }
        });
        mLinearLayout.addView(bt_taskmanager);
Between these two lines:
setLayoutTransition(transitioner);

// Scroll to end after layout.

Okay, now we've got the button!

At last I want to give you something you can experiment with:
Code:
private void clearalltasks() {
    	final ActivityManager am = (ActivityManager)
                mContext.getSystemService(Context.ACTIVITY_SERVICE);
    	final List<ActivityManager.RecentTaskInfo> recentTasks =
                am.getRecentTasks(50, ActivityManager.RECENT_IGNORE_UNAVAILABLE);
    	
    	for (int i = 0; i >= recentTasks.size(); i++) {
    		RecentTaskInfo item = recentTasks.get(i);
    		
    		if (am != null && item!=null) {
    			try {
    				am.removeTask(item.persistentId, ActivityManager.REMOVE_TASK_KILL_PROCESS);
    			} catch (Exception ex) {
    				
    			}
    			try {
    				am.killBackgroundProcesses(item.origActivity.getPackageName());
    			} catch (Exception ex) {
    				
    			}
            }
    	}
        mLinearLayout.removeAllViews();
        try {
			update();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
    }
This is my first attempt to add a clear all button.. Do with it what you want, I tried it and it works half-ways.. But not perfectly. I will add some more things later!

P.S: Screenshot is attached!
Attached Files
File Type: zip allthestuffyouneed.zip - [Click for QR Code] (63.7 KB, 114 views)
The Following 16 Users Say Thank You to XYunknown For This Useful Post: [ View ] Gift XYunknown Ad-Free
 
 
1st September 2012, 11:19 AM |#2  
XYunknown's Avatar
OP Retired Recognized Developer
Thanks Meter: 838
 
Donate to Me
More
Screenshot:
The Following 4 Users Say Thank You to XYunknown For This Useful Post: [ View ] Gift XYunknown Ad-Free
1st September 2012, 04:22 PM |#3  
albertobom's Avatar
Senior Member
Flag Esquinzo
Thanks Meter: 691
 
Donate to Me
More
Thank you!

Sent from my GT-I9000

---------- Post added at 04:22 PM ---------- Previous post was at 03:30 PM ----------

This mod should be added to any cm 10 Rom!


Sent from my GT-I9000
1st September 2012, 05:15 PM |#4  
Account currently disabled
Thanks Meter: 267
 
More
Thanks for the share..
1st September 2012, 05:22 PM |#5  
driodmaster92's Avatar
Senior Member
Flag Chennai
Thanks Meter: 3,552
 
More
Thanks man !!! was waiting for a long time for this....will try to fix the bug..and report ..
I have observed that the task button manager button is not fixed ...
1st September 2012, 05:42 PM |#6  
Senior Member
Thanks Meter: 134
 
More
Any chance to offer this as a mod for Cm10?
1st September 2012, 05:46 PM |#7  
erpurohit's Avatar
Senior Member
Thanks Meter: 1,438
 
More
Quote:
Originally Posted by H-Body

Any chance to offer this as a mod for Cm10?

This is already on cm10 try xbean 1.1
1st September 2012, 06:57 PM |#8  
XYunknown's Avatar
OP Retired Recognized Developer
Thanks Meter: 838
 
Donate to Me
More
Quote:
Originally Posted by H-Body

Any chance to offer this as a mod for Cm10?

You can use this mod on AOKP, AOSP, CM10, CM9 - actually on EVERY Rom that you build from Source!
1st September 2012, 07:25 PM |#9  
sUsH667's Avatar
Senior Member
Thanks Meter: 450
 
More
Quote:
Originally Posted by XYunknown

You can use this mod on AOKP, AOSP, CM10, CM9 - actually on EVERY Rom that you build from Source!

i think what he means is that he wants someone else to do it for him, so he just has to flash it to his device...

btw, great guide, thx for sharing! i was waiting for this, too, since i saw it in xbean.

greetz,

sUsH
The Following User Says Thank You to sUsH667 For This Useful Post: [ View ] Gift sUsH667 Ad-Free
5th September 2012, 05:59 AM |#10  
sUsH667's Avatar
Senior Member
Thanks Meter: 450
 
More
Question a question i forgot...
i forgot one question:
is it in any way possible to mod an already compiled SystemUI.apk, meaning adding this mod to a ready rom?
maybe with apktool-de- and re-compiling?
i did decompile SystemUI.apk successfully, but get no .java-files in result, only the respective .smali-files, so i don't know how to go on from here, if at all...

any help appreciated, and if it is not possible, well, it's not possible, my bad.

greetz,

sUsH
5th September 2012, 08:23 AM |#11  
XYunknown's Avatar
OP Retired Recognized Developer
Thanks Meter: 838
 
Donate to Me
More
Quote:
Originally Posted by sUsH667

i forgot one question:
is it in any way possible to mod an already compiled SystemUI.apk, meaning adding this mod to a ready rom?
maybe with apktool-de- and re-compiling?
i did decompile SystemUI.apk successfully, but get no .java-files in result, only the respective .smali-files, so i don't know how to go on from here, if at all...

any help appreciated, and if it is not possible, well, it's not possible, my bad.

greetz,

sUsH

Not possible, because you can't decompile the APK's one-by-one to the original java code.. Smali or Backsmali is just a replacement for the unprecise re-constructed Java code, to get a code which you can re-compile properly. There is also a possibility to get the rough java sourcecode.. But as this is not the "real" java source, it is in most cases not re-compileable. Hope you could follow me
The Following User Says Thank You to XYunknown For This Useful Post: [ View ] Gift XYunknown Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes