This post was originally published on Coding Glamour.
If you're an avid smartphone user there will be times when there
is behavior on your phone that just doesn't make sense, and that annoys
the crap out of you. Well, you're not alone! Same thing happens to
me, and I'm even a full time developer on Firefox OS. One of the things
that bugs me the most is the behavior of the address bar in the browser.
When you scroll enough down, it will disappear, but the content jumps up
under your finger. And content jumping is the @#*&*#@&#&$ annoying.
Time to fix it!
So first we'll need the source code of the application. To do that, we first enable remote debugging on the phone. You do this via:
Settings -> Device Information -> More Information -> Developer -> Remote Debugging
Now if you have the Android Developer Bridge (adb) installed, and plugged in your phone, running adb devices will show you your device:
Time to pull the browser app. All system apps live in '/system/b2g/webapps/[name].gaiamobile.org' (you can |adb shell| into the phone if you like), and then are zipped up as 'application.zip'. So to pull the browser, run:
Updating the app
The code is not minified or zipped, so it's pretty easy to just start digging around (yeah, you can attach a debugger and inspect the code, but that's for another time). By looking in browser.js there are some scrolling thresholds defined on top of the file:
Well, that seems pretty much what I need. Time to kill the address bar toggling! Searching for the variable brings us to:
So, let's just remove that code, and always show the address bar. Now the thing is that the code that gets executed on the device is minified and combined. And it lives in 'gaia_build_defer_index.js' in the root of the app. So let's open that file, throw it through a JS beautifier, and find the same code. Now we can also fix this piece of code and remove the toggling.
You can minify the file again, but who actually cares.
Time to push this back to the phone
So, make sure you have the original ZIP, in case you made a fuck up. Now make a ZIP file from the app again (select all files -> Compress X items in OSX). Make sure you ZIP the content of the browser folder, not the actual folder itself! And time to push it back to the phone.
Tah dah, no more annoying scroll behavior.
Don't want to hack your own phone?
It will be fixed in Firefox OS 1.4. But then again, there is probably something else that might annoy you :-)
There are 5 comments on this article, read them on Coding Glamour.