aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r--java/src/com/android/inputmethod/latin/MoreSuggestionsView.java18
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestionsView.java37
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java26
3 files changed, 31 insertions, 50 deletions
diff --git a/java/src/com/android/inputmethod/latin/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/MoreSuggestionsView.java
index 5a2eb1632..51f6c040d 100644
--- a/java/src/com/android/inputmethod/latin/MoreSuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/MoreSuggestionsView.java
@@ -163,8 +163,6 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel {
- (container.getMeasuredHeight() - container.getPaddingBottom())
+ parentView.getPaddingTop() + mCoordinates[1];
- window.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
- window.setOutsideTouchable(true);
window.setContentView(container);
window.setWidth(container.getMeasuredWidth());
window.setHeight(container.getMeasuredHeight());
@@ -221,22 +219,6 @@ public class MoreSuggestionsView extends KeyboardView implements MoreKeysPanel {
};
@Override
- public boolean dispatchTouchEvent(MotionEvent me) {
- final int index = me.getActionIndex();
- final int id = me.getPointerId(index);
- final PointerTracker tracker = PointerTracker.getPointerTracker(id, this);
- final int x = (int)me.getX(index);
- final int y = (int)me.getY(index);
- final boolean inside = (x >= 0 && x < getWidth() && y >= 0 && y < getHeight());
- if (inside || tracker.isInSlidingKeyInput()) {
- return super.dispatchTouchEvent(me);
- } else {
- dismissMoreKeysPanel();
- return true;
- }
- }
-
- @Override
public boolean onTouchEvent(MotionEvent me) {
final int action = me.getAction();
final long eventTime = me.getEventTime();
diff --git a/java/src/com/android/inputmethod/latin/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java
index 9d0e42a18..fe54f4ae1 100644
--- a/java/src/com/android/inputmethod/latin/SuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java
@@ -27,6 +27,7 @@ import android.graphics.Paint.Align;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Message;
import android.os.SystemClock;
@@ -506,10 +507,22 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
mMoreSuggestionsView = (MoreSuggestionsView)mMoreSuggestionsContainer
.findViewById(R.id.more_suggestions_view);
mMoreSuggestionsBuilder = new MoreSuggestions.Builder(mMoreSuggestionsView);
- mMoreSuggestionsWindow = new PopupWindow(context);
- mMoreSuggestionsWindow.setWindowLayoutMode(
+
+ final PopupWindow moreWindow = new PopupWindow(context);
+ moreWindow.setWindowLayoutMode(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- mMoreSuggestionsWindow.setBackgroundDrawable(null);
+ moreWindow.setBackgroundDrawable(new ColorDrawable(android.R.color.transparent));
+ moreWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
+ moreWindow.setFocusable(true);
+ moreWindow.setOutsideTouchable(true);
+ moreWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
+ @Override
+ public void onDismiss() {
+ mKeyboardView.dimEntireKeyboard(false);
+ }
+ });
+ mMoreSuggestionsWindow = moreWindow;
+
final Resources res = context.getResources();
mMoreSuggestionsModalTolerance = res.getDimensionPixelOffset(
R.dimen.more_suggestions_modal_tolerance);
@@ -517,21 +530,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
context, mMoreSuggestionsSlidingListener);
}
- private final View.OnTouchListener mMoreSuggestionsCanceller = new View.OnTouchListener() {
- @Override
- public boolean onTouch(View view, MotionEvent me) {
- if (!mMoreSuggestionsWindow.isShowing()) return false;
-
- switch (me.getAction()) {
- case MotionEvent.ACTION_UP:
- case MotionEvent.ACTION_POINTER_UP:
- return mMoreSuggestionsView.dismissMoreKeysPanel();
- default:
- return true;
- }
- }
- };
-
/**
* A connection back to the input method.
* @param listener
@@ -726,8 +724,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
private boolean dismissMoreSuggestions() {
if (mMoreSuggestionsWindow.isShowing()) {
mMoreSuggestionsWindow.dismiss();
- mKeyboardView.dimEntireKeyboard(false);
- mKeyboardView.setOnTouchListener(null);
return true;
}
return false;
@@ -767,7 +763,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
mOriginX = mLastX;
mOriginY = mLastY;
mKeyboardView.dimEntireKeyboard(true);
- mKeyboardView.setOnTouchListener(mMoreSuggestionsCanceller);
for (int i = 0; i < params.mSuggestionsCountInStrip; i++) {
mWords.get(i).setPressed(false);
}
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index 2546df0a2..37145b257 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -95,6 +95,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
private final int DEFAULT_SUGGESTION_LENGTH = 16;
private final ArrayList<CharSequence> mSuggestions;
private final int[] mScores;
+ private final String mOriginalText;
+ private final double mThreshold;
private final int mMaxLength;
private int mLength = 0;
@@ -103,7 +105,10 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
private String mBestSuggestion = null;
private int mBestScore = Integer.MIN_VALUE; // As small as possible
- SuggestionsGatherer(final int maxLength) {
+ SuggestionsGatherer(final String originalText, final double threshold,
+ final int maxLength) {
+ mOriginalText = originalText;
+ mThreshold = threshold;
mMaxLength = maxLength;
mSuggestions = new ArrayList<CharSequence>(maxLength + 1);
mScores = new int[mMaxLength];
@@ -146,8 +151,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
return true;
}
- public Result getResults(final CharSequence originalText, final double threshold,
- final int capitalizeType, final Locale locale) {
+ public Result getResults(final int capitalizeType, final Locale locale) {
final String[] gatheredSuggestions;
final boolean hasLikelySuggestions;
if (0 == mLength) {
@@ -160,8 +164,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
} else {
gatheredSuggestions = EMPTY_STRING_ARRAY;
final double normalizedScore =
- Utils.calcNormalizedScore(originalText, mBestSuggestion, mBestScore);
- hasLikelySuggestions = (normalizedScore > threshold);
+ Utils.calcNormalizedScore(mOriginalText, mBestSuggestion, mBestScore);
+ hasLikelySuggestions = (normalizedScore > mThreshold);
}
} else {
if (DBG) {
@@ -194,11 +198,11 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
final int bestScore = mScores[mLength - 1];
final CharSequence bestSuggestion = mSuggestions.get(0);
final double normalizedScore =
- Utils.calcNormalizedScore(originalText, bestSuggestion, bestScore);
- hasLikelySuggestions = (normalizedScore > threshold);
+ Utils.calcNormalizedScore(mOriginalText, bestSuggestion, bestScore);
+ hasLikelySuggestions = (normalizedScore > mThreshold);
if (DBG) {
Log.i(TAG, "Best suggestion : " + bestSuggestion + ", score " + bestScore);
- Log.i(TAG, "Normalized score = " + normalizedScore + " (threshold " + threshold
+ Log.i(TAG, "Normalized score = " + normalizedScore + " (threshold " + mThreshold
+ ") => hasLikelySuggestions = " + hasLikelySuggestions);
}
}
@@ -351,7 +355,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
// TODO: Don't gather suggestions if the limit is <= 0 unless necessary
final SuggestionsGatherer suggestionsGatherer =
- new SuggestionsGatherer(suggestionsLimit);
+ new SuggestionsGatherer(text, mService.mTypoThreshold, suggestionsLimit);
final WordComposer composer = new WordComposer();
final int length = text.length();
for (int i = 0; i < length; ++i) {
@@ -392,8 +396,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
}
}
- final SuggestionsGatherer.Result result = suggestionsGatherer.getResults(text,
- mService.mTypoThreshold, capitalizeType, mLocale);
+ final SuggestionsGatherer.Result result = suggestionsGatherer.getResults(
+ capitalizeType, mLocale);
if (DBG) {
Log.i(TAG, "Spell checking results for " + text + " with suggestion limit "