Merge "Cosmetic fixes and style fixes"
diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml
index 925eb55..b47897f 100644
--- a/java/res/values/dimens.xml
+++ b/java/res/values/dimens.xml
@@ -93,4 +93,12 @@
     <dimen name="more_suggestions_hint_text_size">27dp</dimen>
     <integer name="suggestions_count_in_strip">3</integer>
     <integer name="center_suggestion_percentile">36</integer>
+
+    <!-- Gesture preview parameters -->
+    <dimen name="gesture_preview_trail_width">2.5dp</dimen>
+    <dimen name="gesture_preview_text_size">35dp</dimen>
+    <dimen name="gesture_preview_text_offset">75dp</dimen>
+    <dimen name="gesture_preview_text_shadow_border">17.5dp</dimen>
+    <dimen name="gesture_preview_text_shading_border">7.5dp</dimen>
+    <dimen name="gesture_preview_text_connector_width">1.0dp</dimen>
 </resources>
diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml
index b1315c0..b448e00 100644
--- a/java/res/xml/method.xml
+++ b/java/res/xml/method.xml
@@ -64,6 +64,7 @@
     sr: Serbian/south_slavic
     (sr-Latn: Serbian/qwerty) # not yet implemented.
     sv: Swedish/nordic
+    sw: Swahili/qwerty
     th: Thai/thai
     tl: Tagalog/spanish
     tr: Turkish/qwerty
@@ -341,6 +342,12 @@
     />
     <subtype android:icon="@drawable/ic_subtype_keyboard"
             android:label="@string/subtype_generic"
+            android:imeSubtypeLocale="sw"
+            android:imeSubtypeMode="keyboard"
+            android:imeSubtypeExtraValue="KeyboardLayoutSet=qwerty,AsciiCapable"
+    />
+    <subtype android:icon="@drawable/ic_subtype_keyboard"
+            android:label="@string/subtype_generic"
             android:imeSubtypeLocale="th"
             android:imeSubtypeMode="keyboard"
             android:imeSubtypeExtraValue="KeyboardLayoutSet=thai"
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index a6c4392..f1f942c 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -35,9 +35,9 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.RelativeLayout;
 import android.widget.TextView;
 
+import com.android.inputmethod.keyboard.internal.PreviewPlacerView;
 import com.android.inputmethod.latin.Constants;
 import com.android.inputmethod.latin.LatinImeLogger;
 import com.android.inputmethod.latin.R;
@@ -97,9 +97,6 @@
     // The maximum key label width in the proportion to the key width.
     private static final float MAX_LABEL_RATIO = 0.90f;
 
-    private final static int GESTURE_DRAWING_WIDTH = 5;
-    private final static int GESTURE_DRAWING_COLOR = 0xff33b5e5;
-
     // Main keyboard
     private Keyboard mKeyboard;
     protected final KeyDrawParams mKeyDrawParams;
@@ -109,7 +106,7 @@
     protected final KeyPreviewDrawParams mKeyPreviewDrawParams;
     private boolean mShowKeyPreviewPopup = true;
     private int mDelayAfterPreview;
-    private ViewGroup mPreviewPlacer;
+    private PreviewPlacerView mPreviewPlacer;
 
     /** True if {@link KeyboardView} should handle gesture events. */
     protected boolean mShouldHandleGesture;
@@ -125,14 +122,11 @@
     private final HashSet<Key> mInvalidatedKeys = new HashSet<Key>();
     /** The region of invalidated keys */
     private final Rect mInvalidatedKeysRect = new Rect();
-    /** The region of invalidated gestures */
-    private final Rect mInvalidatedGesturesRect = new Rect();
     /** The keyboard bitmap buffer for faster updates */
     private Bitmap mBuffer;
     /** The canvas for the above mutable keyboard bitmap */
     private Canvas mCanvas;
     private final Paint mPaint = new Paint();
-    private final Paint mGesturePaint = new Paint();
     private final Paint.FontMetrics mFontMetrics = new Paint.FontMetrics();
     // This sparse array caches key label text height in pixel indexed by key label text size.
     private static final SparseArray<Float> sTextHeightCache = new SparseArray<Float>();
@@ -382,13 +376,6 @@
         mDelayAfterPreview = mKeyPreviewDrawParams.mLingerTimeout;
 
         mPaint.setAntiAlias(true);
-
-        // TODO: These paint parameters should be specified via attribute of the view and styleable.
-        mGesturePaint.setAntiAlias(true);
-        mGesturePaint.setStyle(Paint.Style.STROKE);
-        mGesturePaint.setStrokeJoin(Paint.Join.ROUND);
-        mGesturePaint.setColor(GESTURE_DRAWING_COLOR);
-        mGesturePaint.setStrokeWidth(GESTURE_DRAWING_WIDTH);
     }
 
     // Read fraction value in TypedArray as float.
@@ -888,26 +875,6 @@
         mDrawingHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
     }
 
-    private static class PreviewView extends RelativeLayout {
-        KeyPreviewDrawParams mParams;
-        Paint mGesturePaint;
-
-        public PreviewView(Context context, KeyPreviewDrawParams params, Paint gesturePaint) {
-            super(context);
-            setWillNotDraw(false);
-            mParams = params;
-            mGesturePaint = gesturePaint;
-        }
-
-        @Override
-        public void onDraw(Canvas canvas) {
-            super.onDraw(canvas);
-            canvas.translate(mParams.mCoordinates[0], mParams.mCoordinates[1]);
-            PointerTracker.drawGestureTrailForAllPointerTrackers(canvas, mGesturePaint);
-            canvas.translate(-mParams.mCoordinates[0], -mParams.mCoordinates[1]);
-        }
-    }
-
     private void addKeyPreview(TextView keyPreview) {
         if (mPreviewPlacer == null) {
             createPreviewPlacer();
@@ -917,29 +884,31 @@
     }
 
     private void createPreviewPlacer() {
-        mPreviewPlacer = new PreviewView(getContext(), mKeyPreviewDrawParams, mGesturePaint);
+        mPreviewPlacer = new PreviewPlacerView(getContext());
+        final int[] viewOrigin = new int[2];
+        getLocationInWindow(viewOrigin);
+        mPreviewPlacer.setOrigin(viewOrigin[0], viewOrigin[1]);
         final ViewGroup windowContentView =
                 (ViewGroup)getRootView().findViewById(android.R.id.content);
         windowContentView.addView(mPreviewPlacer);
     }
 
-    @Override
-    public void showGestureTrail(PointerTracker tracker) {
+    public void showGesturePreviewText(String gesturePreviewText) {
+        // TDOD: Add user settings option to control drawing gesture trail.
         if (mPreviewPlacer == null) {
             createPreviewPlacer();
         }
-        final Rect r = tracker.getBoundingBox();
-        if (!r.isEmpty()) {
-            // Invalidate the rectangular region encompassing the gesture. This is needed because
-            // past points along the gesture will fade and gradually disappear.
-            final KeyPreviewDrawParams params = mKeyPreviewDrawParams;
-            mInvalidatedGesturesRect.set(r);
-            mInvalidatedGesturesRect.offset(params.mCoordinates[0], params.mCoordinates[1]);
-            mInvalidatedGesturesRect.inset(-GESTURE_DRAWING_WIDTH, -GESTURE_DRAWING_WIDTH);
-            mPreviewPlacer.invalidate(mInvalidatedGesturesRect);
-        } else {
-            mPreviewPlacer.invalidate();
+        mPreviewPlacer.setGesturePreviewText(gesturePreviewText);
+        mPreviewPlacer.invalidate();
+    }
+
+    @Override
+    public void showGestureTrail(PointerTracker tracker) {
+        // TDOD: Add user settings option to control drawing gesture trail.
+        if (mPreviewPlacer == null) {
+            createPreviewPlacer();
         }
+        mPreviewPlacer.invalidatePointer(tracker);
     }
 
     @SuppressWarnings("deprecation") // setBackgroundDrawable is replaced by setBackground in API16
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index 56c3d46..67857d1 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -18,7 +18,6 @@
 
 import android.graphics.Canvas;
 import android.graphics.Paint;
-import android.graphics.Rect;
 import android.os.SystemClock;
 import android.util.Log;
 import android.view.MotionEvent;
@@ -296,17 +295,6 @@
         sAggregratedPointers.reset();
     }
 
-    // TODO: To handle multi-touch gestures we may want to move this method to
-    // {@link PointerTrackerQueue}.
-    public static void drawGestureTrailForAllPointerTrackers(Canvas canvas, Paint paint) {
-        final int trackersSize = sTrackers.size();
-        for (int i = 0; i < trackersSize; ++i) {
-            final PointerTracker tracker = sTrackers.get(i);
-            tracker.mGestureStroke.drawGestureTrail(canvas, paint, tracker.getLastX(),
-                    tracker.getLastY());
-        }
-    }
-
     private PointerTracker(int id, KeyEventHandler handler) {
         if (handler == null)
             throw new NullPointerException();
@@ -524,6 +512,12 @@
         mDrawingProxy.invalidateKey(key);
     }
 
+    public void drawGestureTrail(Canvas canvas, Paint paint) {
+        if (mInGesture) {
+            mGestureStroke.drawGestureTrail(canvas, paint, mLastX, mLastY);
+        }
+    }
+
     public int getLastX() {
         return mLastX;
     }
@@ -535,9 +529,6 @@
     public long getDownTime() {
         return mDownTime;
     }
-    public Rect getBoundingBox() {
-        return mGestureStroke.getBoundingBox();
-    }
 
     private Key onDownKey(int x, int y, long eventTime) {
         mDownTime = eventTime;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
index c16b70e..28d6c1d 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
@@ -16,7 +16,6 @@
 
 import android.graphics.Canvas;
 import android.graphics.Paint;
-import android.graphics.Rect;
 import android.util.FloatMath;
 
 import com.android.inputmethod.latin.Constants;
@@ -41,7 +40,6 @@
     private int mMinGestureLength;
     private int mMinGestureLengthWhileInGesture;
     private int mMinGestureSampleLength;
-    private final Rect mDrawingRect = new Rect();
 
     // TODO: Move some of these to resource.
     private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 1.0f;
@@ -90,7 +88,6 @@
         mEventTimes.setLength(0);
         mXCoordinates.setLength(0);
         mYCoordinates.setLength(0);
-        mDrawingRect.setEmpty();
     }
 
     private void updateLastPoint(final int x, final int y, final int time) {
@@ -198,8 +195,4 @@
             }
         }
     }
