Merge remote branch 'goog/master'
Conflicts: java/src/com/android/inputmethod/latin/LatinIME.javamain
commit
481a75fcfa
|
@ -143,9 +143,13 @@ public class CandidateView extends View {
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
mPaint.setTextAlign(Align.CENTER);
|
mPaint.setTextAlign(Align.CENTER);
|
||||||
mDescent = (int) mPaint.descent();
|
mDescent = (int) mPaint.descent();
|
||||||
// 80 pixels for a 160dpi device would mean half an inch
|
// 50 pixels for a 160dpi device would mean about 0.3 inch
|
||||||
mMinTouchableWidth = (int) (getResources().getDisplayMetrics().density * 50);
|
mMinTouchableWidth = (int) (getResources().getDisplayMetrics().density * 50);
|
||||||
|
|
||||||
|
// Slightly reluctant to scroll to be able to easily choose the suggestion
|
||||||
|
// 50 pixels for a 160dpi device would mean about 0.3 inch
|
||||||
|
final int touchSlop = (int) (getResources().getDisplayMetrics().density * 50);
|
||||||
|
final int touchSlopSquare = touchSlop * touchSlop;
|
||||||
mGestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
|
mGestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLongPress(MotionEvent me) {
|
public void onLongPress(MotionEvent me) {
|
||||||
|
@ -159,6 +163,13 @@ public class CandidateView extends View {
|
||||||
@Override
|
@Override
|
||||||
public boolean onScroll(MotionEvent e1, MotionEvent e2,
|
public boolean onScroll(MotionEvent e1, MotionEvent e2,
|
||||||
float distanceX, float distanceY) {
|
float distanceX, float distanceY) {
|
||||||
|
final int deltaX = (int) (e2.getX() - e1.getX());
|
||||||
|
final int deltaY = (int) (e2.getY() - e1.getY());
|
||||||
|
final int distance = (deltaX * deltaX) + (deltaY * deltaY);
|
||||||
|
if (distance < touchSlopSquare) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final int width = getWidth();
|
final int width = getWidth();
|
||||||
mScrolled = true;
|
mScrolled = true;
|
||||||
int scrollX = getScrollX();
|
int scrollX = getScrollX();
|
||||||
|
|
|
@ -81,6 +81,7 @@ public class LatinIME extends InputMethodService
|
||||||
static final boolean TRACE = false;
|
static final boolean TRACE = false;
|
||||||
static final boolean VOICE_INSTALLED = true;
|
static final boolean VOICE_INSTALLED = true;
|
||||||
static final boolean ENABLE_VOICE_BUTTON = true;
|
static final boolean ENABLE_VOICE_BUTTON = true;
|
||||||
|
private static final boolean MODIFY_TEXT_FOR_CORRECTION = false;
|
||||||
|
|
||||||
private static final String PREF_VIBRATE_ON = "vibrate_on";
|
private static final String PREF_VIBRATE_ON = "vibrate_on";
|
||||||
private static final String PREF_SOUND_ON = "sound_on";
|
private static final String PREF_SOUND_ON = "sound_on";
|
||||||
|
@ -1645,7 +1646,7 @@ public class LatinIME extends InputMethodService
|
||||||
if (mBestWord != null && mBestWord.length() > 0) {
|
if (mBestWord != null && mBestWord.length() > 0) {
|
||||||
TextEntryState.acceptedDefault(mWord.getTypedWord(), mBestWord);
|
TextEntryState.acceptedDefault(mWord.getTypedWord(), mBestWord);
|
||||||
mJustAccepted = true;
|
mJustAccepted = true;
|
||||||
pickSuggestion(mBestWord);
|
pickSuggestion(mBestWord, false);
|
||||||
// Add the word to the auto dictionary if it's not a known word
|
// Add the word to the auto dictionary if it's not a known word
|
||||||
checkAddToDictionary(mBestWord, AutoDictionary.FREQUENCY_FOR_TYPED);
|
checkAddToDictionary(mBestWord, AutoDictionary.FREQUENCY_FOR_TYPED);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1699,7 +1700,7 @@ public class LatinIME extends InputMethodService
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mJustAccepted = true;
|
mJustAccepted = true;
|
||||||
pickSuggestion(suggestion);
|
pickSuggestion(suggestion, correcting);
|
||||||
// Add the word to the auto dictionary if it's not a known word
|
// Add the word to the auto dictionary if it's not a known word
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
checkAddToDictionary(suggestion, AutoDictionary.FREQUENCY_FOR_PICKED);
|
checkAddToDictionary(suggestion, AutoDictionary.FREQUENCY_FOR_PICKED);
|
||||||
|
@ -1747,7 +1748,15 @@ public class LatinIME extends InputMethodService
|
||||||
// TODO: implement rememberReplacedWord for typed words
|
// TODO: implement rememberReplacedWord for typed words
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pickSuggestion(CharSequence suggestion) {
|
/**
|
||||||
|
* Commits the chosen word to the text field and saves it for later
|
||||||
|
* retrieval.
|
||||||
|
* @param suggestion the suggestion picked by the user to be committed to
|
||||||
|
* the text field
|
||||||
|
* @param correcting whether this is due to a correction of an existing
|
||||||
|
* word.
|
||||||
|
*/
|
||||||
|
private void pickSuggestion(CharSequence suggestion, boolean correcting) {
|
||||||
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
|
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
|
||||||
if (mCapsLock) {
|
if (mCapsLock) {
|
||||||
suggestion = suggestion.toString().toUpperCase();
|
suggestion = suggestion.toString().toUpperCase();
|
||||||
|
@ -1760,9 +1769,17 @@ public class LatinIME extends InputMethodService
|
||||||
InputConnection ic = getCurrentInputConnection();
|
InputConnection ic = getCurrentInputConnection();
|
||||||
if (ic != null) {
|
if (ic != null) {
|
||||||
rememberReplacedWord(suggestion);
|
rememberReplacedWord(suggestion);
|
||||||
if (!VoiceInput.DELETE_SYMBOL.equals(suggestion)) {
|
// If text is in correction mode and we're not using composing
|
||||||
ic.commitText(suggestion, 1);
|
// text to underline, then the word at the cursor position needs
|
||||||
|
// to be removed before committing the correction
|
||||||
|
if (correcting && !MODIFY_TEXT_FOR_CORRECTION) {
|
||||||
|
if (mLastSelectionStart < mLastSelectionEnd) {
|
||||||
|
ic.setSelection(mLastSelectionStart, mLastSelectionStart);
|
||||||
|
}
|
||||||
|
EditingUtil.deleteWordAtCursor(ic, getWordSeparators());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ic.commitText(suggestion, 1);
|
||||||
}
|
}
|
||||||
saveWordInHistory(suggestion);
|
saveWordInHistory(suggestion);
|
||||||
mPredicting = false;
|
mPredicting = false;
|
||||||
|
@ -1881,9 +1898,11 @@ public class LatinIME extends InputMethodService
|
||||||
private void underlineWord(CharSequence word, int left, int right) {
|
private void underlineWord(CharSequence word, int left, int right) {
|
||||||
InputConnection ic = getCurrentInputConnection();
|
InputConnection ic = getCurrentInputConnection();
|
||||||
if (ic == null) return;
|
if (ic == null) return;
|
||||||
ic.finishComposingText();
|
if (MODIFY_TEXT_FOR_CORRECTION) {
|
||||||
ic.deleteSurroundingText(left, right);
|
ic.finishComposingText();
|
||||||
ic.setComposingText(word, 1);
|
ic.deleteSurroundingText(left, right);
|
||||||
|
ic.setComposingText(word, 1);
|
||||||
|
}
|
||||||
ic.setSelection(mLastSelectionStart, mLastSelectionStart);
|
ic.setSelection(mLastSelectionStart, mLastSelectionStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,13 @@ LOCAL_SRC_FILES := \
|
||||||
src/dictionary.cpp \
|
src/dictionary.cpp \
|
||||||
src/char_utils.cpp
|
src/char_utils.cpp
|
||||||
|
|
||||||
LOCAL_NDK_VERSION := 4
|
# NDK does not support sim build.
|
||||||
LOCAL_SDK_VERSION := 8
|
ifneq ($(TARGET_SIMULATOR),true)
|
||||||
|
LOCAL_NDK_VERSION := 4
|
||||||
|
LOCAL_SDK_VERSION := 8
|
||||||
|
else
|
||||||
|
LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
|
||||||
|
endif
|
||||||
|
|
||||||
LOCAL_PRELINK_MODULE := false
|
LOCAL_PRELINK_MODULE := false
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue