Merge "Fix key preview backing view height"
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 5a44460..8d34b7e 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -84,7 +84,7 @@
     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 fbb2773..d7e7d59 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.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 @@
         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 @@
             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 @@
         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 @@
 
     @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 @@
             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 @@
     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 @@
                 || mMoreSuggestionsMode == MORE_SUGGESTIONS_IN_MODAL_MODE) {
             mLastX = (int)me.getX();
             mLastY = (int)me.getY();
+            if (mMoreSuggestionsSlidingDetector.onTouchEvent(me)) {
+                return true;
+            }
             return super.dispatchTouchEvent(me);
         }