diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyboardView.java | 2 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/SuggestionsView.java | 30 |
2 files changed, 28 insertions, 4 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/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java index fbb277372..d7e7d5927 100644 --- a/java/src/com/android/inputmethod/latin/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java @@ -41,6 +41,7 @@ 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; @@ -173,7 +174,7 @@ 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(); @@ -261,7 +262,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( @@ -547,6 +548,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() { @@ -791,6 +794,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 +821,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 +841,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 +860,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); } |