-
-    public Rect getBoundingBox() {
-        return mDrawingRect;
-    }
 }
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
index fc8939b..308e241 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
@@ -2188,6 +2188,56 @@
         /* 24 */ "\u00E6",
     };
 
+    /* Language sw: Swahili */
+    private static final String[] LANGUAGE_sw = {
+        // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
+        // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
+        // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
+        // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
+        // U+00E6: "æ" LATIN SMALL LETTER AE
+        // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE
+        // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE
+        // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON
+        /* 0 */ "\u00E0,\u00E1,\u00E2,\u00E4,\u00E6,\u00E3,\u00E5,\u0101",
+        // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE
+        // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE
+        // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX
+        // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS
+        // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON
+        /* 1 */ "\u00E8,\u00E9,\u00EA,\u00EB,\u0113",
+        // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX
+        // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS
+        // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE
+        // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON
+        // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE
+        /* 2 */ "\u00EE,\u00EF,\u00ED,\u012B,\u00EC",
+        // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX
+        // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS
+        // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE
+        // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE
+        // U+0153: "œ" LATIN SMALL LIGATURE OE
+        // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE
+        // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON
+        // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE
+        /* 3 */ "\u00F4,\u00F6,\u00F2,\u00F3,\u0153,\u00F8,\u014D,\u00F5",
+        // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX
+        // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS
+        // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE
+        // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE
+        // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON
+        /* 4 */ "\u00FB,\u00FC,\u00F9,\u00FA,\u016B",
+        // U+00DF: "ß" LATIN SMALL LETTER SHARP S
+        /* 5 */ "\u00DF",
+        // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE
+        /* 6 */ "\u00F1",
+        // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA
+        /* 7 */ "\u00E7",
+        /* 8~ */
+        null, null, null, null, null, null, null,
+        /* ~14 */
+        /* 15 */ "g\'",
+    };
+
     /* Language tl: Tagalog */
     private static final String[] LANGUAGE_tl = {
         // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
@@ -2550,6 +2600,7 @@
         "sl", LANGUAGE_sl, /* Slovenian */
         "sr", LANGUAGE_sr, /* Serbian */
         "sv", LANGUAGE_sv, /* Swedish */
+        "sw", LANGUAGE_sw, /* Swahili */
         "tl", LANGUAGE_tl, /* Tagalog */
         "tr", LANGUAGE_tr, /* Turkish */
         "uk", LANGUAGE_uk, /* Ukrainian */
diff --git a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java
new file mode 100644
index 0000000..2a53c59
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Paint.Align;
+import android.text.TextUtils;
+import android.util.SparseArray;
+import android.widget.RelativeLayout;
+
+import com.android.inputmethod.keyboard.PointerTracker;
+import com.android.inputmethod.latin.R;
+
+public class PreviewPlacerView extends RelativeLayout {
+    // TODO: Move these parameters to attributes of {@link KeyboardView}.
+    private final static int GESTURE_DRAWING_COLOR = 0xff33b5e5;
+    private static final int GESTURE_PREVIEW_TEXT_COLOR = Color.WHITE;
+    private static final int GESTURE_PREVIEW_TEXT_SHADING_COLOR = 0xff33b5e5;
+    private static final int GESTURE_PREVIEW_TEXT_SHADOW_COLOR = 0xff252525;
+    private static final int GESTURE_PREVIEW_CONNECTOR_COLOR = Color.WHITE;
+
+    private final Paint mGesturePaint;
+    private final int mGesturePreviewTraileWidth;
+    private final Paint mTextPaint;
+    private final int mGesturePreviewTextOffset;
+    private final int mGesturePreviewTextShadowBorder;
+    private final int mGesturePreviewTextShadingBorder;
+    private final int mGesturePreviewTextConnectorWidth;
+
+    private int mXOrigin;
+    private int mYOrigin;
+
+    private final SparseArray<PointerTracker> mPointers = new SparseArray<PointerTracker>();
+
+    private String mGesturePreviewText;
+
+    public PreviewPlacerView(Context context) {
+        super(context);
+        setWillNotDraw(false);
+
+        final Resources res = getResources();
+        // TODO: Move these parameters to attributes of {@link KeyboardView}.
+        mGesturePreviewTraileWidth = res.getDimensionPixelSize(
+                R.dimen.gesture_preview_trail_width);
+        final int textSize = res.getDimensionPixelSize(R.dimen.gesture_preview_text_size);
+        mGesturePreviewTextOffset = res.getDimensionPixelSize(
+                R.dimen.gesture_preview_text_offset);
+        mGesturePreviewTextShadowBorder = res.getDimensionPixelOffset(
+                R.dimen.gesture_preview_text_shadow_border);
+        mGesturePreviewTextShadingBorder = res.getDimensionPixelOffset(
+                R.dimen.gesture_preview_text_shading_border);
+        mGesturePreviewTextConnectorWidth = res.getDimensionPixelOffset(
+                R.dimen.gesture_preview_text_connector_width);
+
+        mGesturePaint = new Paint();
+        mGesturePaint.setAntiAlias(true);
+        mGesturePaint.setStyle(Paint.Style.STROKE);
+        mGesturePaint.setStrokeJoin(Paint.Join.ROUND);
+        mGesturePaint.setColor(GESTURE_DRAWING_COLOR);
+        mGesturePaint.setStrokeWidth(mGesturePreviewTraileWidth);
+
+        mTextPaint = new Paint();
+        mTextPaint.setAntiAlias(true);
+        mTextPaint.setStrokeJoin(Paint.Join.ROUND);
+        mTextPaint.setTextAlign(Align.CENTER);
+        mTextPaint.setTextSize(textSize);
+    }
+
+    public void setOrigin(int x, int y) {
+        mXOrigin = x;
+        mYOrigin = y;
+    }
+
+    public void invalidatePointer(PointerTracker tracker) {
+        synchronized (mPointers) {
+            mPointers.put(tracker.mPointerId, tracker);
+            // TODO: Should narrow the invalidate region.
+            invalidate();
+        }
+    }
+
+    @Override
+    public void onDraw(Canvas canvas) {
+        super.onDraw(canvas);
+        // TDOD: Add user settings option to control drawing gesture trail and gesture preview.
+        synchronized (mPointers) {
+            canvas.translate(mXOrigin, mYOrigin);
+            final int trackerCount = mPointers.size();
+            boolean floatingPreviewHasDrawn = false;
+            for (int index = 0; index < trackerCount; index++) {
+                final PointerTracker tracker = mPointers.valueAt(index);
+                tracker.drawGestureTrail(canvas, mGesturePaint);
+                // TODO: Figure out more cleaner way to draw gesture preview text.
+                if (!floatingPreviewHasDrawn) {
+                    drawGesturePreviewText(canvas, tracker, mGesturePreviewText);
+                    floatingPreviewHasDrawn = true;
+                }
+            }
+            canvas.translate(-mXOrigin, -mYOrigin);
+        }
+    }
+
+    public void setGesturePreviewText(String gesturePreviewText) {
+        mGesturePreviewText = gesturePreviewText;
+        invalidate();
+    }
+
+    private void drawGesturePreviewText(Canvas canvas, PointerTracker tracker,
+            String gesturePreviewText) {
+        if (TextUtils.isEmpty(gesturePreviewText)) {
+            return;
+        }
+
+        final Paint paint = mTextPaint;
+        final int lastX = tracker.getLastX();
+        final int lastY = tracker.getLastY();
+        final int textSize = (int)paint.getTextSize();
+        final int canvasWidth = canvas.getWidth();
+
+        final int halfTextWidth = (int)paint.measureText(gesturePreviewText) / 2 + textSize;
+        final int textX = Math.min(Math.max(lastX, halfTextWidth), canvasWidth - halfTextWidth);
+
+        int textY = Math.max(-textSize, lastY - mGesturePreviewTextOffset);
+        if (textY < 0) {
+            // Paint black text shadow if preview extends above keyboard region.
+            paint.setStyle(Paint.Style.FILL_AND_STROKE);
+            paint.setColor(GESTURE_PREVIEW_TEXT_SHADOW_COLOR);
+            paint.setStrokeWidth(mGesturePreviewTextShadowBorder);
+            canvas.drawText(gesturePreviewText, textX, textY, paint);
+        }
+
+        // Paint the vertical line connecting the touch point to the preview text.
+        paint.setStyle(Paint.Style.STROKE);
+        paint.setColor(GESTURE_PREVIEW_CONNECTOR_COLOR);
+        paint.setStrokeWidth(mGesturePreviewTextConnectorWidth);
+        final int lineTopY = textY - textSize / 4;
+        canvas.drawLine(lastX, lastY, lastX, lineTopY, paint);
+        if (lastX != textX) {
+            // Paint the horizontal line connection the touch point to the preview text.
+            canvas.drawLine(lastX, lineTopY, textX, lineTopY, paint);
+        }
+
+        // Paint the shading for the text preview
+        paint.setStyle(Paint.Style.FILL_AND_STROKE);
+        paint.setColor(GESTURE_PREVIEW_TEXT_SHADING_COLOR);
+        paint.setStrokeWidth(mGesturePreviewTextShadingBorder);
+        canvas.drawText(gesturePreviewText, textX, textY, paint);
+
+        // Paint the text preview
+        paint.setColor(GESTURE_PREVIEW_TEXT_COLOR);
+        paint.setStyle(Paint.Style.FILL);
+        canvas.drawText(gesturePreviewText, textX, textY, paint);
+    }
+}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 7d79886..9f9d07b 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1343,6 +1343,9 @@
         mWordComposer.setBatchInputPointers(batchPointers);
         final SuggestedWords suggestedWords = getSuggestedWords();
         showSuggestionStrip(suggestedWords, null);
+        final String gesturePreviewText = (suggestedWords.size() > 0)
+                ? suggestedWords.getWord(0) : null;
+        mKeyboardSwitcher.getKeyboardView().showGesturePreviewText(gesturePreviewText);
     }
 
     @Override
