bitquill - Spiros Papadimitriou
Warning: Can't synchronize with the repository (Unsupported version control system "svn": "libdb3.so.3: cannot open shared object file: No such file or directory" ). Look in the Trac log for more information.

Greek input method for Android

BETA TESTERS WANTED

Anyone who would like to volunteer for beta testing future versions, please email me with device information (want to ensure decent coverage of various Android versions). You'd be expected to install APKs from the web, and email me logcat output (you can use, e.g., the Log Collector app) if there are problems. Thanks!

Project on Google Code
Google Group
App on Cyrket

UPDATE ISSUE: There is a minor problem (see known issues) when updating from an older version. You may have to switch to another IME (e.g., Android keyboard) and then back to the Greek IME, to get the hardware keys to work properly. Or just try a different edit field (see known issues).

Greek input method extension (IME) for Android 1.5 that supports both a software (virtual) keyboard, as well as the hardware keyboard. I have a G1, and I needed to type Greek, so I hacked this together in a couple of evenings; any feedback is more than welcome, although I cannot promise anything. The code is mostly based on the LatinIME source, plus a couple of things from the PinyinIME sources.

Installation instructions

After you install the application, you must first enable the input method, by going to the phone's "Settings" pages, then into the "Locale & Text" category and checking the "Greek keyboard" option:

After this, you need to switch the input method to Greek. Merely enabling it will only make it available as an option in the input methods popup (see below), but it won't make it the active input method; you need to do that explicitly.

First option: Tap on a text entry field to bring up the software keyboard. Then long-press the symbol key to bring up the popup to select an input method. Tap on "Input method" and, in the next popup, tap on "Greek keyboard".

Second option: Long-press on any text entry field to bring up the text operations popup. One of the options is "Input method". Tap on that and, again, in the next popup, tap on "Greek keyboard".

That's it! Now you can type in Greek, in any application, using either the software keyboard, or your device's hardware keyboard (if it has one).

Note for HTC Magic users: According to this discussion, longpressing the symbol key won't pop up the input method selection dialog. You need to use the second option.

Typing instructions

The input method supports both software and hardware keyboards. Most features should be relatively straightforward. Those that may be less so are described below.

In software keyboard mode, you can use the acute accent (οξεία) key to compose accented characters. Press the accent key a second time to compose characters with diaeresis (διαλυτικά). Press yet one more time to compose characters with both accents. If a character is not composable with the particular accent, an unaccented version will be inserted.

Alternatively you can enter accented characters by double-tapping (for acute) or multi-tapping the corresponding vowel. Tap timing is important (unlike the accent key): if not fast enough, you'll enter the same character twice. You can also long-press a softkey to get a popup keyboard displaying all the options.

In hardware keyboard mode, an icon in the notification area indicates the active language (this is taken from PinyinIME). You can switch languages by simultaneously pressing shift and space (please note, both keys have to be pressed at the same time, not one after the other). Because the G1 has no semicolon key, Q doubles as an accent compose key. Again, you can press the accent key (Q or semicolon) multiple times for different types of accent.

Predictive input with auto-correction

The feature is based on the LatinIME implementation (with some minor modifications to get it to compile with the Android NDK). The piece missing was a dictionary with word frequencies, used for ranking suggestions. I used the Greek Wikipedia corpus to obtain frequency counts, and cross-referenced them with the Greek aspell dictionary to clean up invalid or mistyped words. Thus there is an unavoidable bias towards encyclopedia vocabulary (e.g., third person plural favored over first or second person singular, more archaic/formal forms preferred, etc.), but it works fairly well.

Note: If you have 7bit SMS/IM mode enabled, then predictions don't work (yet) for Greek when typing an SMS or IM.

Download

Binary release

The app is available on Android Market, under the name 'Greek Input Method'.

Source release

The source is available on Google Code, and distributed under the terms of Apache License 2.0, like LatinIME from which it is directly derived. Bug reports or, even better, patches are always appreciated! :-)


Poll results

