diff options
author | 2010-05-11 10:37:11 +0900 | |
---|---|---|
committer | 2010-05-11 10:37:11 +0900 | |
commit | 912fb384da5fe3b84ac0ef8e5d1d3a70a84c7b5b (patch) | |
tree | 86d176921943215c6ff688f5fd7475b1ca30573e /java | |
parent | ee2ab40c7a5609f5bc7a8a066b666fcb86d2f498 (diff) | |
parent | 44357b74a3b7b3eaa5390d1a7427642bcf52dcf9 (diff) | |
download | latinime-912fb384da5fe3b84ac0ef8e5d1d3a70a84c7b5b.tar.gz latinime-912fb384da5fe3b84ac0ef8e5d1d3a70a84c7b5b.tar.xz latinime-912fb384da5fe3b84ac0ef8e5d1d3a70a84c7b5b.zip |
Merge commit 'goog/master'
Diffstat (limited to 'java')
-rw-r--r-- | java/proguard.flags | 5 | ||||
-rwxr-xr-x | java/res/xml-iw/kbd_qwerty.xml | 12 | ||||
-rw-r--r-- | java/res/xml/method.xml | 2 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionary.java | 20 | ||||
-rwxr-xr-x | java/src/com/android/inputmethod/latin/Suggest.java | 21 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/WordComposer.java | 2 |
6 files changed, 47 insertions, 15 deletions
diff --git a/java/proguard.flags b/java/proguard.flags index 0a5d2dda9..829a096c0 100644 --- a/java/proguard.flags +++ b/java/proguard.flags @@ -1,3 +1,8 @@ -keep class com.android.inputmethod.latin.BinaryDictionary { int mDictLength; + <init>(...); +} + +-keep class com.android.inputmethod.latin.Suggest { + <init>(...); } diff --git a/java/res/xml-iw/kbd_qwerty.xml b/java/res/xml-iw/kbd_qwerty.xml index 3cec7cda4..b893f1a62 100755 --- a/java/res/xml-iw/kbd_qwerty.xml +++ b/java/res/xml-iw/kbd_qwerty.xml @@ -94,11 +94,11 @@ <Key android:keyLabel="/" android:keyWidth="10%p"/> <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="20%p" android:isRepeatable="true"/> - <Key android:keyLabel="@string/popular_domain_0" + android:keyWidth="40%p" android:isRepeatable="true"/> + <!--Key android:keyLabel="@string/popular_domain_0" android:keyOutputText="@string/popular_domain_0" android:popupKeyboard="@xml/popup_domains" - android:keyWidth="20%p"/> + android:keyWidth="20%p"/--> <Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation" android:keyWidth="10%p"/> <Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return" @@ -114,11 +114,11 @@ <Key android:keyLabel="\@" android:keyWidth="10%p"/> <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" android:iconPreview="@drawable/sym_keyboard_feedback_space" - android:keyWidth="20%p" android:isRepeatable="true"/> - <Key android:keyLabel="@string/popular_domain_0" + android:keyWidth="40%p" android:isRepeatable="true"/> + <!--Key android:keyLabel="@string/popular_domain_0" android:keyOutputText="@string/popular_domain_0" android:popupKeyboard="@xml/popup_domains" - android:keyWidth="20%p"/> + android:keyWidth="20%p"/--> <Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/> <Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return" android:iconPreview="@drawable/sym_keyboard_feedback_return" diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index 195691b7b..e5654e96d 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -22,5 +22,5 @@ <input-method xmlns:android="http://schemas.android.com/apk/res/android" android:settingsActivity="com.android.inputmethod.latin.LatinIMESettings" - android:isDefault="true" + android:isDefault="@bool/im_is_default" /> diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index dc5417e8e..5d3df4e6c 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -68,6 +68,26 @@ public class BinaryDictionary extends Dictionary { } } + /** + * Create a dictionary from a byte buffer. This is used for testing. + * @param context application context for reading resources + * @param resId the resource containing the raw binary dictionary + */ + public BinaryDictionary(Context context, ByteBuffer byteBuffer) { + if (byteBuffer != null) { + if (byteBuffer.isDirect()) { + mNativeDictDirectBuffer = byteBuffer; + } else { + mNativeDictDirectBuffer = ByteBuffer.allocateDirect(byteBuffer.capacity()); + byteBuffer.rewind(); + mNativeDictDirectBuffer.put(byteBuffer); + } + mDictLength = byteBuffer.capacity(); + mNativeDict = openNative(mNativeDictDirectBuffer, + TYPED_LETTER_MULTIPLIER, FULL_WORD_FREQ_MULTIPLIER); + } + } + private native int openNative(ByteBuffer bb, int typedLetterMultiplier, int fullWordMultiplier); private native void closeNative(int dict); private native boolean isValidWordNative(int nativeData, char[] word, int wordLength); diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index a70bea003..010913d6d 100755 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -16,18 +16,17 @@ package com.android.inputmethod.latin; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import android.content.Context; import android.text.AutoText; import android.text.TextUtils; import android.util.Log; import android.view.View; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import com.android.inputmethod.latin.WordComposer; - /** * This class loads a dictionary and provides a list of suggestions for a given sequence of * characters. This includes corrections and completions. @@ -69,9 +68,17 @@ public class Suggest implements Dictionary.WordCallback { private int mCorrectionMode = CORRECTION_BASIC; - public Suggest(Context context, int dictionaryResId) { mMainDict = new BinaryDictionary(context, dictionaryResId); + initPool(); + } + + public Suggest(Context context, ByteBuffer byteBuffer) { + mMainDict = new BinaryDictionary(context, byteBuffer); + initPool(); + } + + private void initPool() { for (int i = 0; i < mPrefMaxSuggestions; i++) { StringBuilder sb = new StringBuilder(32); mStringPool.add(sb); diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index 19f714ae7..2547aa133 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -44,7 +44,7 @@ public class WordComposer { */ private boolean mIsCapitalized; - WordComposer() { + public WordComposer() { mCodes = new ArrayList<int[]>(12); mTypedWord = new StringBuilder(20); } |