am 15142588: Merge "Have "no whitespace before cursor" upon gesture trigger phantom space" into jb-mr1-dev
* commit '15142588244a10b241f5d3691f80b6540f3f3fc3': Have "no whitespace before cursor" upon gesture trigger phantom spacemain
commit
63b3fc0d23
|
@ -1429,6 +1429,12 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
// The following is necessary for the case where the user typed something but didn't
|
// The following is necessary for the case where the user typed something but didn't
|
||||||
// manual pick it and didn't input any separator.
|
// manual pick it and didn't input any separator.
|
||||||
mSpaceState = SPACE_STATE_PHANTOM;
|
mSpaceState = SPACE_STATE_PHANTOM;
|
||||||
|
} else {
|
||||||
|
final int codePointBeforeCursor = mConnection.getCodePointBeforeCursor();
|
||||||
|
if (Constants.NOT_A_CODE != codePointBeforeCursor
|
||||||
|
&& !Character.isWhitespace(codePointBeforeCursor)) {
|
||||||
|
mSpaceState = SPACE_STATE_PHANTOM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mConnection.endBatchEdit();
|
mConnection.endBatchEdit();
|
||||||
mWordComposer.setCapitalizedModeAtStartComposingTime(getActualCapsMode());
|
mWordComposer.setCapitalizedModeAtStartComposingTime(getActualCapsMode());
|
||||||
|
@ -1564,6 +1570,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
// We have a TLD (or something that looks like this): make sure we don't add
|
// We have a TLD (or something that looks like this): make sure we don't add
|
||||||
// a space even if currently in phantom mode.
|
// a space even if currently in phantom mode.
|
||||||
mSpaceState = SPACE_STATE_NONE;
|
mSpaceState = SPACE_STATE_NONE;
|
||||||
|
// TODO: use getCodePointBeforeCursor instead to improve performance and simplify the code
|
||||||
final CharSequence lastOne = mConnection.getTextBeforeCursor(1, 0);
|
final CharSequence lastOne = mConnection.getTextBeforeCursor(1, 0);
|
||||||
if (lastOne != null && lastOne.length() == 1
|
if (lastOne != null && lastOne.length() == 1
|
||||||
&& lastOne.charAt(0) == Keyboard.CODE_PERIOD) {
|
&& lastOne.charAt(0) == Keyboard.CODE_PERIOD) {
|
||||||
|
@ -2284,6 +2291,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
// This is a stopgap solution to avoid leaving a high surrogate alone in a text view.
|
// This is a stopgap solution to avoid leaving a high surrogate alone in a text view.
|
||||||
// In the future, we need to deprecate deteleSurroundingText() and have a surrogate
|
// In the future, we need to deprecate deteleSurroundingText() and have a surrogate
|
||||||
// pair-friendly way of deleting characters in InputConnection.
|
// pair-friendly way of deleting characters in InputConnection.
|
||||||
|
// TODO: use getCodePointBeforeCursor instead to improve performance
|
||||||
final CharSequence lastChar = mConnection.getTextBeforeCursor(1, 0);
|
final CharSequence lastChar = mConnection.getTextBeforeCursor(1, 0);
|
||||||
if (!TextUtils.isEmpty(lastChar) && Character.isHighSurrogate(lastChar.charAt(0))) {
|
if (!TextUtils.isEmpty(lastChar) && Character.isHighSurrogate(lastChar.charAt(0))) {
|
||||||
mConnection.deleteSurroundingText(1, 0);
|
mConnection.deleteSurroundingText(1, 0);
|
||||||
|
|
|
@ -235,7 +235,14 @@ public final class RichInputConnection {
|
||||||
hasSpaceBefore);
|
hasSpaceBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCodePointBeforeCursor() {
|
||||||
|
if (mCommittedTextBeforeComposingText.length() < 1) return Constants.NOT_A_CODE;
|
||||||
|
return Character.codePointBefore(mCommittedTextBeforeComposingText,
|
||||||
|
mCommittedTextBeforeComposingText.length());
|
||||||
|
}
|
||||||
|
|
||||||
public CharSequence getTextBeforeCursor(final int i, final int j) {
|
public CharSequence getTextBeforeCursor(final int i, final int j) {
|
||||||
|
// TODO: use mCommittedTextBeforeComposingText if possible to improve performance
|
||||||
mIC = mParent.getCurrentInputConnection();
|
mIC = mParent.getCurrentInputConnection();
|
||||||
if (null != mIC) return mIC.getTextBeforeCursor(i, j);
|
if (null != mIC) return mIC.getTextBeforeCursor(i, j);
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue