From 30ce6f0530d125309da3fd28d24cc1f74419f74e Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Fri, 16 Jul 2010 11:36:20 -0700 Subject: [PATCH 1/4] Fix sim build NDK does not support sim build. Change-Id: If3164399d72786c9445cd308376497b8ba76011c --- native/Android.mk | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/native/Android.mk b/native/Android.mk index b2944699c..6bad9d638 100644 --- a/native/Android.mk +++ b/native/Android.mk @@ -8,8 +8,13 @@ LOCAL_SRC_FILES := \ src/dictionary.cpp \ src/char_utils.cpp -LOCAL_NDK_VERSION := 4 -LOCAL_SDK_VERSION := 8 +# NDK does not support sim build. +ifneq ($(TARGET_SIMULATOR),true) + LOCAL_NDK_VERSION := 4 + LOCAL_SDK_VERSION := 8 +else + LOCAL_C_INCLUDES += $(JNI_H_INCLUDE) +endif LOCAL_MODULE := libjni_latinime From 8b96a9a238875767a46400902006540cb54f8d9b Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Thu, 15 Jul 2010 16:02:31 -0700 Subject: [PATCH 2/4] Underlining for correction is causing problems with styled text. Disable for now. Disable until we find a cleaner solution to highlighting for correction (may need a framework change). Removed a check for VoiceInput.DELETE_SYMBOL, which is not in use any more. --- .../android/inputmethod/latin/LatinIME.java | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 51fb9d876..783805e2b 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -82,6 +82,7 @@ public class LatinIME extends InputMethodService static final boolean TRACE = false; static final boolean VOICE_INSTALLED = 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_SOUND_ON = "sound_on"; @@ -1604,7 +1605,7 @@ public class LatinIME extends InputMethodService if (mBestWord != null && mBestWord.length() > 0) { TextEntryState.acceptedDefault(mWord.getTypedWord(), mBestWord); mJustAccepted = true; - pickSuggestion(mBestWord); + pickSuggestion(mBestWord, false); // Add the word to the auto dictionary if it's not a known word checkAddToDictionary(mBestWord, AutoDictionary.FREQUENCY_FOR_TYPED); } @@ -1650,7 +1651,7 @@ public class LatinIME extends InputMethodService return; } mJustAccepted = true; - pickSuggestion(suggestion); + pickSuggestion(suggestion, correcting); // Add the word to the auto dictionary if it's not a known word if (index == 0) { checkAddToDictionary(suggestion, AutoDictionary.FREQUENCY_FOR_PICKED); @@ -1696,7 +1697,15 @@ public class LatinIME extends InputMethodService // 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) { if (mCapsLock) { suggestion = suggestion.toString().toUpperCase(); } else if (preferCapitalization() @@ -1707,9 +1716,17 @@ public class LatinIME extends InputMethodService InputConnection ic = getCurrentInputConnection(); if (ic != null) { rememberReplacedWord(suggestion); - if (!VoiceInput.DELETE_SYMBOL.equals(suggestion)) { - ic.commitText(suggestion, 1); + // If text is in correction mode and we're not using composing + // 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); mPredicting = false; @@ -1828,9 +1845,11 @@ public class LatinIME extends InputMethodService private void underlineWord(CharSequence word, int left, int right) { InputConnection ic = getCurrentInputConnection(); if (ic == null) return; - ic.finishComposingText(); - ic.deleteSurroundingText(left, right); - ic.setComposingText(word, 1); + if (MODIFY_TEXT_FOR_CORRECTION) { + ic.finishComposingText(); + ic.deleteSurroundingText(left, right); + ic.setComposingText(word, 1); + } ic.setSelection(mLastSelectionStart, mLastSelectionStart); } From 88e7b49fc8657544380620729eb28966669103a2 Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Sat, 17 Jul 2010 09:51:26 +0900 Subject: [PATCH 3/4] Backport https://android-git.corp.google.com/g/#change,52371 to Froyo. Fix bug: 2693836 - Russian keyboard is missing a letter Change-Id: Ic931991bc188f646d30a399bb0b268f415f12051 --- java/res/xml-ru/kbd_qwerty.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/res/xml-ru/kbd_qwerty.xml b/java/res/xml-ru/kbd_qwerty.xml index cbb518f24..9773a305f 100755 --- a/java/res/xml-ru/kbd_qwerty.xml +++ b/java/res/xml-ru/kbd_qwerty.xml @@ -70,7 +70,9 @@ - + Date: Fri, 16 Jul 2010 17:45:39 -0700 Subject: [PATCH 4/4] Slightly reluctant to scroll candidate strip to be able to easily choose the suggestion Also fixed the comment of mMinTouchableWidth Bug: 2581826 Change-Id: Idc79186b0647b0e7e7ec889488b019b7db5241ad --- .../android/inputmethod/latin/CandidateView.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java index ae45001b8..93966a86c 100755 --- a/java/src/com/android/inputmethod/latin/CandidateView.java +++ b/java/src/com/android/inputmethod/latin/CandidateView.java @@ -144,9 +144,13 @@ public class CandidateView extends View { mPaint.setStrokeWidth(0); mPaint.setTextAlign(Align.CENTER); 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); + // 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() { @Override public void onLongPress(MotionEvent me) { @@ -160,6 +164,13 @@ public class CandidateView extends View { @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, 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(); mScrolled = true; int scrollX = getScrollX();