ADT Graphical Layout tool and SCM systems

Well, most of you android developers encountered this problem. The graphical layout designer in the ADT (Android Developer Tool – the eclipse plugin) creates every element in the XML as one line. You might ask, why is it a problem? well, in most cases, it is not. But there is one annoying thing that makes this feature/bug or whatever you want to call this a real time consumer. Unless you are a solo Android developer that saves his code in a local or remote storage as is, you probably use some kind of SCM (Source Control Management) system (e.g. git, svn, cvs, tfs, clearcase and the list goes on and on). Most (if not all) of these systems and their diff tools (also most of the diff tools I encountered) use line comparison. They tell you if you added/removed/edit a line. In case you edit a line, it marks the parts of the line you edited. This is all nice when you edit the text code yourself. But in the GL (Graphical Layout) you don’t. And then, if you changed one property of an element using the GL, you will see it in the SCM as an edited line. The thing is, now you need to go over the whole element (that sometimes has several properties) and see which property exactly you changes. And let’s say, for example, that you changed two properties. One is at the beginning of the line and the other at the end. How easy it would be to miss that second property? Basically, what the GL does is to eliminate many of the advantages of SCMS.

In the past, I usually chose between two options:

  1. Not use the GL (not always possible since I don’t remember all the properties by heart).
  2. After using the GL, go over the file and add line breaks manually.
I wanted to use the auto formatting tool of eclipse, but it always looked bad. Here it how it looked before:
And After:
After a bit of digging in the eclipse preferences by my colleague he found the solution: going to preferences -> XML -> XML Files -> Editor and checking the “Split multiple attributes each on a new line” and after pressing Ctrl+Shift+F voila:
No more hard work setting the text to align as i want it.
Enjoy.

Mobile Web Debugging

In my current job, I became part of the FED (Front End Developers) community.
In Android there are great debugging tools, and the tools for FED development are improving more and more. I got to know WebKit’s Web Inspector (in Safari and Chrome) and learnt how to use them.
But when running the same web app on mobile devices, I encountered a wall… Suddenly I was compeled to use old fashion debugging techniques like print to log and alerts. Of course some devices don’t natively support even that and you need to implement your own print to log mechanism (fun fun fun).
But help came in the last few days in the name of Weinre. This is a great Web debugging tool that lets you remotely debug your mobile web application with most of the functionality of Web Inspector. Of course, since the “debugger” on the Web App side is actualy a JS script, you can’t put breakpoints and stuff like that, but it eases the working process tremendously.
So enjoy and good work Weinre guys…

Android Web Fragmentation

Everybody talks about Android fragmentation problem. Meaning, each device manufacture creates its own flavor of Android OS. The problems starts when they customize heavily leaving the developers struggling with changes in Application look and feel, and worse, in behavior. At WeFi I saw that a lot, when each device’s WiFi driver reacted differently though it had the same API for the developer. There is also fragmentation in the browsers arena, but I naively thought that choosing the browser as the platform will reduce fragmentation head ache. I couldn’t been more wrong! Not only there is difference in behavior between browsers in different Android devices running, what should be, the same OS version, there is a difference between the behavior between the WebView and the browser on the same device. I encountered performance variations, or to be exact, the WebView is much slower than the browser. This is due to different cache and memory handling (can’t take the credit for finding that out). Here is the link to the guy that posted a very interesting answer regarding performance boost to the WebView. Enjoy and happy fragmentation.

Android Soft Keyboard and WebViews

When adding input text area to an Android WebView, you don’t get the behavior you expect. The webview jumps up and down when the input text area is focused since the Soft Keyboard is opened. Also, you JavaScript code does not get notified when the keyboard is hidden (only when it is shown). I tried listening to window resize event, but with no luck. Looking for a solution to my problem I encountered this cool post. Simple and elegant. 10x Michael.