diff options
Diffstat (limited to 'java/src/com/android/inputmethod')
3 files changed, 38 insertions, 65 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java index a82bcbed0..0e2d28024 100644 --- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java +++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java @@ -65,7 +65,8 @@ public class ProximityInfo { spellCheckerProximityInfo.mNativeProximityInfo = spellCheckerProximityInfo.setProximityInfoNative( SpellCheckerProximityInfo.ROW_SIZE, - 480, 300, 10, 3, SpellCheckerProximityInfo.PROXIMITY); + 480, 300, 10, 3, SpellCheckerProximityInfo.PROXIMITY, + 0, null, null, null, null, null); return spellCheckerProximityInfo; } @@ -74,7 +75,9 @@ public class ProximityInfo { Utils.loadNativeLibrary(); } private native int setProximityInfoNative(int maxProximityCharsSize, int displayWidth, - int displayHeight, int gridWidth, int gridHeight, int[] proximityCharsArray); + int displayHeight, int gridWidth, int gridHeight, int[] proximityCharsArray, + int keyCount, int[] keyXCoordinates, int[] keyYCoordinates, + int[] keyWidths, int[] keyHeights, int[] keyCharCodes); private native void releaseProximityInfoNative(int nativeProximityInfo); private final void setProximityInfo(int[][] gridNeighborKeyIndexes, int keyboardWidth, @@ -88,8 +91,23 @@ public class ProximityInfo { keys.get(gridNeighborKeyIndexes[i][j]).mCode; } } + final int keyCount = keys.size(); + int[] keyXCoordinates = new int[keyCount]; + int[] keyYCoordinates = new int[keyCount]; + int[] keyWidths = new int[keyCount]; + int[] keyHeights = new int[keyCount]; + int[] keyCharCodes = new int[keyCount]; + for (int i = 0; i < keyCount; ++i) { + final Key key = keys.get(i); + keyXCoordinates[i] = key.mX; + keyYCoordinates[i] = key.mY; + keyWidths[i] = key.mWidth; + keyHeights[i] = key.mHeight; + keyCharCodes[i] = key.mCode; + } mNativeProximityInfo = setProximityInfoNative(MAX_PROXIMITY_CHARS_SIZE, - keyboardWidth, keyboardHeight, mGridWidth, mGridHeight, proximityCharsArray); + keyboardWidth, keyboardHeight, mGridWidth, mGridHeight, proximityCharsArray, + keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes); } public int getNativeProximityInfo() { diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 91a784124..ddda184aa 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -618,6 +618,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mSuggestionsView = (SuggestionsView) view.findViewById(R.id.suggestions_view); if (mSuggestionsView != null) mSuggestionsView.setListener(this, view); + if (LatinImeLogger.sVISUALDEBUG) { + mKeyPreviewBackingView.setBackgroundColor(0x10FF0000); + } } @Override @@ -998,8 +1001,17 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar @Override public boolean onEvaluateFullscreenMode() { - return super.onEvaluateFullscreenMode() - && mResources.getBoolean(R.bool.config_use_fullscreen_mode); + if (!super.onEvaluateFullscreenMode()) return false; + + final EditorInfo ei = getCurrentInputEditorInfo(); + if (ei != null) { + final int imeOptions = ei.imeOptions; + if ((imeOptions & EditorInfo.IME_FLAG_NO_EXTRACT_UI) != 0) { + return false; + } + } + + return mResources.getBoolean(R.bool.config_use_fullscreen_mode); } @Override @@ -1494,8 +1506,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 0785169e2..946b9ea73 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); |