Wednesday, July 28, 2010

Supporting Multiple Android Version

Previously when considering new features for CedIME, I always hesitate about features that require a newer Android version like Voice Input. I want to support devices back to Android 1.5. And I thought it was tedious to manually support multiple code base for different versions of Android.

Now the smart people at Google has shown us the way! Using a method developed by Bill Pugh that was originally developed for implementing a lazy Singleton pattern in Java. It can be modified slightly to accomplish the magic of selecting the right class to load for different runtime versions of Android.

This is much better than using reflection which is slow and ugly.

Using this method I've already made CedIME support multitouch as the Froyo keyboard on Android version 2.0 or above, which is coming in CedIME 1.2.0 together with some other Froyo keyboard features. Stay tuned.

Thursday, July 15, 2010

Froyo Keyboard 研究

Froyo 的 source code 早些時候已經 release 了。但是我這兩天才找到時間仔細去看看它有什麼新功能。這裡簡單整理一下,大家將來或者有可能在 CedIME 裡看到類似的功能。

可見的新功能有
Extended keypad for numeric+symbols keys
按著鍵盤任何位置然後向上掃,會顯示兩行新的鍵,有數字鍵及一些常用符號。

Drag on spacebar to switch language
如果在設定裡選擇了多種語言,則按著鍵盤 spacebar 然後左右掃可以轉換輸入語言。

隱藏的新功能
Multi-touch support
當用雙手打字的時候,有可能會發生手指在上一個按鍵還沒離開鍵盤的時候另一隻手指就已經按到下個鍵的情況,這種情況正常來說只能記錄到後來的按鍵。但 Froyo 的鍵盤專門對此做了處理,兩個按鍵都能夠成功輸入。

Larger hit area for next probable key
根據字典,Froyo 鍵盤會計算出下一個將會被輸入字母的機會率,然後暗地裡增加那個字母鍵的大小。例如我剛打: appl 。則下一個字母 e 的機會率會比 r 為高,如果你按到 r 鍵偏左的話就會輸出 e 而不是 r 。