aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-09-20 23:28:31 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-20 23:28:31 -0700
commit68c7b9b195c3ffcc52cd265b98aa15d637fb5420 (patch)
tree16ac2527899f7126f4350f1cb793b45b7b3fec8f /java/src
parent92a83e74ec57cd6d86b20b687d94e1704795a98e (diff)
parent77a87e3cb5886b1319230906c77c0bc98b905248 (diff)
downloadlatinime-68c7b9b195c3ffcc52cd265b98aa15d637fb5420.tar.gz
latinime-68c7b9b195c3ffcc52cd265b98aa15d637fb5420.tar.xz
latinime-68c7b9b195c3ffcc52cd265b98aa15d637fb5420.zip
Merge "Remove "autoCorrectInvert" feature from SuggestionsView"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java2
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestionsView.java61
2 files changed, 3 insertions, 60 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 1fa536e59..5ccf6b795 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1497,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 d7e7d5927..776cea26a 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.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;
@@ -93,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;
@@ -102,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);
@@ -118,9 +113,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
case MSG_HIDE_PREVIEW:
suggestionsView.hidePreview();
break;
- case MSG_UPDATE_SUGGESTION:
- suggestionsView.updateSuggestions();
- break;
}
}
@@ -133,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();
}
}
@@ -178,12 +159,9 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
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 @@ 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);
@@ -346,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()) {
@@ -577,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());
}
@@ -680,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;
@@ -712,7 +658,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
}
public void clear() {
- mShowingAutoCorrectionInverted = false;
mSuggestionsStrip.removeAllViews();
removeAllViews();
addView(mSuggestionsStrip);