Improve type mode

See commit messages. This is a continuation of #610 and a fix for [2291](https://code.google.com/p/ankidroid/issues/detail?id=2291).