am eed74b81: am c8383eda: Fix wrong commitText parameter in sendKeyCodePoint()
* commit 'eed74b81a6a8d7de11ae2411817546bdd886ae0a': Fix wrong commitText parameter in sendKeyCodePoint()main
commit
3a3bbf4a38
|
@ -99,6 +99,7 @@ import com.android.inputmethod.latin.utils.JniUtils;
|
||||||
import com.android.inputmethod.latin.utils.LatinImeLoggerUtils;
|
import com.android.inputmethod.latin.utils.LatinImeLoggerUtils;
|
||||||
import com.android.inputmethod.latin.utils.RecapitalizeStatus;
|
import com.android.inputmethod.latin.utils.RecapitalizeStatus;
|
||||||
import com.android.inputmethod.latin.utils.StaticInnerHandlerWrapper;
|
import com.android.inputmethod.latin.utils.StaticInnerHandlerWrapper;
|
||||||
|
import com.android.inputmethod.latin.utils.StringUtils;
|
||||||
import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
||||||
import com.android.inputmethod.latin.utils.TextRange;
|
import com.android.inputmethod.latin.utils.TextRange;
|
||||||
import com.android.inputmethod.latin.utils.UserHistoryForgettingCurveUtils;
|
import com.android.inputmethod.latin.utils.UserHistoryForgettingCurveUtils;
|
||||||
|
@ -1586,8 +1587,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// relying on this behavior so we continue to support it for older apps.
|
// relying on this behavior so we continue to support it for older apps.
|
||||||
sendDownUpKeyEvent(KeyEvent.KEYCODE_ENTER);
|
sendDownUpKeyEvent(KeyEvent.KEYCODE_ENTER);
|
||||||
} else {
|
} else {
|
||||||
final String text = new String(new int[] { code }, 0, 1);
|
mConnection.commitText(StringUtils.newSingleCodePointString(code), 1);
|
||||||
mConnection.commitText(text, text.length());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2335,11 +2335,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
if (mWordComposer.isComposingWord()) { // May have changed since we stored wasComposing
|
if (mWordComposer.isComposingWord()) { // May have changed since we stored wasComposing
|
||||||
if (currentSettings.mCorrectionEnabled) {
|
if (currentSettings.mCorrectionEnabled) {
|
||||||
final String separator = shouldAvoidSendingCode ? LastComposedWord.NOT_A_SEPARATOR
|
final String separator = shouldAvoidSendingCode ? LastComposedWord.NOT_A_SEPARATOR
|
||||||
: new String(new int[] { primaryCode }, 0, 1);
|
: StringUtils.newSingleCodePointString(primaryCode);
|
||||||
commitCurrentAutoCorrection(separator);
|
commitCurrentAutoCorrection(separator);
|
||||||
didAutoCorrect = true;
|
didAutoCorrect = true;
|
||||||
} else {
|
} else {
|
||||||
commitTyped(new String(new int[]{primaryCode}, 0, 1));
|
commitTyped(StringUtils.newSingleCodePointString(primaryCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,16 @@ public final class StringUtils {
|
||||||
return text.codePointCount(0, text.length());
|
return text.codePointCount(0, text.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String newSingleCodePointString(int codePoint) {
|
||||||
|
if (Character.charCount(codePoint) == 1) {
|
||||||
|
// Optimization: avoid creating an temporary array for characters that are
|
||||||
|
// represented by a single char value
|
||||||
|
return String.valueOf((char) codePoint);
|
||||||
|
}
|
||||||
|
// For surrogate pair
|
||||||
|
return new String(Character.toChars(codePoint));
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean containsInArray(final String text, final String[] array) {
|
public static boolean containsInArray(final String text, final String[] array) {
|
||||||
for (final String element : array) {
|
for (final String element : array) {
|
||||||
if (text.equals(element)) return true;
|
if (text.equals(element)) return true;
|
||||||
|
|
Loading…
Reference in New Issue