Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,737,124 Members 43,486 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE][MOD] Modify Launcher2 3D for any screen resolution or size UPDATE - 2/12/12

Tip us?
 
gh123man
Old
(Last edited by gh123man; 13th April 2012 at 04:17 PM.)
#1  
gh123man's Avatar
Senior Member - OP
Thanks Meter 314
Posts: 368
Join Date: Jan 2010
Location: Rochester NY -school (Kendall park NJ - home)
Angry [GUIDE][MOD] Modify Launcher2 3D for any screen resolution or size UPDATE - 2/12/12

Quote:
NEWS AND UPDATES
2/13/12
I have continued my research and discovered some better ways to port the launcher. the key update im adding to the guide today is how to fix the icon label aliasing. see step 11

Greetings all XDA friends,
I have been up all night working on this for my Atrix 4g.
I think I have made enough documentation to make an official guide

This guide will teach you how to modify the stock android 3D Launcher to work with any screen size and resolution.
Last night I successfully ported it to QHD screens and posted the source/changes on my github page (https://github.com/gh123man/Launcher2_QHD)


--INTRO--
Launcher2 has 2 views for the app drawer. A 2D view that works with any phone and is the default as outlined in the source. A 3D view that only works correctly with phones of a 850x480 resolution.
Being I am a lover of the stock android experence I wanted to make this possible on my device.
While I am aware this has been done before on QHD screens, I could not find any source code or documentation on how to make some changes that I wanted to make. This guide should allow you to correct the possition of the 3D app drawer on any device. I am using QHD as an example.

--GUIDE--

THIS IS LINUX ONLY
IM USING UBUNTU 11.04

1) the first thing you need to do is download the android source code and sdk. why? because the stock launcher can only be compiled with the tools used to build the entire firmware from source. it CANNOT BE COMPILED IN ECLIPSE because some libraries are private and not included in the sdk. so the first step is to set up the build environment. we need the sdk because of adb. I would assume you have it.
follow the guide as outlined here http://source.android.com/source/initializing.html
go to developer.android.com for the sdk

after you have the build environment configured you should download the cyanogenmod 7 source. I decided against the official source from google because cm7 has support for tons of devices and wont compile odexed apks.

so folow this guide http://source.android.com/source/downloading.html

but replace
Quote:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
with
Quote:
repo init -u git://github.com/CyanogenMod/android.git -b gingerbread
so you get cm7 source and not the stock ICS source.

2) long step 1 eh? anyways. once the source is downloaded into a working directory your going to want to compile it for a device. because if we are only going to compile launcher 2 it needs a clean build first. so...
cd into your /working_dir (or whatever you called it) and type these commands

Quote:
. build/envsetup.sh
lunch
when the big menu comes up pick a device. not full-eng, a real device. I picked the olympus because I work on the atrix anyway. you need to pick a device because it will ensure you get a deodexed apk in your /out directory.
so after lunch I type

Quote:
61
...waits a long time
then if all went well
Quote:
make -j4
(if it fails change it to -j1)

THIS WILL TAKE A LONG TIME
i have a dual core hyperthreaded i5 laptop. a -j1 build takes about 2 hrs because its only working off one logical core.
be paitent you only need to do this once.

3) let build the launcher on its own to make sure it compiles clean.
type...
Quote:
make Launcher2
this will go much faster.
now you can navigate to
Quote:
/out/target/product/<dvice_name>/system/app
and pull out the Launcher2.apk

4) make sure adb is in your path, if its not and you have the sdk installed this should help
http://forum.xda-developers.com/show...66&postcount=4

5) make sure you have an alternate launcher installed. most people do now, weather its adw or something that comes with your rom. make sure Launcher2 is not your only launcher on your phone if you even have it.
now...
type

Quote:
adb remount
adb push out/target/product/<device_name>/system/app/Launcher2.apk /system/app
adb shell
su
cd /system/app
chmod 644 Launcher2.apk
or you can do this all with root explorer. adb is much faster if your doing the whole trial and error methond like I did

