Properly detect the orientation of the device.

When the keyboard is shown the gridview will improperly
think the device is in landscape.
Merge remote-tracking branch 'jstralko/master'