diff options
Diffstat (limited to 'java/src')
6 files changed, 29 insertions, 19 deletions
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index 32ef1021d..8803edc88 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -232,31 +232,33 @@ public final class WordComposer { * @return true if the cursor is still inside the composing word, false otherwise. */ public boolean moveCursorByAndReturnIfInsideComposingWord(final int expectedMoveAmount) { - int actualMoveAmountWithinWord = 0; + int actualMoveAmount = 0; int cursorPos = mCursorPositionWithinWord; // TODO: Don't make that copy. We can do this directly from mTypedWordCache. final int[] codePoints = StringUtils.toCodePointArray(mTypedWordCache); if (expectedMoveAmount >= 0) { // Moving the cursor forward for the expected amount or until the end of the word has // been reached, whichever comes first. - while (actualMoveAmountWithinWord < expectedMoveAmount && cursorPos < mCodePointSize) { - actualMoveAmountWithinWord += Character.charCount(codePoints[cursorPos]); + while (actualMoveAmount < expectedMoveAmount && cursorPos < codePoints.length) { + actualMoveAmount += Character.charCount(codePoints[cursorPos]); ++cursorPos; } } else { // Moving the cursor backward for the expected amount or until the start of the word // has been reached, whichever comes first. - while (actualMoveAmountWithinWord > expectedMoveAmount && cursorPos > 0) { + while (actualMoveAmount > expectedMoveAmount && cursorPos > 0) { --cursorPos; - actualMoveAmountWithinWord -= Character.charCount(codePoints[cursorPos]); + actualMoveAmount -= Character.charCount(codePoints[cursorPos]); } } // If the actual and expected amounts differ, we crossed the start or the end of the word // so the result would not be inside the composing word. - if (actualMoveAmountWithinWord != expectedMoveAmount) return false; + if (actualMoveAmount != expectedMoveAmount) { + return false; + } mCursorPositionWithinWord = cursorPos; - mCombinerChain.applyProcessedEvent(mCombinerChain.processEvent(mEvents, - Event.createCursorMovedEvent(cursorPos))); + mCombinerChain.applyProcessedEvent(mCombinerChain.processEvent( + mEvents, Event.createCursorMovedEvent(cursorPos))); return true; } diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index 7907aaa16..3f1646beb 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -925,6 +925,7 @@ public final class InputLogic { if (tryPerformDoubleSpacePeriod(event, inputTransaction)) { mSpaceState = SpaceState.DOUBLE; inputTransaction.setRequiresUpdateSuggestions(); + StatsUtils.onDoubleSpacePeriod(); } else if (swapWeakSpace && trySwapSwapperAndSpace(event, inputTransaction)) { mSpaceState = SpaceState.SWAP_PUNCTUATION; mSuggestionStripViewAccessor.setNeutralSuggestionStrip(); diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java index 1e9f8e47e..32a746d37 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java +++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java @@ -172,8 +172,8 @@ public final class FormatSpec { public static final int VERSION2 = 2; public static final int VERSION201 = 201; public static final int VERSION202 = 202; - // format version for Fava - public static final int VERSION300 = 300; + // format version for Fava Dictionaries. + public static final int VERSION_DELIGHT3 = 86736212; public static final int MINIMUM_SUPPORTED_VERSION_OF_CODE_POINT_TABLE = VERSION201; // Dictionary version used for testing. public static final int VERSION4_ONLY_FOR_TESTING = 399; @@ -182,7 +182,7 @@ public final class FormatSpec { public static final int VERSION4 = VERSION403; public static final int VERSION4_DEV = VERSION403; public static final int MINIMUM_SUPPORTED_STATIC_VERSION = VERSION202; - public static final int MAXIMUM_SUPPORTED_STATIC_VERSION = VERSION300; + public static final int MAXIMUM_SUPPORTED_STATIC_VERSION = VERSION_DELIGHT3; static final int MINIMUM_SUPPORTED_DYNAMIC_VERSION = VERSION4; static final int MAXIMUM_SUPPORTED_DYNAMIC_VERSION = VERSION4_DEV; diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java index a9d1207f1..d8926ffba 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java @@ -342,8 +342,11 @@ final class SuggestionStripLayoutHelper { * @param placerView the view where the debug info will be placed. * @return the start index of more suggestions. */ - public int layoutAndReturnStartIndexOfMoreSuggestions(final SuggestedWords suggestedWords, - final ViewGroup stripView, final ViewGroup placerView) { + public int layoutAndReturnStartIndexOfMoreSuggestions( + final Context context, + final SuggestedWords suggestedWords, + final ViewGroup stripView, + final ViewGroup placerView) { if (suggestedWords.isPunctuationSuggestions()) { return layoutPunctuationsAndReturnStartIndexOfMoreSuggestions( (PunctuationSuggestions)suggestedWords, stripView); @@ -362,7 +365,7 @@ final class SuggestionStripLayoutHelper { // by consolidating all slots in the strip. final int countInStrip = 1; mMoreSuggestionsAvailable = (wordCountToShow > countInStrip); - layoutWord(mCenterPositionInStrip, stripWidth - mPadding); + layoutWord(context, mCenterPositionInStrip, stripWidth - mPadding); stripView.addView(centerWordView); setLayoutWeight(centerWordView, 1.0f, ViewGroup.LayoutParams.MATCH_PARENT); if (SuggestionStripView.DBG) { @@ -385,7 +388,7 @@ final class SuggestionStripLayoutHelper { } final int width = getSuggestionWidth(positionInStrip, stripWidth); - final TextView wordView = layoutWord(positionInStrip, width); + final TextView wordView = layoutWord(context, positionInStrip, width); stripView.addView(wordView); setLayoutWeight(wordView, getSuggestionWeight(positionInStrip), ViewGroup.LayoutParams.MATCH_PARENT); @@ -414,7 +417,7 @@ final class SuggestionStripLayoutHelper { * @param width the maximum width for layout in pixels. * @return the {@link TextView} containing the suggested word appropriately formatted. */ - private TextView layoutWord(final int positionInStrip, final int width) { + private TextView layoutWord(final Context context, final int positionInStrip, final int width) { final TextView wordView = mWordViews.get(positionInStrip); final CharSequence word = wordView.getText(); if (positionInStrip == mCenterPositionInStrip && mMoreSuggestionsAvailable) { @@ -428,7 +431,10 @@ final class SuggestionStripLayoutHelper { } // {@link StyleSpan} in a content description may cause an issue of TTS/TalkBack. // Use a simple {@link String} to avoid the issue. - wordView.setContentDescription(TextUtils.isEmpty(word) ? null : word.toString()); + wordView.setContentDescription( + TextUtils.isEmpty(word) + ? context.getResources().getString(R.string.spoken_empty_suggestion) + : word.toString()); final CharSequence text = getEllipsizedTextWithSettingScaleX( word, width, wordView.getPaint()); final float scaleX = wordView.getTextScaleX(); diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java index 4b849496c..17525f650 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java @@ -146,6 +146,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); + word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion)); word.setOnClickListener(this); word.setOnLongClickListener(this); mWordViews.add(word); @@ -200,7 +201,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick mStripVisibilityGroup.setLayoutDirection(isRtlLanguage); mSuggestedWords = suggestedWords; mStartIndexOfMoreSuggestions = mLayoutHelper.layoutAndReturnStartIndexOfMoreSuggestions( - mSuggestedWords, mSuggestionsStrip, this); + getContext(), mSuggestedWords, mSuggestionsStrip, this); mStripVisibilityGroup.showSuggestionsStrip(); } diff --git a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java index 293623cae..3ed6a021e 100644 --- a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java @@ -153,7 +153,7 @@ public class DictionaryInfoUtils { } /** - * Reverse escaping done by replaceFileNameDangerousCharacters. + * Reverse escaping done by {@link #replaceFileNameDangerousCharacters(String)}. */ @Nonnull public static String getWordListIdFromFileName(@Nonnull final String fname) { |