Monday, February 25, 2013

Adding photography grid lines in GIMP

In photography, the "Rule of thirds" suggests places for optimal visual interest. You divide the photo into nine equal parts, like a tic-tac-toe board. The rule says that the most important visual elements must be at the dividing lines, or along the lines of the tic-tac-toe. This is an easy rule, and helps to determine how best to crop an image, or to judge a composition.

GIMP, the free image editor, allows the user to create guide lines. These are lines shown for reference while editing an image. They do not modify the underlying image, and can be dragged out from the ruler or created using a menu item. Gimp also allows certain edits to stick to guide lines. This is useful if you are adding text, or adding layers as it makes it easy to align visual elements in an appealing manner.

I find it helpful to create rule of thirds guide lines to evaluate photographs. Rather than manually drag out guide lines, I have written a GIMP script to automatically create such rule-of-thirds guide lines. This is what the result looks like.

To use, download the rule-of-thirds script and copy it to your local scripts directory. On my machine, this is $HOME/.gimp-2.6/scripts. The exact location depends on your platform (Windows/Linux/Mac) and Gimp version. You can find out the exact location by going to [Menu] -> Edit -> Preferences -> Folders -> Scripts.

Now start gimp and navigate to [Menu] -> Filters -> Script-Fu -> Refresh scripts.

Once it is refreshed, the rule of thirds guide lines should be available under [Menu] -> Images -> Guides -> Photography.

Tuesday, February 12, 2013

Customers want control over their mobile device

Disclaimer: I'm a Google employee.

"The average consumer doesn't care about whether their mobile device is locked down"

I've heard this argument very often. However, the data just doesn't support it. Over the last week, the hacker group evasi0n released a program to jailbreak an iOS device. iOS devices (iPhones and iPads) are closed down: Apple chooses which programs can be installed by device owners. A jailbreak removes this restriction, and allows the device owner to install any program of their choice on their device.

The initial justification for such unprecedented control was that the phone network could not handle poorly written applications. This argument was bogus even when the iPhone came out. At that time, arbitrary applications could be executed on existing phones. Palm Treo and Blackberry both allowed the device owner to choose which applications to run. Not all applications were passed through careful scrutiny: the device owner could write his own application and run it on the device. With the advent of Android, this argument is even more hollow. Google sells Android devices on which the user can not just install any application, but also install any system software.

Other justifications claim that users want a third-party to control their experience and are willing to submit control of their own devices. The data suggests otherwise. The hack by evasi0n was downloaded by four million unique devices in just five days. We don't have any concrete numbers for iOS 6.x devices, but let's try to use people's estimates to arrive at how significant the five million figure is.

Apple announced the number of iOS devices in October 2011: 250 Million.
Rough numbers for devices runing iOS version 6.x: 100 Million.

So 5% of the total user base chose to jailbreak their device within the first four days. There are lots of caveats: the figures are all guess-work (the fact that the numbers are nice round figures should also make you suspicious). We don't know the exact number of 6.x devices, and Jay Freeman, the creator of Cydia, admits that many jailbreakers weren't counted because the jailbreak servers crumbled under the heavy load.

Even so, 5% of the users want control over their own device. And that's within a week of the jailbreak being available. A very conservative estimate is that another 5 million users jailbreak their device. So 10% of the users choose to control their own device. (This is again a rough guess, since total iOS version 6.x devices is a moving target.)

Keep in mind that the entire idea of a jailbreak is somewhat scary. I suspect most users would hesitate to download a program from an unknown website and run it on a costly phone or tablet. Put another way, the number of users who want to jailbreak their device is larger than the ones that do perform the jailbreak.

When one in ten of your users wants something, it isn't a fringe phenomenon anymore. They are sending you a strong message: that they want control over their own device.

Monday, February 11, 2013

Android framework debugging through IntelliJ

I had blogged earlier about using the Android Open Source Project (AOSP) to learn about the Android framework, and help debug your Android applications.

I missed out how easy it is to do this through IntelliJ, the other popular IDE.

IntelliJ is an IDE that was released in 2001, and has boasted an impressive feature set. It started out as a paid product and a community edition was released in 2009, along with source code licensed under the Apache License 2.0. A commercial version is still sold, and that includes enterprise support. For an Android developer's perspective, the community edition is a great product to use for all Android development. This post shows how to get set up and start debugging your project with full cross-references into the AOSP framework code.  This is a great way to learn the intricacies of the framework.

Installing IntelliJ IDEA

  1. Download IntelliJ IDEA community edition for your platform. Linux, Mac and Windows versions are available. At the time of writing this post, version 12 was the latest.
  2. Install it according to the instructions for your platform.

Set up JDK

Android development needs a Java Development Kit installed on the device. I choose to use Sun's Java 1.6, but you are free to use any JDK of your choice.
Configure -> Settings -> Project
It will say "No SDK". Click on New and select the path to your jdk. This is probably in /usr/local/sun-java-1.6, or somewhere else.

Set Android SDK

You should also have the Android SDK downloaded. If you need to download the SDK, notice that you need just the SDK for other IDEs, not the entire ADT. Say you unzip it into /usr/local/android-sdk-linux:
export ANDROID_SDK=/usr/local/android-sdk/linux

Create a new project on the previous screen.

On the following screen, create an "Android Application Module" and set the location of the Android SDK:

The project name doesn't much matter. You could create a Hello World project for the purpose of this guide. After clicking no "New", you need to set it to the path of the Android sdk, which is the location where you expanded the Android SDK zip file: ${ANDROID_SDK}.  You can change this setting later under  Menu bar -> File -> Other Settings -> Default Project Settings -> Platform Settings SDKs -> Project Structure.
This can also be set on a per-project basis. However, you should never need to change the SDK location. Instead, you can change the Build Target to the version of Android you wish to support. A single SDK location can hold multiple build targets (Starting from the earliest version of Android all the way to the latest.
At the end of this, you should have a Hello World Android project. IntelliJ supports looking up code sources if you have downloaded the sources with the SDK. To verify, run ${ANDROID_SDK}/tools/android
Select the sources for the Android build targets you need.

Debug with framework source

At this point, you are ready to debug using the framework source. Highlight any framework code (like Activity, or Context) and hit Ctrl+B. It will take you to the source for that class. Sometimes documentation can be vague, and the definitive word is the source. You can also use the source to learn how canonical classes like ListView or DialogFragment are written. Looking at framework code is a very powerful way of learning good coding practices and system paradigms.

Happy hacking!