aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java2
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java5
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestionsView.java91
3 files changed, 34 insertions, 64 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 5a44460a1..8d34b7ee1 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -84,7 +84,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
private final float mBackgroundDimAmount;
// HORIZONTAL ELLIPSIS "...", character for popup hint.
- private static final String POPUP_HINT_CHAR = "\u2026";
+ private static final String POPUP_HINT_CHAR = "...";
// Margin between the label and the icon on a key that has both of them.
// Specified by the fraction of the key width.
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 91a784124..5ccf6b795 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -618,6 +618,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mSuggestionsView = (SuggestionsView) view.findViewById(R.id.suggestions_view);
if (mSuggestionsView != null)
mSuggestionsView.setListener(this, view);
+ if (LatinImeLogger.sVISUALDEBUG) {
+ mKeyPreviewBackingView.setBackgroundColor(0x10FF0000);
+ }
}
@Override
@@ -1494,8 +1497,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (!TextUtils.isEmpty(typedWord) && !typedWord.equals(mBestWord)) {
InputConnectionCompatUtils.commitCorrection(
ic, mLastSelectionEnd - typedWord.length(), typedWord, mBestWord);
- if (mSuggestionsView != null)
- mSuggestionsView.onAutoCorrectionInverted(mBestWord);
}
}
if (Keyboard.CODE_SPACE == primaryCode) {
diff --git a/java/src/com/android/inputmethod/latin/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java
index fbb277372..776cea26a 100644
--- a/java/src/com/android/inputmethod/latin/SuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java
@@ -35,12 +35,11 @@ import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
-import android.text.style.BackgroundColorSpan;
import android.text.style.CharacterStyle;
-import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;
import android.util.AttributeSet;
+import android.view.GestureDetector;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -92,7 +91,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
private Listener mListener;
private SuggestedWords mSuggestions = SuggestedWords.EMPTY;
- private boolean mShowingAutoCorrectionInverted;
private final SuggestionsViewParams mParams;
private static final float MIN_TEXT_XSCALE = 0.70f;
@@ -101,10 +99,8 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
private static class UiHandler extends StaticInnerHandlerWrapper<SuggestionsView> {
private static final int MSG_HIDE_PREVIEW = 0;
- private static final int MSG_UPDATE_SUGGESTION = 1;
private static final long DELAY_HIDE_PREVIEW = 1300;
- private static final long DELAY_UPDATE_SUGGESTION = 300;
public UiHandler(SuggestionsView outerInstance) {
super(outerInstance);
@@ -117,9 +113,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
case MSG_HIDE_PREVIEW:
suggestionsView.hidePreview();
break;
- case MSG_UPDATE_SUGGESTION:
- suggestionsView.updateSuggestions();
- break;
}
}
@@ -132,19 +125,8 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
removeMessages(MSG_HIDE_PREVIEW);
}
- public void postUpdateSuggestions() {
- cancelUpdateSuggestions();
- sendMessageDelayed(obtainMessage(MSG_UPDATE_SUGGESTION),
- DELAY_UPDATE_SUGGESTION);
- }
-
- public void cancelUpdateSuggestions() {
- removeMessages(MSG_UPDATE_SUGGESTION);
- }
-
public void cancelAllMessages() {
cancelHidePreview();
- cancelUpdateSuggestions();
}
}
@@ -173,16 +155,13 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
private final float mCenterSuggestionWeight;
private final int mCenterSuggestionIndex;
private final Drawable mMoreSuggestionsHint;
- private static final String MORE_SUGGESTIONS_HINT = "\u2026";
+ private static final String MORE_SUGGESTIONS_HINT = "...";
private static final CharacterStyle BOLD_SPAN = new StyleSpan(Typeface.BOLD);
private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan();
- private final CharacterStyle mInvertedForegroundColorSpan;
- private final CharacterStyle mInvertedBackgroundColorSpan;
private static final int AUTO_CORRECT_BOLD = 0x01;
private static final int AUTO_CORRECT_UNDERLINE = 0x02;
- private static final int AUTO_CORRECT_INVERT = 0x04;
- private static final int VALID_TYPED_WORD_BOLD = 0x08;
+ private static final int VALID_TYPED_WORD_BOLD = 0x04;
private final int mSuggestionStripOption;
@@ -245,9 +224,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
mMoreSuggestionsBottomGap = res.getDimensionPixelOffset(
R.dimen.more_suggestions_bottom_gap);
- mInvertedForegroundColorSpan = new ForegroundColorSpan(mColorTypedWord ^ 0x00ffffff);
- mInvertedBackgroundColorSpan = new BackgroundColorSpan(mColorTypedWord);
-
final LayoutInflater inflater = LayoutInflater.from(context);
mWordToSaveView = (TextView)inflater.inflate(R.layout.suggestion_word, null);
mHintToSaveView = (TextView)inflater.inflate(R.layout.suggestion_word, null);
@@ -261,7 +237,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
paint.setTextSize(textSize);
paint.setColor(color);
final Rect bounds = new Rect();
- paint.getTextBounds(MORE_SUGGESTIONS_HINT, 0, 1, bounds);
+ paint.getTextBounds(MORE_SUGGESTIONS_HINT, 0, MORE_SUGGESTIONS_HINT.length(), bounds);
final int width = Math.round(bounds.width() + 0.5f);
final int height = Math.round(bounds.height() + 0.5f);
final Bitmap buffer = Bitmap.createBitmap(
@@ -345,16 +321,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
return Color.argb(newAlpha, Color.red(color), Color.green(color), Color.blue(color));
}
- public CharSequence getInvertedText(CharSequence text) {
- if ((mSuggestionStripOption & AUTO_CORRECT_INVERT) == 0)
- return null;
- final int len = text.length();
- final Spannable word = new SpannableString(text);
- word.setSpan(mInvertedBackgroundColorSpan, 0, len, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
- word.setSpan(mInvertedForegroundColorSpan, 0, len, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
- return word;
- }
-
public void layout(SuggestedWords suggestions, ViewGroup stripView, ViewGroup placer,
int stripWidth) {
if (suggestions.isPunctuationSuggestions()) {
@@ -547,6 +513,8 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
final Resources res = context.getResources();
mMoreSuggestionsModalTolerance = res.getDimensionPixelOffset(
R.dimen.more_suggestions_modal_tolerance);
+ mMoreSuggestionsSlidingDetector = new GestureDetector(
+ context, mMoreSuggestionsSlidingListener);
}
private final View.OnTouchListener mMoreSuggestionsCanceller = new View.OnTouchListener() {
@@ -574,21 +542,11 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
}
public void setSuggestions(SuggestedWords suggestions) {
- if (suggestions == null)
+ if (suggestions == null || suggestions.size() == 0)
return;
- mSuggestions = suggestions;
- if (mShowingAutoCorrectionInverted) {
- mHandler.postUpdateSuggestions();
- } else {
- updateSuggestions();
- }
- }
- private void updateSuggestions() {
clear();
- if (mSuggestions.size() == 0)
- return;
-
+ mSuggestions = suggestions;
mParams.layout(mSuggestions, mSuggestionsStrip, this, getWidth());
}
@@ -677,15 +635,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
}
}
- public void onAutoCorrectionInverted(CharSequence autoCorrectedWord) {
- final CharSequence inverted = mParams.getInvertedText(autoCorrectedWord);
- if (inverted == null)
- return;
- final TextView tv = mWords.get(1);
- tv.setText(inverted);
- mShowingAutoCorrectionInverted = true;
- }
-
public boolean isShowingAddToDictionaryHint() {
return mSuggestionsStrip.getChildCount() > 0
&& mSuggestionsStrip.getChildAt(0) == mParams.mWordToSaveView;
@@ -709,7 +658,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
}
public void clear() {
- mShowingAutoCorrectionInverted = false;
mSuggestionsStrip.removeAllViews();
removeAllViews();
addView(mSuggestionsStrip);
@@ -791,6 +739,10 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
@Override
public boolean onLongClick(View view) {
+ return showMoreSuggestions();
+ }
+
+ private boolean showMoreSuggestions() {
final SuggestionsViewParams params = mParams;
if (params.mMoreSuggestionsAvailable) {
final int stripWidth = getWidth();
@@ -814,9 +766,11 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
mMoreSuggestionsMode = MORE_SUGGESTIONS_CHECKING_MODAL_OR_SLIDING;
mOriginX = mLastX;
mOriginY = mLastY;
- view.setPressed(false);
mKeyboardView.dimEntireKeyboard(true);
mKeyboardView.setOnTouchListener(mMoreSuggestionsCanceller);
+ for (int i = 0; i < params.mSuggestionsCountInStrip; i++) {
+ mWords.get(i).setPressed(false);
+ }
return true;
}
return false;
@@ -832,6 +786,18 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
private int mOriginX;
private int mOriginY;
private final int mMoreSuggestionsModalTolerance;
+ private final GestureDetector mMoreSuggestionsSlidingDetector;
+ private final GestureDetector.OnGestureListener mMoreSuggestionsSlidingListener =
+ new GestureDetector.SimpleOnGestureListener() {
+ @Override
+ public boolean onScroll(MotionEvent down, MotionEvent me, float deltaX, float deltaY) {
+ final float dy = me.getY() - down.getY();
+ if (deltaY > 0 && dy < 0) {
+ return showMoreSuggestions();
+ }
+ return false;
+ }
+ };
@Override
public boolean dispatchTouchEvent(MotionEvent me) {
@@ -839,6 +805,9 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|| mMoreSuggestionsMode == MORE_SUGGESTIONS_IN_MODAL_MODE) {
mLastX = (int)me.getX();
mLastY = (int)me.getY();
+ if (mMoreSuggestionsSlidingDetector.onTouchEvent(me)) {
+ return true;
+ }
return super.dispatchTouchEvent(me);
}