Guess what? I’m left handed! And I’m sad to see that Google is still not offering a left handed option to theirs users. Until now, one solution is to use a custom rom witch allows you to customize navigation bar. But with the recent Lollipop release, no custom rom is yet ready for daily use… Moreover, ART, the new runtime, breaks Xposed Framework compatibility. Xposed Framework was another solution for stock rooted rom to install a module for navigation bar customization. I recently bought a Nexus 6 (still shipping!) and I don’t want to wait a new solution (Xposed Framework compatibility is not coming soon). Never mind, I’m a developer so let’s do this myself!
In the following, I will explain how to switch order of navigation bar controls. I did it on my Nexus 7 (grouper) on latest Lollipop release (LRX21P). I warn you: make a backup before breaking your rom. So if you want to edit the navigation bar, you will need to edit the SystemUI.apk. This application is responsible for… the System UI (User Interface). To do this, you will need:
- adb (command details, included in the platform-tools of the Android SDK),
- Java 7,
- apktool (2.0.0rc3 as I wrote),
- a text (or XML) editor,
- an archiver,
- zipalign (command details, included in the build-tools of the Android SDK),
- to be rooted (you will need to modify a system file, which is in read-only mode by default).
First, grab the SystemUI.apk application. In my case, it is located in /system/priv-app/SystemUI/:
adb pull /system/priv-app/SystemUI/SystemUI.apk
We also need the framework resource application. It will be used by apktool to decompile the SystemUI.apk. In my case, it is located in /system/framework/:
adb pull /system/framework/framework-res.apk
So now, we need to install framework for apktool then we could decompile the SystemUI:
$ ./apktool.sh if LRX21P/framework-res.apk I: Framework installed to: /home/user/apktool/framework/1.apk $ ./apktool.sh d -s SystemUI.apk I: Using Apktool 2.0.0-RC3 on SystemUI.apk I: Loading resource table... I: Decoding AndroidManifest.xml with resources... I: Loading resource table from file: /home/user/apktool/framework/1.apk I: Regular manifest package... I: Decoding file-resources... I: Decoding values */* XMLs... I: Copying raw classes.dex file... I: Copying assets and libs... I: Copying unknown files... I: Copying original files...
Note I did’nt decompile sources, using the -s option of apktool. We only need to edit the layout files. The navigation bar is defined in layouts (obviously) named navigation_bar.xml. You will found two files: one in /res/layout/ folder, another in /res/layout-sw600dp/ folder. To be simple, the first one is for phone, the second one for tablet (see resource qualifiers for more explanations).
Now, you could edit those layout files to set the navigation buttons at the location you want. Look for the LinearLayout with id “@id/nav_buttons”, it will contains the buttons and spacers. You should have two LinearLayout per file with this identifier: one for the portrait mode, another for the landscape mode (check the parent FrameLayout identifier: @id/rot0 for portrait, @id/rot90 for landscape). In my case, reverse order of each element of those LineraLayout (for the two layout files). For example, I got:
- LinearLayout (@id/nav_buttons):
- FrameLayout (menu button and keyboard locale switcher),
- KeyButtonView (@id/recent_apps),
- View (spacer),
- KeyButtonView (@id/home),
- View (spacer),
- KeyButtonView (@id/back),
- View (fixed size spacer).
Once you have edit the layout files, we need to rebuild the SystemUI.apk:
$ ./apktool.sh b SystemUI I: Using Apktool 2.0.0-RC3 on SystemUI I: Checking whether resources has changed... I: Building resources... warning: string 'notifications_off_text' has no default translation. warning: string 'notifications_off_title' has no default translation. I: Building apk file...
You will find the resulting apk in SystemUI/dist/. You will now need to sign and align the built apk. Make a copy of the original SystemUI.apk to SystemUI_signed.apk. Extract with an archiver the two edited files, /res/layout/navigation-bar.xml and /res/layout-sw600dp-v13/navigation-bar.xml, from the built apk to add it to the SystemUI_signed.apk. Once done, signed the SystemUI_signed.apk to a SystemUI_aligned.apk:
zipalign -v 4 SystemUI_signed.apk SystemUI_aligned.apk
Now you could replace the original system application with the freshly built, signed then aligned one. First copy it to the SD card (or any writable location), remount the file system with write option and replace the apk:
adb push SystemUI_aligned.apk /sdcard/ adb shell $ su # mount -o rw,remount /system # cp /sdcard/SystemUI_aligned.apk /system/priv-app/SystemUI/SystemUI.apk
Now reboot and enjoy the result!
If you get troubles, feel free to post comment about it for some help.