Merge remote-tracking branch 'goog/master' into mergescriptpackage
commit
f4eb4f0c79
|
@ -1,3 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2012 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
coreApp="true"
|
coreApp="true"
|
||||||
package="com.android.inputmethod.latin">
|
package="com.android.inputmethod.latin">
|
||||||
|
|
|
@ -64,6 +64,20 @@ public interface KeyboardActionListener {
|
||||||
*/
|
*/
|
||||||
public void onTextInput(CharSequence text);
|
public void onTextInput(CharSequence text);
|
||||||
|
|
||||||
|
// TODO: Should move this method to some more appropriate interface.
|
||||||
|
/**
|
||||||
|
* Called when user started batch input.
|
||||||
|
*/
|
||||||
|
public void onStartBatchInput();
|
||||||
|
|
||||||
|
// TODO: Should move this method to some more appropriate interface.
|
||||||
|
/**
|
||||||
|
* Sends a sequence of characters to the listener as batch input.
|
||||||
|
*
|
||||||
|
* @param text the sequence of characters to be displayed as composing text.
|
||||||
|
*/
|
||||||
|
public void onEndBatchInput(CharSequence text);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when user released a finger outside any key.
|
* Called when user released a finger outside any key.
|
||||||
*/
|
*/
|
||||||
|
@ -85,6 +99,10 @@ public interface KeyboardActionListener {
|
||||||
@Override
|
@Override
|
||||||
public void onTextInput(CharSequence text) {}
|
public void onTextInput(CharSequence text) {}
|
||||||
@Override
|
@Override
|
||||||
|
public void onStartBatchInput() {}
|
||||||
|
@Override
|
||||||
|
public void onEndBatchInput(CharSequence text) {}
|
||||||
|
@Override
|
||||||
public void onCancelInput() {}
|
public void onCancelInput() {}
|
||||||
@Override
|
@Override
|
||||||
public boolean onCustomRequest(int requestCode) {
|
public boolean onCustomRequest(int requestCode) {
|
||||||
|
|
|
@ -57,6 +57,16 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
|
||||||
mListener.onTextInput(text);
|
mListener.onTextInput(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartBatchInput() {
|
||||||
|
mListener.onStartBatchInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEndBatchInput(CharSequence text) {
|
||||||
|
mListener.onEndBatchInput(text);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancelInput() {
|
public void onCancelInput() {
|
||||||
mListener.onCancelInput();
|
mListener.onCancelInput();
|
||||||
|
|
|
@ -1272,6 +1272,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
if (mCurrentSettings.isWordSeparator(primaryCode)) {
|
if (mCurrentSettings.isWordSeparator(primaryCode)) {
|
||||||
didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState);
|
didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState);
|
||||||
} else {
|
} else {
|
||||||
|
if (SPACE_STATE_PHANTOM == spaceState) {
|
||||||
|
commitTyped(LastComposedWord.NOT_A_SEPARATOR);
|
||||||
|
}
|
||||||
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
|
||||||
if (keyboard != null && keyboard.hasProximityCharsCorrection(primaryCode)) {
|
if (keyboard != null && keyboard.hasProximityCharsCorrection(primaryCode)) {
|
||||||
handleCharacter(primaryCode, x, y, spaceState);
|
handleCharacter(primaryCode, x, y, spaceState);
|
||||||
|
@ -1313,6 +1316,31 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
resetComposingState(true /* alsoResetLastComposedWord */);
|
resetComposingState(true /* alsoResetLastComposedWord */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartBatchInput() {
|
||||||
|
mConnection.beginBatchEdit();
|
||||||
|
if (mWordComposer.isComposingWord()) {
|
||||||
|
commitTyped(LastComposedWord.NOT_A_SEPARATOR);
|
||||||
|
mExpectingUpdateSelection = true;
|
||||||
|
// TODO: Can we remove this?
|
||||||
|
mSpaceState = SPACE_STATE_PHANTOM;
|
||||||
|
}
|
||||||
|
mConnection.endBatchEdit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEndBatchInput(CharSequence text) {
|
||||||
|
mConnection.beginBatchEdit();
|
||||||
|
if (SPACE_STATE_PHANTOM == mSpaceState) {
|
||||||
|
sendKeyCodePoint(Keyboard.CODE_SPACE);
|
||||||
|
}
|
||||||
|
mConnection.setComposingText(text, 1);
|
||||||
|
mExpectingUpdateSelection = true;
|
||||||
|
mConnection.endBatchEdit();
|
||||||
|
mKeyboardSwitcher.updateShiftState();
|
||||||
|
mSpaceState = SPACE_STATE_PHANTOM;
|
||||||
|
}
|
||||||
|
|
||||||
private CharSequence specificTldProcessingOnTextInput(final CharSequence text) {
|
private CharSequence specificTldProcessingOnTextInput(final CharSequence text) {
|
||||||
if (text.length() <= 1 || text.charAt(0) != Keyboard.CODE_PERIOD
|
if (text.length() <= 1 || text.charAt(0) != Keyboard.CODE_PERIOD
|
||||||
|| !Character.isLetter(text.charAt(1))) {
|
|| !Character.isLetter(text.charAt(1))) {
|
||||||
|
@ -1359,7 +1387,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
if (mWordComposer.isComposingWord()) {
|
if (mWordComposer.isComposingWord()) {
|
||||||
final int length = mWordComposer.size();
|
final int length = mWordComposer.size();
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
|
// Immediately after a batch input.
|
||||||
|
if (SPACE_STATE_PHANTOM == spaceState) {
|
||||||
|
mWordComposer.reset();
|
||||||
|
} else {
|
||||||
mWordComposer.deleteLast();
|
mWordComposer.deleteLast();
|
||||||
|
}
|
||||||
mConnection.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1);
|
mConnection.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1);
|
||||||
// If we have deleted the last remaining character of a word, then we are not
|
// If we have deleted the last remaining character of a word, then we are not
|
||||||
// isComposingWord() any more.
|
// isComposingWord() any more.
|
||||||
|
@ -1523,27 +1556,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
swapSwapperAndSpace();
|
swapSwapperAndSpace();
|
||||||
mSpaceState = SPACE_STATE_WEAK;
|
mSpaceState = SPACE_STATE_WEAK;
|
||||||
}
|
}
|
||||||
// Some characters are not word separators, yet they don't start a new
|
// We may need to update predictions, if the "add to dictionary" hint was displayed
|
||||||
// composing span. For these, we haven't changed the suggestion strip, and
|
// for example.
|
||||||
// if the "add to dictionary" hint is shown, we should do so now. Examples of
|
if (null != mSuggestionsView) mSuggestionsView.dismissAddToDictionaryHint();
|
||||||
// such characters include single quote, dollar, and others; the exact list is
|
|
||||||
// the list of characters for which we enter handleCharacterWhileInBatchEdit
|
|
||||||
// that don't match the test if ((isAlphabet...)) at the top of this method.
|
|
||||||
if (null != mSuggestionsView && mSuggestionsView.dismissAddToDictionaryHint()) {
|
|
||||||
mHandler.postUpdateBigramPredictions();
|
mHandler.postUpdateBigramPredictions();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Utils.Stats.onNonSeparator((char)primaryCode, x, y);
|
Utils.Stats.onNonSeparator((char)primaryCode, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if we did an autocorrection, false otherwise.
|
// Returns true if we did an autocorrection, false otherwise.
|
||||||
private boolean handleSeparator(final int primaryCode, final int x, final int y,
|
private boolean handleSeparator(final int primaryCode, final int x, final int y,
|
||||||
final int spaceState) {
|
final int spaceState) {
|
||||||
// Should dismiss the "Touch again to save" message when handling separator
|
|
||||||
if (mSuggestionsView != null && mSuggestionsView.dismissAddToDictionaryHint()) {
|
|
||||||
mHandler.postUpdateSuggestions();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean didAutoCorrect = false;
|
boolean didAutoCorrect = false;
|
||||||
// Handle separator
|
// Handle separator
|
||||||
if (mWordComposer.isComposingWord()) {
|
if (mWordComposer.isComposingWord()) {
|
||||||
|
@ -1799,6 +1822,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mConnection.beginBatchEdit();
|
||||||
if (SPACE_STATE_PHANTOM == mSpaceState && suggestion.length() > 0) {
|
if (SPACE_STATE_PHANTOM == mSpaceState && suggestion.length() > 0) {
|
||||||
int firstChar = Character.codePointAt(suggestion, 0);
|
int firstChar = Character.codePointAt(suggestion, 0);
|
||||||
if ((!mCurrentSettings.isWeakSpaceStripper(firstChar))
|
if ((!mCurrentSettings.isWeakSpaceStripper(firstChar))
|
||||||
|
@ -1816,7 +1840,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mKeyboardSwitcher.updateShiftState();
|
mKeyboardSwitcher.updateShiftState();
|
||||||
resetComposingState(true /* alsoResetLastComposedWord */);
|
resetComposingState(true /* alsoResetLastComposedWord */);
|
||||||
final CompletionInfo completionInfo = mApplicationSpecifiedCompletions[index];
|
final CompletionInfo completionInfo = mApplicationSpecifiedCompletions[index];
|
||||||
mConnection.beginBatchEdit();
|
|
||||||
mConnection.commitCompletion(completionInfo);
|
mConnection.commitCompletion(completionInfo);
|
||||||
mConnection.endBatchEdit();
|
mConnection.endBatchEdit();
|
||||||
if (ProductionFlag.IS_EXPERIMENTAL) {
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
||||||
|
@ -1837,6 +1860,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mExpectingUpdateSelection = true;
|
mExpectingUpdateSelection = true;
|
||||||
commitChosenWord(suggestion, LastComposedWord.COMMIT_TYPE_MANUAL_PICK,
|
commitChosenWord(suggestion, LastComposedWord.COMMIT_TYPE_MANUAL_PICK,
|
||||||
LastComposedWord.NOT_A_SEPARATOR);
|
LastComposedWord.NOT_A_SEPARATOR);
|
||||||
|
mConnection.endBatchEdit();
|
||||||
// Don't allow cancellation of manual pick
|
// Don't allow cancellation of manual pick
|
||||||
mLastComposedWord.deactivate();
|
mLastComposedWord.deactivate();
|
||||||
mSpaceState = SPACE_STATE_PHANTOM;
|
mSpaceState = SPACE_STATE_PHANTOM;
|
||||||
|
@ -2025,7 +2049,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// Since we just changed languages, we should re-evaluate suggestions with whatever word
|
// Since we just changed languages, we should re-evaluate suggestions with whatever word
|
||||||
// we are currently composing. If we are not composing anything, we may want to display
|
// we are currently composing. If we are not composing anything, we may want to display
|
||||||
// predictions or punctuation signs (which is done by updateBigramPredictions anyway).
|
// predictions or punctuation signs (which is done by updateBigramPredictions anyway).
|
||||||
if (mConnection.isCursorTouchingWord(mCurrentSettings)) {
|
if (mWordComposer.isComposingWord()) {
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
} else {
|
} else {
|
||||||
mHandler.postUpdateBigramPredictions();
|
mHandler.postUpdateBigramPredictions();
|
||||||
|
|
Loading…
Reference in New Issue