merge in jb-mr1-release history after reset to jb-mr1-dev
diff --git a/dictionaries/en_gb_wordlist.xml.gz b/dictionaries/en_gb_wordlist.xml.gz
index 0b96771..927f2d1 100644
--- a/dictionaries/en_gb_wordlist.xml.gz
+++ b/dictionaries/en_gb_wordlist.xml.gz
Binary files differ
diff --git a/dictionaries/en_us_wordlist.xml.gz b/dictionaries/en_us_wordlist.xml.gz
index ea1cb72..4cad38b 100644
--- a/dictionaries/en_us_wordlist.xml.gz
+++ b/dictionaries/en_us_wordlist.xml.gz
Binary files differ
diff --git a/dictionaries/en_wordlist.xml.gz b/dictionaries/en_wordlist.xml.gz
index 2bc47f6..01dcc28 100644
--- a/dictionaries/en_wordlist.xml.gz
+++ b/dictionaries/en_wordlist.xml.gz
Binary files differ
diff --git a/java/res/raw/main_en.dict b/java/res/raw/main_en.dict
index 0cf5467..bd7737a 100644
--- a/java/res/raw/main_en.dict
+++ b/java/res/raw/main_en.dict
Binary files differ
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 88d7b66..e99e956 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -390,7 +390,11 @@
     }
 
     public int getManualCapsMode() {
-        switch (getKeyboard().mId.mElementId) {
+        final Keyboard keyboard = getKeyboard();
+        if (keyboard == null) {
+            return WordComposer.CAPS_MODE_OFF;
+        }
+        switch (keyboard.mId.mElementId) {
         case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED:
         case KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED:
             return WordComposer.CAPS_MODE_MANUAL_SHIFT_LOCKED;
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index e084cb3..7184f1d 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -187,6 +187,9 @@
     }
 
     public static int editDistance(String before, String after) {
+        if (before == null || after == null) {
+            throw new IllegalArgumentException();
+        }
         return editDistanceNative(before.toCharArray(), after.toCharArray());
     }
 
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 3113553..fe6ad49 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1910,6 +1910,10 @@
     }
 
     private SuggestedWords getSuggestedWords(final int sessionId) {
+        final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
+        if (keyboard == null) {
+            return SuggestedWords.EMPTY;
+        }
         final String typedWord = mWordComposer.getTypedWord();
         // Get the word on which we should search the bigrams. If we are composing a word, it's
         // whatever is *before* the half-committed word in the buffer, hence 2; if we aren't, we
@@ -1919,8 +1923,8 @@
                 mConnection.getNthPreviousWord(mCurrentSettings.mWordSeparators,
                 mWordComposer.isComposingWord() ? 2 : 1);
         final SuggestedWords suggestedWords = mSuggest.getSuggestedWords(mWordComposer,
-                prevWord, mKeyboardSwitcher.getKeyboard().getProximityInfo(),
-                mCurrentSettings.mCorrectionEnabled, sessionId);
+                prevWord, keyboard.getProximityInfo(), mCurrentSettings.mCorrectionEnabled,
+                sessionId);
         return maybeRetrieveOlderSuggestions(typedWord, suggestedWords);
     }
 
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index 8a1bbed..da0071a 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -177,14 +177,16 @@
      * Internal method to retrieve reasonable proximity info for a character.
      */
     private void addKeyInfo(final int codePoint, final Keyboard keyboard) {
-        final Key key = keyboard.getKey(codePoint);
-        if (key != null) {
-            final int x = key.mX + key.mWidth / 2;
-            final int y = key.mY + key.mHeight / 2;
-            add(codePoint, x, y);
-            return;
+        final int x, y;
+        final Key key;
+        if (keyboard != null && (key = keyboard.getKey(codePoint)) != null) {
+            x = key.mX + key.mWidth / 2;
+            y = key.mY + key.mHeight / 2;
+        } else {
+            x = Constants.NOT_A_COORDINATE;
+            y = Constants.NOT_A_COORDINATE;
         }
-        add(codePoint, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
+        add(codePoint, x, y);
     }
 
     /**
@@ -195,7 +197,7 @@
         reset();
         final int length = word.length();
         for (int i = 0; i < length; i = Character.offsetByCodePoints(word, i, 1)) {
-            int codePoint = Character.codePointAt(word, i);
+            final int codePoint = Character.codePointAt(word, i);
             addKeyInfo(codePoint, keyboard);
         }
         mIsResumed = true;