diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyboardView.java | 2 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/DictionaryFactory.java | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 71c4896a7..d23b8ff0e 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -526,7 +526,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { canvas.translate(-bgX, -bgY); // Draw key top visuals. - final int keyWidth = key.mWidth; + final int keyWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight; final int keyHeight = key.mHeight; final float centerX = keyWidth * 0.5f; final float centerY = keyHeight * 0.5f; diff --git a/java/src/com/android/inputmethod/latin/DictionaryFactory.java b/java/src/com/android/inputmethod/latin/DictionaryFactory.java index a35b0f5b0..f0637b8ce 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFactory.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFactory.java @@ -56,8 +56,11 @@ public class DictionaryFactory { BinaryDictionaryGetter.getDictionaryFiles(locale, context, fallbackResId); if (null != assetFileList) { for (final AssetFileAddress f : assetFileList) { - dictList.add( - new BinaryDictionary(context, f.mFilename, f.mOffset, f.mLength, null)); + final BinaryDictionary binaryDictionary = + new BinaryDictionary(context, f.mFilename, f.mOffset, f.mLength, null); + if (binaryDictionary.isValidDictionary()) { + dictList.add(binaryDictionary); + } } } @@ -67,7 +70,16 @@ public class DictionaryFactory { if (null == dictList) { return new DictionaryCollection(); } else { - return new DictionaryCollection(dictList); + if (dictList.isEmpty()) { + // The list may be empty if no dictionaries have been added. The getter should not + // return an empty list, but if it does we end up here. Likewise, if the files + // we found could not be opened by the native code for any reason (format mismatch, + // file too big to fit in memory, etc) then we could have an empty list. In this + // case we want to fall back on the resource. + return new DictionaryCollection(createBinaryDictionary(context, fallbackResId)); + } else { + return new DictionaryCollection(dictList); + } } } |