am db961227: Fix the NPE on selection string on unlearnWord
* commit 'db96122787a57632136566e2448c21aa96879955': Fix the NPE on selection string on unlearnWordmain
commit
70f0c72135
|
@ -48,6 +48,7 @@ import com.android.inputmethod.latin.utils.SpannableStringUtils;
|
||||||
import com.android.inputmethod.latin.utils.TextRange;
|
import com.android.inputmethod.latin.utils.TextRange;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enrichment class for InputConnection to simplify interaction and add functionality.
|
* 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) {
|
public CharSequence getSelectedText(final int flags) {
|
||||||
return isConnected() ? mIC.getSelectedText(flags) : null;
|
return isConnected() ? mIC.getSelectedText(flags) : null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1089,8 +1089,11 @@ public final class InputLogic {
|
||||||
// If there is a selection, remove it.
|
// If there is a selection, remove it.
|
||||||
// We also need to unlearn the selected text.
|
// We also need to unlearn the selected text.
|
||||||
final CharSequence selection = mConnection.getSelectedText(0 /* 0 for no styles */);
|
final CharSequence selection = mConnection.getSelectedText(0 /* 0 for no styles */);
|
||||||
unlearnWord(selection.toString(), inputTransaction.mSettingsValues,
|
if (!TextUtils.isEmpty(selection)) {
|
||||||
Constants.EVENT_BACKSPACE);
|
unlearnWord(selection.toString(), inputTransaction.mSettingsValues,
|
||||||
|
Constants.EVENT_BACKSPACE);
|
||||||
|
hasUnlearnedWordBeingDeleted = true;
|
||||||
|
}
|
||||||
final int numCharsDeleted = mConnection.getExpectedSelectionEnd()
|
final int numCharsDeleted = mConnection.getExpectedSelectionEnd()
|
||||||
- mConnection.getExpectedSelectionStart();
|
- mConnection.getExpectedSelectionStart();
|
||||||
mConnection.setSelection(mConnection.getExpectedSelectionEnd(),
|
mConnection.setSelection(mConnection.getExpectedSelectionEnd(),
|
||||||
|
|
Loading…
Reference in New Issue