Remove "autoCorrectInvert" feature from SuggestionsView

Bug: 5162005
Change-Id: Iec679f5f05f28cd7e8013d7350ea03372f1cd7b2
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index e40cc95..cd1b460 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -118,10 +118,10 @@
 
     <declare-styleable name="SuggestionsView">
         <attr name="suggestionStripOption" format="integer">
+            <!-- This should be aligned with SuggestionsViewParams.AUTO_CORRECT_* and etc. -->
             <flag name="autoCorrectBold" value="0x01" />
             <flag name="autoCorrectUnderline" value="0x02" />
-            <flag name="autoCorrectInvert" value="0x04" />
-            <flag name="validTypedWordBold" value="0x08" />
+            <flag name="validTypedWordBold" value="0x04" />
         </attr>
         <attr name="colorTypedWord" format="color" />
         <attr name="colorAutoCorrect" format="color" />
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 91a7841..6637d3d 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1494,8 +1494,6 @@
             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 0785169..946b9ea 100644
--- a/java/src/com/android/inputmethod/latin/SuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java
@@ -35,9 +35,7 @@
 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;
@@ -93,7 +91,6 @@
 
     private Listener mListener;
     private SuggestedWords mSuggestions = SuggestedWords.EMPTY;
-    private boolean mShowingAutoCorrectionInverted;
 
     private final SuggestionsViewParams mParams;
     private static final float MIN_TEXT_XSCALE = 0.70f;
@@ -102,10 +99,8 @@
 
     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);
@@ -118,9 +113,6 @@
             case MSG_HIDE_PREVIEW:
                 suggestionsView.hidePreview();
                 break;
-            case MSG_UPDATE_SUGGESTION:
-                suggestionsView.updateSuggestions();
-                break;
             }
         }
 
@@ -133,19 +125,8 @@
             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();
         }
     }
 
@@ -178,12 +159,9 @@
 
         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;
 
@@ -246,9 +224,6 @@
             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);
@@ -346,16 +321,6 @@
             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()) {
@@ -577,21 +542,11 @@
     }
 
     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());
     }
 
@@ -680,15 +635,6 @@
         }
     }
 
-    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;
@@ -712,7 +658,6 @@
     }
 
     public void clear() {
-        mShowingAutoCorrectionInverted = false;
         mSuggestionsStrip.removeAllViews();
         removeAllViews();
         addView(mSuggestionsStrip);