diff options
author | 2013-08-07 03:35:08 -0700 | |
---|---|---|
committer | 2013-08-07 03:35:08 -0700 | |
commit | 72b5ff6645f9022065732ffc648e1ae28d62a1de (patch) | |
tree | 8d6312b6f24ca19b5874e5dd9aa72d676de31361 /java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java | |
parent | f6872b36017fd289af5d65caf0e04bfd671b9524 (diff) | |
parent | 083a40b291dbd4d63aabbcb4a1dc1ca27bb46863 (diff) | |
download | latinime-72b5ff6645f9022065732ffc648e1ae28d62a1de.tar.gz latinime-72b5ff6645f9022065732ffc648e1ae28d62a1de.tar.xz latinime-72b5ff6645f9022065732ffc648e1ae28d62a1de.zip |
am 083a40b2: Merge "Move createKeyboardSetForSpellChecker to AndroidSpellCheckService"
* commit '083a40b291dbd4d63aabbcb4a1dc1ca27bb46863':
Move createKeyboardSetForSpellChecker to AndroidSpellCheckService
Diffstat (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index 692e7392c..eb6d7c106 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -20,7 +20,10 @@ import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.service.textservice.SpellCheckerService; +import android.text.InputType; import android.util.Log; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; import android.view.textservice.SuggestionsInfo; import com.android.inputmethod.keyboard.KeyboardLayoutSet; @@ -33,6 +36,7 @@ import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SynchronouslyLoadedContactsBinaryDictionary; import com.android.inputmethod.latin.SynchronouslyLoadedUserBinaryDictionary; import com.android.inputmethod.latin.UserBinaryDictionary; +import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils; import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.LocaleUtils; import com.android.inputmethod.latin.utils.StringUtils; @@ -58,6 +62,9 @@ public final class AndroidSpellCheckerService extends SpellCheckerService public static final String PREF_USE_CONTACTS_KEY = "pref_spellcheck_use_contacts"; + private static final int SPELLCHECKER_DUMMY_KEYBOARD_WIDTH = 480; + private static final int SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT = 368; + private final static String[] EMPTY_STRING_ARRAY = new String[0]; private Map<String, DictionaryPool> mDictionaryPools = CollectionUtils.newSynchronizedTreeMap(); private Map<String, UserBinaryDictionary> mUserDictionaries = @@ -401,9 +408,9 @@ public final class AndroidSpellCheckerService extends SpellCheckerService public DictAndKeyboard createDictAndKeyboard(final Locale locale) { final int script = getScriptFromLocale(locale); final String keyboardLayoutName = getKeyboardLayoutNameForScript(script); - final KeyboardLayoutSet keyboardLayoutSet = - KeyboardLayoutSet.createKeyboardSetForSpellChecker(this, locale.toString(), - keyboardLayoutName); + final InputMethodSubtype subtype = AdditionalSubtypeUtils.createAdditionalSubtype( + locale.toString(), keyboardLayoutName, null); + final KeyboardLayoutSet keyboardLayoutSet = createKeyboardSetForSpellChecker(subtype); final DictionaryCollection dictionaryCollection = DictionaryFactory.createMainDictionaryFromManager(this, locale, @@ -431,4 +438,16 @@ public final class AndroidSpellCheckerService extends SpellCheckerService } return new DictAndKeyboard(dictionaryCollection, keyboardLayoutSet); } + + private KeyboardLayoutSet createKeyboardSetForSpellChecker(final InputMethodSubtype subtype) { + final EditorInfo editorInfo = new EditorInfo(); + editorInfo.inputType = InputType.TYPE_CLASS_TEXT; + final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(this, editorInfo); + builder.setKeyboardGeometry( + SPELLCHECKER_DUMMY_KEYBOARD_WIDTH, SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT); + builder.setSubtype(subtype); + builder.setIsSpellChecker(true /* isSpellChecker */); + builder.disableTouchPositionCorrectionData(); + return builder.build(); + } } |