aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorMohammadinamul Sheik <inamul@google.com>2015-04-13 23:49:43 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-04-13 23:49:43 +0000
commit70f0c721355cac78955bfa02549c0d4007358f3b (patch)
tree4d1cbc523558c83c2a7845ca3a61ff85262e067b /java/src
parent694f6dbd5392d447d7ddc79d4deba646e6050c6d (diff)
parentdb96122787a57632136566e2448c21aa96879955 (diff)
downloadlatinime-70f0c721355cac78955bfa02549c0d4007358f3b.tar.gz
latinime-70f0c721355cac78955bfa02549c0d4007358f3b.tar.xz
latinime-70f0c721355cac78955bfa02549c0d4007358f3b.zip
am db961227: Fix the NPE on selection string on unlearnWord
* commit 'db96122787a57632136566e2448c21aa96879955': Fix the NPE on selection string on unlearnWord
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java2
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java7
2 files changed, 7 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index 49c47d775..a123d282b 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -48,6 +48,7 @@ import com.android.inputmethod.latin.utils.SpannableStringUtils;
import com.android.inputmethod.latin.utils.TextRange;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* Enrichment class for InputConnection to simplify interaction and add functionality.
@@ -288,6 +289,7 @@ public final class RichInputConnection implements PrivateCommandPerformer {
}
}
+ @Nullable
public CharSequence getSelectedText(final int flags) {
return isConnected() ? mIC.getSelectedText(flags) : null;
}
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 4bee94ad4..324ae3a19 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -1089,8 +1089,11 @@ public final class InputLogic {
// If there is a selection, remove it.
// We also need to unlearn the selected text.
final CharSequence selection = mConnection.getSelectedText(0 /* 0 for no styles */);
- unlearnWord(selection.toString(), inputTransaction.mSettingsValues,
- Constants.EVENT_BACKSPACE);
+ if (!TextUtils.isEmpty(selection)) {
+ unlearnWord(selection.toString(), inputTransaction.mSettingsValues,
+ Constants.EVENT_BACKSPACE);
+ hasUnlearnedWordBeingDeleted = true;
+ }
final int numCharsDeleted = mConnection.getExpectedSelectionEnd()
- mConnection.getExpectedSelectionStart();
mConnection.setSelection(mConnection.getExpectedSelectionEnd(),