@@ -1350,6 +1353,7 @@
         mWordComposer.setBatchInputPointers(batchPointers);
         final SuggestedWords suggestedWords = getSuggestedWords();
         showSuggestionStrip(suggestedWords, null);
+        mKeyboardSwitcher.getKeyboardView().showGesturePreviewText(null);
         if (suggestedWords == null || suggestedWords.size() == 0) {
             return;
         }
diff --git a/tools/maketext/res/values-sw/donottranslate-more-keys.xml b/tools/maketext/res/values-sw/donottranslate-more-keys.xml
new file mode 100644
index 0000000..968a80c
--- /dev/null
+++ b/tools/maketext/res/values-sw/donottranslate-more-keys.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- This is the same as English except more_keys_for_g. -->
+    <!-- U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
+         U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
+         U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
+         U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
+         U+00E6: "æ" LATIN SMALL LETTER AE
+         U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE
+         U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE
+         U+0101: "ā" LATIN SMALL LETTER A WITH MACRON -->
+    <string name="more_keys_for_a">&#x00E0;,&#x00E1;,&#x00E2;,&#x00E4;,&#x00E6;,&#x00E3;,&#x00E5;,&#x0101;</string>
+    <!-- U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE
+         U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE
+         U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX
+         U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS
+         U+0113: "ē" LATIN SMALL LETTER E WITH MACRON -->
+    <string name="more_keys_for_e">&#x00E8;,&#x00E9;,&#x00EA;,&#x00EB;,&#x0113;</string>
+    <!-- U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX
+         U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS
+         U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE
+         U+012B: "ī" LATIN SMALL LETTER I WITH MACRON
+         U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE -->
+    <string name="more_keys_for_i">&#x00EE;,&#x00EF;,&#x00ED;,&#x012B;,&#x00EC;</string>
+    <!-- U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX
+         U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS
+         U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE
+         U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE
+         U+0153: "œ" LATIN SMALL LIGATURE OE
+         U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE
+         U+014D: "ō" LATIN SMALL LETTER O WITH MACRON
+         U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE -->
+    <string name="more_keys_for_o">&#x00F4;,&#x00F6;,&#x00F2;,&#x00F3;,&#x0153;,&#x00F8;,&#x014D;,&#x00F5;</string>
+    <!-- U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX
+         U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS
+         U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE
+         U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE
+         U+016B: "ū" LATIN SMALL LETTER U WITH MACRON -->
+    <string name="more_keys_for_u">&#x00FB;,&#x00FC;,&#x00F9;,&#x00FA;,&#x016B;</string>
+    <!-- U+00DF: "ß" LATIN SMALL LETTER SHARP S -->
+    <string name="more_keys_for_s">&#x00DF;</string>
+    <!-- U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE -->
+    <string name="more_keys_for_n">&#x00F1;</string>
+    <!-- U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA -->
+    <string name="more_keys_for_c">&#x00E7;</string>
+    <string name="more_keys_for_g">g\'</string>
+</resources>