6) now that you have the pure unmodded stock launcher on your phone, it should not have 3d turned on. we will fix that next

7) now to jump into some code. first things first your going to want to back up your launcher2 folder in /Packages/apps
just save it anywere in its current state. if you dont its not that big a deal, a repo sync will fix it if its broked too.
navigate to
packages/apps/Launcher2/res/layout
and open all_apps.xml in any text editor.
and change this line
Quote:
<include layout="@layout/all_apps_2d" />
to
Quote:
<include layout="@layout/all_apps_3d" />
8) now you have 3d mode enabled compile and push it over again to make sure it runs and your changes took effect. go through steps 3 - 5
it should look something like this if your using a QHD device



9) its time to start resizing it to fit our screen. navigate to

Quote:
/packages/apps/Launcher2/scr/com/android/Launcher2
and open AllApps3D.java in any text editor. one that colors the code helps. the stock ubuntu editor does this. go down to around line 280.
This is the magic block of code we are looking for.



now let me shed some light on how this works. it took me a few hours to find this and figure out what it does and how it works. basicly the values in the array tf control the possition, zoom level, and start and end point of the 3d drawer. this is what I came up with using the trial and error method.
if you have any programming experence you know the number has to do with the possiton in the list starting at 0.
Quote:
tf 6 = vertical streatch of main grid from the bottom
tf 7 = vertical streatch of main grid from the top
tf 8 = zoom level
tf 10 = horizontal shift
tf 11 = vertical shift
soooooooooo
Quote:
tf 6 = 120.f
tf 7 = 680.f
tf 8 = (2.f / 480.f)
tf 10 = -((float)w / 2) - 0.25f
tf 11 = -380.25
f
that should make it a little easier for anyone to understand.

so what you basicly want to to is change these valuse, compile it, push it, test it, repeat until your figure out what looks best. Dont worry about the icons looking horrible. we are fixing that next.

10) now we need to resize the icons to match your screen resolution. so head to the top-ish of AllApps3D and look for this section around line 149
your looking for this


you mainly want to worry about
Quote:
ICON_TEXTURE_WIDTH_PX = 74;
and
Quote:
ICON_TEXTURE_HEIGHT_PX = 74;
as long as these 2 values are the same the icons will be square. so size them up and down until it looks right. or you can use figure out the ratio to match your resolution perfectly. its up to you. the goal is to make sure that when scrolling the icons do get "ripples" through them.

11) the last step is to fix the icon labels. as you zoom in and out and realign the grid and re-size the icons. The icon labels become distorted. To fix this you need to go to
Quote:
/res/raw/allapps.rs
I want to say .rs stands for render script? someone correct me if im wrong.
Anyways what you need to do is go to line 338ish and find
Quote:
vpConstants->ImgSize.x = 107.f;
vpConstants->ImgSize.y = 57.f;
your number will look different as these are my settings.
x = the width of the icon label
y = the hight of the icon label
I dont know any easy way to do this other then the old "compile it, push it, test it, repeat" method.
so mess with them until the text is crisp and clear all changes are updated on my github if you want to use it for reference!



my final product looks like this





If anyone would like more information or the source for QHD just head over to my github.
If you have any questions. let me know. ill do my best to help out.
good Luck!

small update. I fixed texture tearing on QHD. see my github for changes

front page link
http://www.xda-developers.com/androi...-developers%29

EDIT:
just fixing errors and stuff
checkout Tree Task

ADD ON GOOGLE+ - https://plus.google.com/116707674152406292958
SUBSCRIBE ON YOUTUBE - http://youtube.com/gh123man
FOLLOW ON TWITTER - http://twitter.com/#!/gh123man
GITHUB - https://github.com/gh123man
Acer iconia a500 - CM9 /cm10alpha
GSM unlocked Galaxy Nexus- CM10
Moto Atrix 4g - CM9 / stock + modded webtop
2x Moto Droid - CM7
The Following 5 Users Say Thank You to gh123man For This Useful Post: [ Click to Expand ]
 
