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

Search This thread

gh123man

Senior Member
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
with
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

. 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

...waits a long time
then if all went well
(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...
this will go much faster.
now you can navigate to
/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://xdaforums.com/showpost.php?p=4074066&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

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 :p

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
<include layout="@layout/all_apps_2d" />
to
<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
screenshot-1328478636487.png



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

/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.

Screenshot-6.png


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.
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
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
Screenshot-7.png


you mainly want to worry about
ICON_TEXTURE_WIDTH_PX = 74;
and
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
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
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 :)
screenshot-1329099575759.png





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/andro...gn=Feed:+xda-developers/ShsH+(xda-developers)

EDIT:
just fixing errors and stuff
 
Last edited:

gh123man

Senior Member
Could you post a guide or an APK for HVGA? That would be awesome:D

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!
 
Last edited:

myn

Retired Senior Recognized Developer
Nov 15, 2007
2,679
3,985
Great mod :)

Thanks for documenting this so detailed :)
 
  • Like
Reactions: gh123man

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    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
    with
    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

    . 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

    ...waits a long time
    then if all went well
    (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...
    this will go much faster.
    now you can navigate to
    /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://xdaforums.com/showpost.php?p=4074066&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

    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 :p

    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
    <include layout="@layout/all_apps_2d" />
    to
    <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
    screenshot-1328478636487.png



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

    /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.

    Screenshot-6.png


    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.
    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
    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
    Screenshot-7.png


    you mainly want to worry about
    ICON_TEXTURE_WIDTH_PX = 74;
    and
    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
    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
    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 :)
    screenshot-1329099575759.png





    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/andro...gn=Feed:+xda-developers/ShsH+(xda-developers)

    EDIT:
    just fixing errors and stuff
    1
    Great mod :)

    Thanks for documenting this so detailed :)