Known issues

  • Dictionary for predictive input in English is not included in the APK, but loaded from the LatinIME APK. I'm assuming all phones have the dictionary in the same resource path (I used the path in T-Mobile's version, which is res/raw-en/main.dict). I probably should not be assuming this, but adding another 650KB to the APK is a bit too much (plus I'm not sure it's legal to just copy that dictionary into my APK, and I don't want to bother with building an English dictionary from scratch). In particular, the HTC Magic version of Android uses a different default IME; I don't have access to a device to fix this now.
  • No way to distinguish when the IME is called from an SMS application, or an IM application (both use EditorInfo.TYPE_TEXT_VARIATION_SHORT_MESSAGE). Thus, enabling the 7bit alphabet workaround will also restrict your alphabet in the instant messaging application, not just the SMS application.
  • Hardware shift and alt key behavior in Greek mode is not 100% identical to default behavior. However, it should be close enough, though. If you do see any really weird behavior, please let me know.
  • Soft shift state does not match hard key state (no fix planned: seems this can only be partially implemented with current APIs; anyway, you can't use both keyboards at the same time, except in the emulator).
  • Hardware key press translation may not work immediately after an update, under very specific circumstances. This is probably an Android bug. I get "IME died" log messages from InputManagerService, but only if I type into the edit field that had the last active connection to the IME and only if I use the hardware keyboard. I suspect that, after restarting the IME, Android does not rebind the RPC connection over which it forwards hardware keypress events. I decided not to spend more time on this, since it is a minor/transient problem.
  • [BUG] Accent compose key clears shift state.

SMS application issues

I'm having some trouble getting the Android SMS application (G1 on the T-Mobile US network) to send messages with non-Latin unicode characters. Although this would be an Android and/or T-Mobile issue and not an IME issue, if anyone else has problems, or has managed to send SMSs succesfully, please drop me a line (and let me know phone and carrier). Update (6/8): Ventrix informed me that the only safe way to send SMSes is by using only characters in the 7bit SMS alphabet. Did some further testing with upper- and lower-case Greek in SMS (which Android encodes using UCS2) and: (i) SMSes to myself on T-Mobile US go through, (ii) SMSes to Cosmote (and a new Nokia) go through, (iii) SMSes from Cosmote to me go through, (iv) SMSes to a G1 on AT&T are dropped, (v) SMSes from a G1 on AT&T are dropped, (vi) SMSes from a G1 on AT&T to itself go through (in Hangul, not Greek, but still Unicode).

Update (6/30): The IME has an option (enabled by default) that restricts input to characters available in the 7bit SMS alphabet. You can disable this if your carrier supports UCS2 encoding (and you don't mind the 70 character limit, since Unicode uses two bytes per character). The 7bit alphabet includes only upper case Greek glyphs that have no corresponding Latin glyph. No lower case and no accented characters are available. If this workaround is enabled, the IME will use this alphabet when invoked in "short message mode" (which includes the SMS as well as IM applications). YMMV, but this may not solve your problems (e.g., SMSes from T-Mobile to AT&T now go through for me, but Greek characters are mangled).

Frequently asked questions

Q. I get a "could not be launched" error.

A. An input method is a service, not a regular application. It is not meant to be launched. This input method allows you to enter Greek in any application; you don't have to open the application and copy/paste things around. Please read and follow the instructions above, on how to enable an input method.

Q. The application "doesn't work" / "doesn't do anything" / etc.

A. Please read and follow the instructions above, on how to enable input methods for your phone.

Q. SMS length is just 70 characters.

A. This is related to what character encoding is used. Android applications use UTF-16, like Java. The default SMS application on Android will try to translate all characters in your to the 7-bit SMS alphabet. If it fails on any character, it will fall back to UCS2 (i.e., UTF-16, which is a 2-byte alphabet). The 7bit SMS/IM keyboard mode relies on this fact, and tries to ensure that the translation to 7bit will succeed, by allowing you to type only characters included in that alphabet. Also, the IME will activate this restricted keyboard only if the application sets the SMS/IM mode flag (EditorInfo.TYPE_TEXT_VARIATION_SHORT_MESSAGE) for the text field.

The G1 on T-Mobile comes with the default application. However, I cannot guarantee that other carriers' customizations will preserve this behavior, nor that this hack will work with third-party SMS applications. Alphabet translation is really something that the SMS application should handle, not the IME. Please consider this as nothing more than a kludge to make up for omitted functionality in the SMS app. YMMV. Also, it seems that some third-party SMS applications don't set the TYPE_TEXT_VARIATION_SHORT_MESSAGE flag; please request a fix from developers of those applications. Finally, some carriers seem to discard SMSes that contain non-English carriers (I'm guessing based on tests, but couldn't find concrete information either way).

Changelog

  • v0.1a 6/3/2009
    • Initial release on Android Market
  • v0.1b 6/4/2009
    • Hardware key mapping bugfix
    • Clear shift state after Shift+Space
  • v0.2 6/30/2009
    • Add 7bit alphabet workaround for SMS (enabled by default, see options)
    • Improve accent composition (visual feedback, more options for diaeresis)
    • Auto-finalize lower-case sigma
    • Swap location of symbol and language change virtual keys, for consistency with other IMEs
  • v0.2.1 7/1/2009
    • Hardware shift and alt behave better
  • v0.2.2 7/2/2009
    • Fix reported bug (thanks!) in sigma auto-finalization (crash if first character entered was a word separator)
    • Respect EditorInfo caps mode when translating hardware keypresses
  • v0.9.0 8/3/2009
    • Predictive input with auto-correction (except for 7bit SMS/IM mode)
  • v0.9.1 8/3/2009
    • Crash fix for HTC Magic (thanks to Φάνης Ντόκος, Στράτος Ζολώτας, and malibu_undead for their help in tracking down the bug).

To Do

  • Add option for 7bit encoding when IME is called in SMS mode. [v0.2]
  • Swap symbol/language mode keys, to make layout more consistent with Latin IME. [v0.2]
  • Auto-finalization of lower-case sigma. [v0.2]
  • Fix shift and alt hardware keys. [v0.2.1]
  • Build dictionary using Greek Wikipedia for word frequencies (needed for suggestion ranking).
  • Predictive input. [v0.9.0]
  • Bugfix: hardware keyboard accent key should not change caps state.
  • Tentative: Simple part-of-speech recognition to improve suggestion ranking of different inflections.
  • Prediction for 7bit SMS/IM mode (or, completely get rid of this option; TBD, based on user feedback).
  • Hardware keyboard logic is a mess, with significant duplication of soft key logic: clean up!

Not planning any updates (other than bugfixes) in the near future; next major item is code cleanup, when/if I have time (you may have noticed that the releases come in bursts :-).

Attachments