diff options
Diffstat (limited to 'java/src/com/android')
10 files changed, 82 insertions, 145 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 4088f3e93..9590290ea 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -835,20 +835,6 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key return false; } - @Override - public void draw(Canvas c) { - Utils.GCUtils.getInstance().reset(); - boolean tryGC = true; - for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { - try { - super.draw(c); - tryGC = false; - } catch (OutOfMemoryError e) { - tryGC = Utils.GCUtils.getInstance().tryGCOrWait(TAG, e); - } - } - } - /** * Receives hover events from the input framework. * diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 85360c410..7d565a64f 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -29,7 +29,6 @@ import com.android.inputmethod.keyboard.internal.GestureStroke; import com.android.inputmethod.keyboard.internal.PointerTrackerQueue; import com.android.inputmethod.latin.InputPointers; import com.android.inputmethod.latin.LatinImeLogger; -import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.research.ResearchLogger; @@ -130,10 +129,6 @@ public class PointerTracker implements PointerTrackerQueue.Element { private static final InputPointers sAggregratedPointers = new InputPointers( GestureStroke.DEFAULT_CAPACITY); private static PointerTrackerQueue sPointerTrackerQueue; - // HACK: Change gesture detection criteria depending on this variable. - // TODO: Find more comprehensive ways to detect a gesture start. - // True when the previous user input was a gesture input, not a typing input. - private static boolean sWasInGesture; public final int mPointerId; @@ -413,8 +408,7 @@ public class PointerTracker implements PointerTrackerQueue.Element { mKeyDetector = keyDetector; mKeyboard = keyDetector.getKeyboard(); mIsAlphabetKeyboard = mKeyboard.mId.isAlphabetKeyboard(); - mGestureStroke.setGestureSampleLength( - mKeyboard.mMostCommonKeyWidth, mKeyboard.mMostCommonKeyHeight); + mGestureStroke.setGestureSampleLength(mKeyboard.mMostCommonKeyWidth); final Key newKey = mKeyDetector.detectHitKey(mKeyX, mKeyY); if (newKey != mCurrentKey) { if (mDrawingProxy != null) { @@ -526,7 +520,7 @@ public class PointerTracker implements PointerTrackerQueue.Element { public void drawGestureTrail(Canvas canvas, Paint paint) { if (mInGesture) { - mGestureStroke.drawGestureTrail(canvas, paint, mLastX, mLastY); + mGestureStroke.drawGestureTrail(canvas, paint); } } @@ -586,7 +580,6 @@ public class PointerTracker implements PointerTrackerQueue.Element { mListener.onEndBatchInput(batchPoints); clearBatchInputRecognitionStateOfThisPointerTracker(); clearBatchInputPointsOfAllPointerTrackers(); - sWasInGesture = true; } private void abortBatchInput() { @@ -719,7 +712,7 @@ public class PointerTracker implements PointerTrackerQueue.Element { if (sShouldHandleGesture && mIsPossibleGesture) { final GestureStroke stroke = mGestureStroke; stroke.addPoint(x, y, gestureTime, isHistorical); - if (!mInGesture && stroke.isStartOfAGesture(gestureTime, sWasInGesture)) { + if (!mInGesture && stroke.isStartOfAGesture()) { startBatchInput(); } } @@ -1002,7 +995,6 @@ public class PointerTracker implements PointerTrackerQueue.Element { int code = key.mCode; callListenerOnCodeInput(key, code, x, y); callListenerOnRelease(key, code, false); - sWasInGesture = false; } private void printTouchEvent(String title, int x, int y, long eventTime) { diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java index ae123e29a..ac0a56ba3 100644 --- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java +++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java @@ -18,7 +18,6 @@ package com.android.inputmethod.keyboard; import android.graphics.Rect; import android.text.TextUtils; -import android.util.FloatMath; import com.android.inputmethod.keyboard.Keyboard.Params.TouchPositionCorrection; import com.android.inputmethod.latin.JniUtils; @@ -155,7 +154,9 @@ public class ProximityInfo { final float radius = touchPositionCorrection.mRadii[row]; sweetSpotCenterXs[i] = hitBox.exactCenterX() + x * hitBoxWidth; sweetSpotCenterYs[i] = hitBox.exactCenterY() + y * hitBoxHeight; - sweetSpotRadii[i] = radius * FloatMath.sqrt( + // Note that, in recent versions of Android, FloatMath is actually slower than + // java.lang.Math due to the way the JIT optimizes java.lang.Math. + sweetSpotRadii[i] = radius * (float)Math.sqrt( hitBoxWidth * hitBoxWidth + hitBoxHeight * hitBoxHeight); } } diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java index 28d6c1d07..79e977a40 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java @@ -16,7 +16,6 @@ package com.android.inputmethod.keyboard.internal; import android.graphics.Canvas; import android.graphics.Paint; -import android.util.FloatMath; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.InputPointers; @@ -38,19 +37,16 @@ public class GestureStroke { private int mLastPointY; private int mMinGestureLength; - private int mMinGestureLengthWhileInGesture; private int mMinGestureSampleLength; // TODO: Move some of these to resource. - private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 1.0f; - private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH_WHILE_IN_GESTURE = 0.5f; - private static final int MIN_GESTURE_DURATION = 150; // msec - private static final int MIN_GESTURE_DURATION_WHILE_IN_GESTURE = 75; // msec - private static final float MIN_GESTURE_SAMPLING_RATIO_TO_KEY_HEIGHT = 1.0f / 6.0f; + private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 0.75f; + private static final int MIN_GESTURE_DURATION = 100; // msec + private static final float MIN_GESTURE_SAMPLING_RATIO_TO_KEY_WIDTH = 1.0f / 6.0f; private static final float GESTURE_RECOG_SPEED_THRESHOLD = 0.4f; // dip/msec private static final float GESTURE_RECOG_CURVATURE_THRESHOLD = (float)(Math.PI / 4.0f); - private static final float DOUBLE_PI = (float)(2 * Math.PI); + private static final float DOUBLE_PI = (float)(2.0f * Math.PI); // Fade based on number of gesture samples, see MIN_GESTURE_SAMPLING_RATIO_TO_KEY_HEIGHT private static final int DRAWING_GESTURE_FADE_START = 10; @@ -61,21 +57,15 @@ public class GestureStroke { reset(); } - public void setGestureSampleLength(final int keyWidth, final int keyHeight) { + public void setGestureSampleLength(final int keyWidth) { // TODO: Find an appropriate base metric for these length. Maybe diagonal length of the key? mMinGestureLength = (int)(keyWidth * MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH); - mMinGestureLengthWhileInGesture = (int)( - keyWidth * MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH_WHILE_IN_GESTURE); - mMinGestureSampleLength = (int)(keyHeight * MIN_GESTURE_SAMPLING_RATIO_TO_KEY_HEIGHT); + mMinGestureSampleLength = (int)(keyWidth * MIN_GESTURE_SAMPLING_RATIO_TO_KEY_WIDTH); } - public boolean isStartOfAGesture(final int downDuration, final boolean wasInGesture) { - // The tolerance of the time duration and the stroke length to detect the start of a - // gesture stroke should be eased when the previous input was a gesture input. - if (wasInGesture) { - return downDuration > MIN_GESTURE_DURATION_WHILE_IN_GESTURE - && mLength > mMinGestureLengthWhileInGesture; - } + public boolean isStartOfAGesture() { + final int size = mEventTimes.getLength(); + final int downDuration = (size > 0) ? mEventTimes.get(size - 1) : 0; return downDuration > MIN_GESTURE_DURATION && mLength > mMinGestureLength; } @@ -154,19 +144,21 @@ public class GestureStroke { mLastIncrementalBatchSize = size; } - private static float getDistance(final int p1x, final int p1y, - final int p2x, final int p2y) { - final float dx = p1x - p2x; - final float dy = p1y - p2y; - // TODO: Optimize out this {@link FloatMath#sqrt(float)} call. - return FloatMath.sqrt(dx * dx + dy * dy); + private static float getDistance(final int x1, final int y1, final int x2, final int y2) { + final float dx = x1 - x2; + final float dy = y1 - y2; + // Note that, in recent versions of Android, FloatMath is actually slower than + // java.lang.Math due to the way the JIT optimizes java.lang.Math. + return (float)Math.sqrt(dx * dx + dy * dy); } - private static float getAngle(final int p1x, final int p1y, final int p2x, final int p2y) { - final int dx = p1x - p2x; - final int dy = p1y - p2y; + private static float getAngle(final int x1, final int y1, final int x2, final int y2) { + final int dx = x1 - x2; + final int dy = y1 - y2; if (dx == 0 && dy == 0) return 0; - return (float)Math.atan2(dy, dx); + // Would it be faster to call atan2f() directly via JNI? Not sure about what the JIT + // does with Math.atan2(). + return (float)Math.atan2((double)dy, (double)dx); } private static float getAngleDiff(final float a1, final float a2) { @@ -177,12 +169,12 @@ public class GestureStroke { return diff; } - public void drawGestureTrail(Canvas canvas, Paint paint, int lastX, int lastY) { + public void drawGestureTrail(final Canvas canvas, final Paint paint) { // TODO: These paint parameter interpolation should be tunable, possibly introduce an object // that implements an interface such as Paint getPaint(int step, int strokePoints) final int size = mXCoordinates.getLength(); - int[] xCoords = mXCoordinates.getPrimitiveArray(); - int[] yCoords = mYCoordinates.getPrimitiveArray(); + final int[] xCoords = mXCoordinates.getPrimitiveArray(); + final int[] yCoords = mYCoordinates.getPrimitiveArray(); int alpha = Constants.Color.ALPHA_OPAQUE; for (int i = size - 1; i > 0 && alpha > 0; i--) { paint.setAlpha(alpha); @@ -190,9 +182,6 @@ public class GestureStroke { alpha -= DRAWING_GESTURE_FADE_RATE; } canvas.drawLine(xCoords[i - 1], yCoords[i - 1], xCoords[i], yCoords[i], paint); - if (i == size - 1) { - canvas.drawLine(lastX, lastY, xCoords[i], yCoords[i], paint); - } } } } diff --git a/java/src/com/android/inputmethod/latin/AutoCorrection.java b/java/src/com/android/inputmethod/latin/AutoCorrection.java index a66337404..048166807 100644 --- a/java/src/com/android/inputmethod/latin/AutoCorrection.java +++ b/java/src/com/android/inputmethod/latin/AutoCorrection.java @@ -75,17 +75,10 @@ public class AutoCorrection { return maxFreq; } - // Returns true if this is a whitelist entry, or it isn't in any dictionary. - public static boolean isWhitelistedOrNotAWord( + // Returns true if this isn't in any dictionary. + public static boolean isNotAWord( final ConcurrentHashMap<String, Dictionary> dictionaries, final CharSequence word, final boolean ignoreCase) { - final WhitelistDictionary whitelistDictionary = - (WhitelistDictionary)dictionaries.get(Dictionary.TYPE_WHITELIST); - // If "word" is in the whitelist dictionary, it should not be auto corrected. - if (whitelistDictionary != null - && whitelistDictionary.shouldForciblyAutoCorrectFrom(word)) { - return true; - } return !isValidWord(dictionaries, word, ignoreCase); } diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index e0adc9a71..f0f5cd320 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -51,7 +51,8 @@ public class BinaryDictionary extends Dictionary { private static final int TYPED_LETTER_MULTIPLIER = 2; private long mNativeDict; - private final int[] mInputCodes = new int[MAX_WORD_LENGTH]; + private final int[] mInputCodePoints = new int[MAX_WORD_LENGTH]; + // TODO: The below should be int[] mOutputCodePoints private final char[] mOutputChars = new char[MAX_WORD_LENGTH * MAX_RESULTS]; private final int[] mSpaceIndices = new int[MAX_SPACES]; private final int[] mOutputScores = new int[MAX_RESULTS]; @@ -78,6 +79,7 @@ public class BinaryDictionary extends Dictionary { mUseFullEditDistance = useFullEditDistance; loadDictionary(filename, offset, length); mDicTraverseSession = new DicTraverseSession(locale); + mDicTraverseSession.initSession(mNativeDict); } static { @@ -88,18 +90,17 @@ public class BinaryDictionary extends Dictionary { int typedLetterMultiplier, int fullWordMultiplier, int maxWordLength, int maxWords, int maxPredictions); private native void closeNative(long dict); - private native int getFrequencyNative(long dict, int[] word, int wordLength); + private native int getFrequencyNative(long dict, int[] word); private native boolean isValidBigramNative(long dict, int[] word1, int[] word2); private native int getSuggestionsNative(long dict, long proximityInfo, long traverseSession, int[] xCoordinates, int[] yCoordinates, int[] times, int[] pointerIds, - int[] inputCodes, int codesSize, int commitPoint, boolean isGesture, + int[] inputCodePoints, int codesSize, int commitPoint, boolean isGesture, int[] prevWordCodePointArray, boolean useFullEditDistance, char[] outputChars, int[] outputScores, int[] outputIndices, int[] outputTypes); - private static native float calcNormalizedScoreNative( - char[] before, int beforeLength, char[] after, int afterLength, int score); - private static native int editDistanceNative( - char[] before, int beforeLength, char[] after, int afterLength); + private static native float calcNormalizedScoreNative(char[] before, char[] after, int score); + private static native int editDistanceNative(char[] before, char[] after); + // TODO: Move native dict into session private final void loadDictionary(String path, long startOffset, long length) { mNativeDict = openNative(path, startOffset, length, TYPED_LETTER_MULTIPLIER, FULL_WORD_SCORE_MULTIPLIER, MAX_WORD_LENGTH, MAX_WORDS, MAX_PREDICTIONS); @@ -109,9 +110,7 @@ public class BinaryDictionary extends Dictionary { public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, final CharSequence prevWord, final ProximityInfo proximityInfo) { if (!isValidDictionary()) return null; - Arrays.fill(mInputCodes, WordComposer.NOT_A_CODE); - Arrays.fill(mOutputChars, (char) 0); - Arrays.fill(mOutputScores, 0); + Arrays.fill(mInputCodePoints, WordComposer.NOT_A_CODE); // TODO: toLowerCase in the native code final int[] prevWordCodePointArray = (null == prevWord) ? null : StringUtils.toCodePointArray(prevWord.toString()); @@ -121,7 +120,7 @@ public class BinaryDictionary extends Dictionary { if (composerSize <= 1 || !isGesture) { if (composerSize > MAX_WORD_LENGTH - 1) return null; for (int i = 0; i < composerSize; i++) { - mInputCodes[i] = composer.getCodeAt(i); + mInputCodePoints[i] = composer.getCodeAt(i); } } @@ -129,10 +128,9 @@ public class BinaryDictionary extends Dictionary { final int codesSize = isGesture ? ips.getPointerSize() : composerSize; // proximityInfo and/or prevWordForBigrams may not be null. final int tmpCount = getSuggestionsNative(mNativeDict, - proximityInfo.getNativeProximityInfo(), - mDicTraverseSession.getSession(), ips.getXCoordinates(), - ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(), - mInputCodes, codesSize, 0 /* commitPoint */, isGesture, prevWordCodePointArray, + proximityInfo.getNativeProximityInfo(), mDicTraverseSession.getSession(), + ips.getXCoordinates(), ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(), + mInputCodePoints, codesSize, 0 /* commitPoint */, isGesture, prevWordCodePointArray, mUseFullEditDistance, mOutputChars, mOutputScores, mSpaceIndices, mOutputTypes); final int count = Math.min(tmpCount, MAX_PREDICTIONS); @@ -145,9 +143,10 @@ public class BinaryDictionary extends Dictionary { ++len; } if (len > 0) { + final int score = SuggestedWordInfo.KIND_WHITELIST == mOutputTypes[j] + ? SuggestedWordInfo.MAX_SCORE : mOutputScores[j]; suggestions.add(new SuggestedWordInfo( - new String(mOutputChars, start, len), - mOutputScores[j], SuggestedWordInfo.KIND_CORRECTION, mDictType)); + new String(mOutputChars, start, len), score, mOutputTypes[j], mDictType)); } } return suggestions; @@ -158,13 +157,11 @@ public class BinaryDictionary extends Dictionary { } public static float calcNormalizedScore(String before, String after, int score) { - return calcNormalizedScoreNative(before.toCharArray(), before.length(), - after.toCharArray(), after.length(), score); + return calcNormalizedScoreNative(before.toCharArray(), after.toCharArray(), score); } public static int editDistance(String before, String after) { - return editDistanceNative( - before.toCharArray(), before.length(), after.toCharArray(), after.length()); + return editDistanceNative(before.toCharArray(), after.toCharArray()); } @Override @@ -175,8 +172,8 @@ public class BinaryDictionary extends Dictionary { @Override public int getFrequency(CharSequence word) { if (word == null) return -1; - int[] chars = StringUtils.toCodePointArray(word.toString()); - return getFrequencyNative(mNativeDict, chars, chars.length); + int[] codePoints = StringUtils.toCodePointArray(word.toString()); + return getFrequencyNative(mNativeDict, codePoints); } // TODO: Add a batch process version (isValidBigramMultiple?) to avoid excessive numbers of jni diff --git a/java/src/com/android/inputmethod/latin/DicTraverseSession.java b/java/src/com/android/inputmethod/latin/DicTraverseSession.java index 437876e05..c76815363 100644 --- a/java/src/com/android/inputmethod/latin/DicTraverseSession.java +++ b/java/src/com/android/inputmethod/latin/DicTraverseSession.java @@ -23,8 +23,8 @@ public class DicTraverseSession { JniUtils.loadNativeLibrary(); } private native long setDicTraverseSessionNative(String locale); - private native void initDicTraverseSessionNative( - long nativeDicTraverseSession, int[] previousWord, int previwousWordLength); + private native void initDicTraverseSessionNative(long nativeDicTraverseSession, + long dictionary, int[] previousWord, int previousWordLength); private native void releaseDicTraverseSessionNative(long nativeDicTraverseSession); private long mNativeDicTraverseSession; @@ -32,19 +32,19 @@ public class DicTraverseSession { public DicTraverseSession(Locale locale) { mNativeDicTraverseSession = createNativeDicTraverseSession( locale != null ? locale.toString() : ""); - initSession(); } public long getSession() { return mNativeDicTraverseSession; } - public void initSession() { - initSession(null, 0); + public void initSession(long dictionary) { + initSession(dictionary, null, 0); } - public void initSession(int[] previousWord, int previousWordLength) { - initDicTraverseSessionNative(mNativeDicTraverseSession, previousWord, previousWordLength); + public void initSession(long dictionary, int[] previousWord, int previousWordLength) { + initDicTraverseSessionNative( + mNativeDicTraverseSession, dictionary, previousWord, previousWordLength); } private final long createNativeDicTraverseSession(String locale) { diff --git a/java/src/com/android/inputmethod/latin/NativeUtils.java b/java/src/com/android/inputmethod/latin/NativeUtils.java deleted file mode 100644 index 9cc2bc02e..000000000 --- a/java/src/com/android/inputmethod/latin/NativeUtils.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.inputmethod.latin; - -public class NativeUtils { - static { - JniUtils.loadNativeLibrary(); - } - - private NativeUtils() { - // This utility class is not publicly instantiable. - } - - /** - * This method just calls up libm's powf() directly. - */ - public static native float powf(float x, float y); -} diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index a65d36adb..8a2341d5e 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -208,23 +208,34 @@ public class Suggest { wordComposerForLookup, prevWordForBigram, proximityInfo)); } - // TODO: Change this scheme - a boolean is not enough. A whitelisted word may be "valid" - // but still autocorrected from - in the case the whitelist only capitalizes the word. - // The whitelist should be case-insensitive, so it's not possible to be consistent with - // a boolean flag. Right now this is handled with a slight hack in - // WhitelistDictionary#shouldForciblyAutoCorrectFrom. - final boolean allowsToBeAutoCorrected = AutoCorrection.isWhitelistedOrNotAWord( - mDictionaries, consideredWord, wordComposer.isFirstCharCapitalized()); - - final CharSequence whitelistedWord = + final CharSequence whitelistedWordFromWhitelistDictionary = mWhiteListDictionary.getWhitelistedWord(consideredWord); - if (whitelistedWord != null) { + if (whitelistedWordFromWhitelistDictionary != null) { // MAX_SCORE ensures this will be considered strong enough to be auto-corrected - suggestionsSet.add(new SuggestedWordInfo(whitelistedWord, + suggestionsSet.add(new SuggestedWordInfo(whitelistedWordFromWhitelistDictionary, SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_WHITELIST, Dictionary.TYPE_WHITELIST)); } + final CharSequence whitelistedWord; + if (suggestionsSet.isEmpty()) { + whitelistedWord = null; + } else if (SuggestedWordInfo.KIND_WHITELIST != suggestionsSet.first().mKind) { + whitelistedWord = null; + } else { + whitelistedWord = suggestionsSet.first().mWord; + } + + // TODO: Change this scheme - a boolean is not enough. A whitelisted word may be "valid" + // but still autocorrected from - in the case the whitelist only capitalizes the word. + // The whitelist should be case-insensitive, so it's not possible to be consistent with + // a boolean flag. Right now this is handled with a slight hack in + // WhitelistDictionary#shouldForciblyAutoCorrectFrom. + final boolean allowsToBeAutoCorrected = (null != whitelistedWord + && !whitelistedWord.equals(consideredWord)) + || AutoCorrection.isNotAWord(mDictionaries, consideredWord, + wordComposer.isFirstCharCapitalized()); + final boolean hasAutoCorrection; // TODO: using isCorrectionEnabled here is not very good. It's probably useless, because // any attempt to do auto-correction is already shielded with a test for this flag; at the diff --git a/java/src/com/android/inputmethod/latin/UserHistoryForgettingCurveUtils.java b/java/src/com/android/inputmethod/latin/UserHistoryForgettingCurveUtils.java index 1de95d7b8..5a2fdf48e 100644 --- a/java/src/com/android/inputmethod/latin/UserHistoryForgettingCurveUtils.java +++ b/java/src/com/android/inputmethod/latin/UserHistoryForgettingCurveUtils.java @@ -212,7 +212,7 @@ public class UserHistoryForgettingCurveUtils { for (int j = 0; j < ELAPSED_TIME_MAX; ++j) { final float elapsedHours = j * ELAPSED_TIME_INTERVAL_HOURS; final float freq = initialFreq - * NativeUtils.powf(initialFreq, elapsedHours / HALF_LIFE_HOURS); + * (float)Math.pow(initialFreq, elapsedHours / HALF_LIFE_HOURS); final int intFreq = Math.min(FC_FREQ_MAX, Math.max(0, (int)freq)); SCORE_TABLE[i][j] = intFreq; } |