diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/res/values-land/config.xml | 23 | ||||
-rw-r--r-- | java/res/values-sw600dp-land/config.xml | 23 | ||||
-rw-r--r-- | java/res/values-sw768dp-land/config.xml | 23 | ||||
-rw-r--r-- | java/res/values/attrs.xml | 6 | ||||
-rw-r--r-- | java/res/values/config.xml | 1 | ||||
-rw-r--r-- | java/res/values/dimens.xml | 6 | ||||
-rw-r--r-- | java/res/values/donottranslate.xml | 2 | ||||
-rw-r--r-- | java/res/values/styles.xml | 1 | ||||
-rw-r--r-- | java/res/xml-sw600dp/kbd_phone.xml | 2 | ||||
-rw-r--r-- | java/res/xml-sw768dp/kbd_qwerty_row4.xml | 2 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/Key.java | 35 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyboardView.java | 42 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/ProximityInfo.java | 1 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java | 46 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 10 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/SuggestionsView.java | 2 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java | 20 |
17 files changed, 170 insertions, 75 deletions
diff --git a/java/res/values-land/config.xml b/java/res/values-land/config.xml new file mode 100644 index 000000000..7d93cc2ff --- /dev/null +++ b/java/res/values-land/config.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2011, 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> + <bool name="config_use_fullscreen_mode">true</bool> +</resources> diff --git a/java/res/values-sw600dp-land/config.xml b/java/res/values-sw600dp-land/config.xml new file mode 100644 index 000000000..b3cd7278d --- /dev/null +++ b/java/res/values-sw600dp-land/config.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2011, 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> + <bool name="config_use_fullscreen_mode">false</bool> +</resources> diff --git a/java/res/values-sw768dp-land/config.xml b/java/res/values-sw768dp-land/config.xml new file mode 100644 index 000000000..b3cd7278d --- /dev/null +++ b/java/res/values-sw768dp-land/config.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2011, 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> + <bool name="config_use_fullscreen_mode">false</bool> +</resources> diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index e964889c4..a456b221b 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -63,6 +63,8 @@ <attr name="keyLabelHorizontalPadding" format="dimension" /> <!-- Top and right padding of hint letter to the edge of the key.--> <attr name="keyHintLetterPadding" format="dimension" /> + <!-- Bottom padding of popup hint letter "..." to the edge of the key.--> + <attr name="keyPopupHintLetterPadding" format="dimension" /> <!-- Top and right padding of upper case letter to the edge of the key.--> <attr name="keyUppercaseLetterPadding" format="dimension" /> @@ -148,8 +150,8 @@ area between the nearest key on the left hand side and the right edge of the keyboard. --> <attr name="keyWidth" format="dimension|fraction|enum"> - <enum name="fillRight" value="0" /> - <enum name="fillBoth" value="-1" /> + <enum name="fillRight" value="-1" /> + <enum name="fillBoth" value="-2" /> </attr> <!-- Default height of a row (key height + vertical gap), in pixels or percentage of keyboard height. --> diff --git a/java/res/values/config.xml b/java/res/values/config.xml index d9ff8d7b9..194f2ed42 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -19,6 +19,7 @@ --> <resources> + <bool name="config_use_fullscreen_mode">false</bool> <bool name="config_enable_show_settings_key_option">true</bool> <bool name="config_default_show_settings_key">false</bool> <bool name="config_enable_show_voice_key_option">true</bool> diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index 50eca4bdb..8488c777b 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -71,6 +71,7 @@ <dimen name="key_label_horizontal_padding">4dip</dimen> <dimen name="key_hint_letter_padding">1dp</dimen> + <dimen name="key_popup_hint_letter_padding">2dp</dimen> <dimen name="key_uppercase_letter_padding">2dp</dimen> <dimen name="key_preview_height_ics">80sp</dimen> @@ -94,10 +95,5 @@ <integer name="suggestions_count_in_strip">3</integer> <integer name="center_suggestion_percentile">36</integer> - <!-- If the screen height in landscape is larger than the below value, then the keyboard - will not go into extract (fullscreen) mode. - Current value is approximate to 7-inch tablet height - system navigation bar height. --> - <dimen name="max_height_for_fullscreen">500dip</dimen> - <dimen name="key_hysteresis_distance">0.05in</dimen> </resources> diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml index 228380da7..4072ea4b8 100644 --- a/java/res/values/donottranslate.xml +++ b/java/res/values/donottranslate.xml @@ -19,7 +19,7 @@ --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <!-- Symbols that are suggested between words --> - <string name="suggested_punctuations">!?,\u0022:;()\u0027-/@_</string> + <string name="suggested_punctuations">!?,:;\u0022()\u0027-/@_</string> <!-- Symbols that should be swapped with a magic space --> <string name="magic_space_swapping_symbols">.,;:!?)]}\u0022</string> <!-- Symbols that should strip a magic space --> diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 0e8216b48..9fa4d842e 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -52,6 +52,7 @@ <item name="keyUppercaseLetterActivatedColor">#CCE0E4E5</item> <item name="keyLabelHorizontalPadding">@dimen/key_label_horizontal_padding</item> <item name="keyHintLetterPadding">@dimen/key_hint_letter_padding</item> + <item name="keyPopupHintLetterPadding">@dimen/key_popup_hint_letter_padding</item> <item name="keyUppercaseLetterPadding">@dimen/key_uppercase_letter_padding</item> <item name="keyPreviewLayout">@layout/key_preview</item> <item name="keyPreviewBackground">@drawable/keyboard_key_feedback</item> diff --git a/java/res/xml-sw600dp/kbd_phone.xml b/java/res/xml-sw600dp/kbd_phone.xml index 0331389c1..303f8145b 100644 --- a/java/res/xml-sw600dp/kbd_phone.xml +++ b/java/res/xml-sw600dp/kbd_phone.xml @@ -105,7 +105,7 @@ <Key latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle" latin:keyXPos="15.625%p" - latin:keyWidth="18.67%p" /> + latin:keyWidth="18.50%p" /> <Key latin:keyStyle="numStarKeyStyle" latin:keyXPos="38.867%p" /> diff --git a/java/res/xml-sw768dp/kbd_qwerty_row4.xml b/java/res/xml-sw768dp/kbd_qwerty_row4.xml index 9346111ee..e35e47d83 100644 --- a/java/res/xml-sw768dp/kbd_qwerty_row4.xml +++ b/java/res/xml-sw768dp/kbd_qwerty_row4.xml @@ -35,7 +35,7 @@ </switch> <Spacer latin:keyXPos="15.157%p" - latin:keyWidth="fillRight" /> + latin:keyWidth="0%p" /> <switch> <case latin:mode="url" diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 15ec80b6e..735caaebb 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -115,9 +115,10 @@ public class Key { /** Whether this key needs to show the "..." popup hint for special purposes */ private boolean mNeedsSpecialPopupHint; - // keyWidth constants - private static final int KEYWIDTH_FILL_RIGHT = 0; - private static final int KEYWIDTH_FILL_BOTH = -1; + // keyWidth enum constants + private static final int KEYWIDTH_NOT_ENUM = 0; + private static final int KEYWIDTH_FILL_RIGHT = -1; + private static final int KEYWIDTH_FILL_BOTH = -2; private final static int[] KEY_STATE_NORMAL_ON = { android.R.attr.state_checkable, @@ -249,15 +250,17 @@ public class Key { */ public Key(Resources res, KeyboardParams params, KeyboardBuilder.Row row, XmlResourceParser parser, KeyStyles keyStyles) { - final TypedArray keyboardAttr = res.obtainAttributes(Xml.asAttributeSet(parser), R.styleable.Keyboard); mHeight = (int)KeyboardBuilder.getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_rowHeight, params.mHeight, row.mRowHeight) - params.mVerticalGap; - final float horizontalGap = KeyboardBuilder.getDimensionOrFraction(keyboardAttr, - R.styleable.Keyboard_horizontalGap, params.mWidth, params.mHorizontalGap); + final float horizontalGap = isSpacer() ? 0 + : KeyboardBuilder.getDimensionOrFraction(keyboardAttr, + R.styleable.Keyboard_horizontalGap, params.mWidth, params.mHorizontalGap); mVerticalGap = params.mVerticalGap; + final int widthType = KeyboardBuilder.getEnumValue(keyboardAttr, + R.styleable.Keyboard_keyWidth, KEYWIDTH_NOT_ENUM); float keyWidth = KeyboardBuilder.getDimensionOrFraction(keyboardAttr, R.styleable.Keyboard_keyWidth, params.mWidth, row.mDefaultKeyWidth); keyboardAttr.recycle(); @@ -288,11 +291,11 @@ public class Key { keyXPos = x; } } - if (keyWidth == KEYWIDTH_FILL_RIGHT) { + if (widthType == KEYWIDTH_FILL_RIGHT) { // If keyWidth is zero, the actual key width will be determined to fill out the // area up to the right edge of the keyboard. keyWidth = keyboardWidth - keyXPos; - } else if (keyWidth <= KEYWIDTH_FILL_BOTH) { + } else if (widthType == KEYWIDTH_FILL_BOTH) { // If keyWidth is negative, the actual key width will be determined to fill out the // area between the nearest key on the left hand side and the right edge of the // keyboard. @@ -367,6 +370,10 @@ public class Key { mEdgeFlags |= flags; } + public boolean isSpacer() { + return false; + } + public Typeface selectTypeface(Typeface defaultTypeface) { // TODO: Handle "bold" here too? if ((mLabelOption & LABEL_OPTION_FONT_NORMAL) != 0) { @@ -559,4 +566,16 @@ public class Key { } return states; } + + public static class Spacer extends Key { + public Spacer(Resources res, KeyboardParams params, KeyboardBuilder.Row row, + XmlResourceParser parser, KeyStyles keyStyles) { + super(res, params, row, parser, keyStyles); + } + + @Override + public boolean isSpacer() { + return true; + } + } } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 1e7c32638..acb76cc78 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -58,6 +58,7 @@ import java.util.HashMap; * @attr ref R.styleable#KeyboardView_keyHintLabelRatio * @attr ref R.styleable#KeyboardView_keyLabelHorizontalPadding * @attr ref R.styleable#KeyboardView_keyHintLetterPadding + * @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding * @attr ref R.styleable#KeyboardView_keyUppercaseLetterPadding * @attr ref R.styleable#KeyboardView_keyTextStyle * @attr ref R.styleable#KeyboardView_keyPreviewLayout @@ -198,6 +199,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { public final Typeface mKeyTextStyle; public final float mKeyLabelHorizontalPadding; public final float mKeyHintLetterPadding; + public final float mKeyPopupHintLetterPadding; public final float mKeyUppercaseLetterPadding; public final int mShadowColor; public final float mShadowRadius; @@ -246,6 +248,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { R.styleable.KeyboardView_keyLabelHorizontalPadding, 0); mKeyHintLetterPadding = a.getDimension( R.styleable.KeyboardView_keyHintLetterPadding, 0); + mKeyPopupHintLetterPadding = a.getDimension( + R.styleable.KeyboardView_keyPopupHintLetterPadding, 0); mKeyUppercaseLetterPadding = a.getDimension( R.styleable.KeyboardView_keyUppercaseLetterPadding, 0); mKeyTextColor = a.getColor(R.styleable.KeyboardView_keyTextColor, 0xFF000000); @@ -506,24 +510,26 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { Paint paint, KeyDrawParams params, boolean isManualTemporaryUpperCase) { final boolean debugShowAlign = LatinImeLogger.sVISUALDEBUG; // Draw key background. - final int bgWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight - + params.mPadding.left + params.mPadding.right; - final int bgHeight = key.mHeight + params.mPadding.top + params.mPadding.bottom; - final int bgX = -params.mPadding.left; - final int bgY = -params.mPadding.top; - final int[] drawableState = key.getCurrentDrawableState(); - final Drawable background = params.mKeyBackground; - background.setState(drawableState); - final Rect bounds = background.getBounds(); - if (bgWidth != bounds.right || bgHeight != bounds.bottom) { - background.setBounds(0, 0, bgWidth, bgHeight); - } - canvas.translate(bgX, bgY); - background.draw(canvas); - if (debugShowAlign) { - drawRectangle(canvas, 0, 0, bgWidth, bgHeight, 0x80c00000, new Paint()); + if (!key.isSpacer()) { + final int bgWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight + + params.mPadding.left + params.mPadding.right; + final int bgHeight = key.mHeight + params.mPadding.top + params.mPadding.bottom; + final int bgX = -params.mPadding.left; + final int bgY = -params.mPadding.top; + final int[] drawableState = key.getCurrentDrawableState(); + final Drawable background = params.mKeyBackground; + background.setState(drawableState); + final Rect bounds = background.getBounds(); + if (bgWidth != bounds.right || bgHeight != bounds.bottom) { + background.setBounds(0, 0, bgWidth, bgHeight); + } + canvas.translate(bgX, bgY); + background.draw(canvas); + if (debugShowAlign) { + drawRectangle(canvas, 0, 0, bgWidth, bgHeight, 0x80c00000, new Paint()); + } + canvas.translate(-bgX, -bgY); } - canvas.translate(-bgX, -bgY); // Draw key top visuals. final int keyWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight; @@ -698,7 +704,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { paint.setTextAlign(Align.CENTER); final float hintX = keyWidth - params.mKeyHintLetterPadding - getCharWidth(KEY_LABEL_REFERENCE_CHAR, paint) / 2; - final float hintY = keyHeight - params.mKeyHintLetterPadding; + final float hintY = keyHeight - params.mKeyPopupHintLetterPadding; canvas.drawText(POPUP_HINT_CHAR, hintX, hintY, paint); if (debugShowAlign) { diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java index 7190b051d..a82bcbed0 100644 --- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java +++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java @@ -122,6 +122,7 @@ public class ProximityInfo { int count = 0; for (int i = 0; i < keys.size(); i++) { final Key key = keys.get(i); + if (key.isSpacer()) continue; if (key.squaredDistanceToEdge(centerX, centerY) < threshold) indices[count++] = i; } diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java index fb1c06175..e39548e9c 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java @@ -394,12 +394,11 @@ public class KeyboardBuilder<KP extends KeyboardParams> { if (skip) { checkEndTag(TAG_KEY, parser); } else { - Key key = new Key(mResources, mParams, row, parser, mKeyStyles); + final Key key = new Key(mResources, mParams, row, parser, mKeyStyles); if (DEBUG) Log.d(TAG, String.format("<%s%s keyLabel=%s code=%d moreKeys=%s />", TAG_KEY, (key.isEnabled() ? "" : " disabled"), key.mLabel, key.mCode, Arrays.toString(key.mMoreKeys))); checkEndTag(TAG_KEY, parser); - mParams.onAddKey(key); endKey(key); } } @@ -409,27 +408,10 @@ public class KeyboardBuilder<KP extends KeyboardParams> { if (skip) { checkEndTag(TAG_SPACER, parser); } else { + final Key.Spacer spacer = new Key.Spacer(mResources, mParams, row, parser, mKeyStyles); if (DEBUG) Log.d(TAG, String.format("<%s />", TAG_SPACER)); - final TypedArray keyboardAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser), - R.styleable.Keyboard); - if (keyboardAttr.hasValue(R.styleable.Keyboard_horizontalGap)) - throw new IllegalAttribute(parser, "horizontalGap"); - final int keyboardWidth = mParams.mWidth; - final float keyWidth = getDimensionOrFraction(keyboardAttr, - R.styleable.Keyboard_keyWidth, keyboardWidth, row.mDefaultKeyWidth); - keyboardAttr.recycle(); - - final TypedArray keyAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser), - R.styleable.Keyboard_Key); - float keyXPos = getDimensionOrFraction(keyAttr, - R.styleable.Keyboard_Key_keyXPos, keyboardWidth, row.mCurrentX); - if (keyXPos < 0) { - // If keyXPos is negative, the actual x-coordinate will be display_width + keyXPos. - keyXPos += keyboardWidth; - } - checkEndTag(TAG_SPACER, parser); - setSpacer(keyXPos, keyWidth, row); + endKey(spacer); } } @@ -686,7 +668,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> { private void startRow(Row row) { row.mCurrentX = 0; - setSpacer(row.mCurrentX, mParams.mHorizontalEdgesPadding, row); + addEdgeSpace(mParams.mHorizontalEdgesPadding, row); mCurrentRow = row; mLeftEdge = true; mRightEdgeKey = null; @@ -699,13 +681,14 @@ public class KeyboardBuilder<KP extends KeyboardParams> { mRightEdgeKey.addEdgeFlags(Keyboard.EDGE_RIGHT); mRightEdgeKey = null; } - setSpacer(row.mCurrentX, mParams.mHorizontalEdgesPadding, row); + addEdgeSpace(mParams.mHorizontalEdgesPadding, row); mCurrentY += mCurrentRow.mRowHeight; mCurrentRow = null; mTopEdge = false; } private void endKey(Key key) { + mParams.onAddKey(key); if (mLeftEdge) { key.addEdgeFlags(Keyboard.EDGE_LEFT); mLeftEdge = false; @@ -719,8 +702,8 @@ public class KeyboardBuilder<KP extends KeyboardParams> { private void endKeyboard() { } - private void setSpacer(float keyXPos, float width, Row row) { - row.mCurrentX = keyXPos + width; + private void addEdgeSpace(float width, Row row) { + row.mCurrentX += width; mLeftEdge = false; mRightEdgeKey = null; } @@ -733,9 +716,16 @@ public class KeyboardBuilder<KP extends KeyboardParams> { return a.getFraction(index, base, base, defValue); } else if (isDimensionValue(value)) { return a.getDimension(index, defValue); - } else if (isIntegerValue(value)) { - // For enum value. - return a.getInt(index, 0); + } + return defValue; + } + + public static int getEnumValue(TypedArray a, int index, int defValue) { + final TypedValue value = a.peekValue(index); + if (value == null) + return defValue; + if (isIntegerValue(value)) { + return a.getInt(index, defValue); } return defValue; } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 68d93295c..08af5c5e3 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1004,15 +1004,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return false; } - final Resources res = mResources; - final DisplayMetrics dm = res.getDisplayMetrics(); - // If the display is more than X DIP high, don't go to fullscreen mode - final int threshold = res.getDimensionPixelSize(R.dimen.max_height_for_fullscreen); - if (dm.heightPixels >= threshold) { - return false; - } else { - return super.onEvaluateFullscreenMode(); - } + return mResources.getBoolean(R.bool.config_use_fullscreen_mode); } @Override diff --git a/java/src/com/android/inputmethod/latin/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java index 22aa5e259..6879f7660 100644 --- a/java/src/com/android/inputmethod/latin/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java @@ -146,7 +146,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, private static final int DEFAULT_SUGGESTIONS_COUNT_IN_STRIP = 3; private static final int DEFAULT_CENTER_SUGGESTION_PERCENTILE = 40; private static final int DEFAULT_MAX_MORE_SUGGESTIONS_ROW = 2; - private static final int PUNCTUATIONS_IN_STRIP = 6; + private static final int PUNCTUATIONS_IN_STRIP = 5; public final int mPadding; public final int mDividerWidth; diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index 85c142f1e..ae47ab22b 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -160,6 +160,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService { if (mLength != mSuggestions.size()) { Log.e(TAG, "Suggestion size is not the same as stored mLength"); } + for (int i = mLength - 1; i >= 0; --i) { + Log.i(TAG, "" + mScores[i] + " " + mSuggestions.get(i)); + } } Collections.reverse(mSuggestions); Utils.removeDupes(mSuggestions); @@ -167,11 +170,16 @@ public class AndroidSpellCheckerService extends SpellCheckerService { // into a String[]. gatheredSuggestions = mSuggestions.toArray(EMPTY_STRING_ARRAY); - final int bestScore = mScores[0]; + final int bestScore = mScores[mLength - 1]; final CharSequence bestSuggestion = mSuggestions.get(0); final double normalizedScore = Utils.calcNormalizedScore(originalText, bestSuggestion, bestScore); looksLikeTypo = (normalizedScore > threshold); + if (DBG) { + Log.i(TAG, "Best suggestion : " + bestSuggestion + ", score " + bestScore); + Log.i(TAG, "Normalized score = " + normalizedScore + " (threshold " + threshold + + ") => looksLikeTypo = " + looksLikeTypo); + } } return new Result(gatheredSuggestions, looksLikeTypo); } @@ -305,6 +313,16 @@ public class AndroidSpellCheckerService extends SpellCheckerService { final SuggestionsGatherer.Result result = suggestionsGatherer.getResults(text, mService.mTypoThreshold); + if (DBG) { + Log.i(TAG, "Spell checking results for " + text + " with suggestion limit " + + suggestionsLimit); + Log.i(TAG, "IsInDict = " + result.mLooksLikeTypo); + Log.i(TAG, "LooksLikeTypo = " + result.mLooksLikeTypo); + for (String suggestion : result.mSuggestions) { + Log.i(TAG, suggestion); + } + } + final int flags = (isInDict ? SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY : 0) | (result.mLooksLikeTypo |