-Grift-
Old
#2  
-Grift-'s Avatar
Recognized Contributor
Thanks Meter 1927
Posts: 4,492
Join Date: Jan 2011
Location: Singapore
Cool! dont know what to say :/




Devices That I Have Rooted/Flashed/S-OFF
Asus Google Nexus 7 2012
LG GT540 Optimus Swift
LG Optimus 4X HD P880
LG Google Nexus 5 (Active)
Samsung Galaxy Mini
Samsung Galaxy Ace
Samsung Galaxy Note
Samsung Galaxy S II (<-- Awesome Device)
HTC Sensation XE

 
Rores
Old
#3  
Senior Member
Thanks Meter 44
Posts: 168
Join Date: Jun 2011
Location: Rouen
Could you post a guide or an APK for HVGA? That would be awesome
 
gh123man
Old
(Last edited by gh123man; 6th February 2012 at 05:28 PM.)
#4  
gh123man's Avatar
Senior Member - OP
Thanks Meter 314
Posts: 368
Join Date: Jan 2010
Location: Rochester NY -school (Kendall park NJ - home)
Quote:
Originally Posted by Rores View Post
Could you post a guide or an APK for HVGA? That would be awesome
If I get some free time I could try to build it for the emulator (as i dont have an HVGA device). The guide applies to all devices so I would only release an apk and I could post the changes in the source. I still need to finish with QHD so Ill post back if I get around to it. Thanks for your interest!
checkout Tree Task

ADD ON GOOGLE+ - https://plus.google.com/116707674152406292958
SUBSCRIBE ON YOUTUBE - http://youtube.com/gh123man
FOLLOW ON TWITTER - http://twitter.com/#!/gh123man
GITHUB - https://github.com/gh123man
Acer iconia a500 - CM9 /cm10alpha
GSM unlocked Galaxy Nexus- CM10
Moto Atrix 4g - CM9 / stock + modded webtop
2x Moto Droid - CM7
 
myn
Old
#5  
myn's Avatar
Senior Recognized Developer
Thanks Meter 4002
Posts: 2,658
Join Date: Nov 2007

 
DONATE TO ME
Great mod

Thanks for documenting this so detailed
The Following User Says Thank You to myn For This Useful Post: [ Click to Expand ]
 
bL33d
Old
#6  
bL33d's Avatar
Senior Member
Thanks Meter 61
Posts: 831
Join Date: Mar 2008
Location: Illinois
hopefully someone smarter then i can get this working on 720p displays.
LG G2
[ROM] [AOSP] TEAM GUMMY
-------------------
Previous - Verizon Note 3
Previous- note 2
 
Amir.Adel
Old
#7  
Amir.Adel's Avatar
Member
Thanks Meter 11
Posts: 83
Join Date: Jan 2012
Location: Cairo
thats coool
 
gh123man
Old
#8  
gh123man's Avatar
Senior Member - OP
Thanks Meter 314
Posts: 368
Join Date: Jan 2010
Location: Rochester NY -school (Kendall park NJ - home)
I have continued my research and discovered some better ways to port the launcher. the key update im adding to the guide today is how to fix the icon label aliasing. see step 11
checkout Tree Task

ADD ON GOOGLE+ - https://plus.google.com/116707674152406292958
SUBSCRIBE ON YOUTUBE - http://youtube.com/gh123man
FOLLOW ON TWITTER - http://twitter.com/#!/gh123man
GITHUB - https://github.com/gh123man
Acer iconia a500 - CM9 /cm10alpha
GSM unlocked Galaxy Nexus- CM10
Moto Atrix 4g - CM9 / stock + modded webtop
2x Moto Droid - CM7

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA PORTAL POSTS

Port Sony Xperia Themes to CyanogenMod 11 with Ease

In addition the obvious proficiency with graphics, creating agood Android theme … more

Cell Phone SIM Unlock Bill Just Steps Away from President’s Desk

For all those who believe that Cinderella stories don’t actually … more

Get Your Cargo to its Destination in 4×4 Military Operations Reborn

Racing games have evolved quite a bit since the days of Pole … more