Properly detech the orientation of the device.

When the keyboard is shown the gridview will improperly
think the device is in landscape.