aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod
diff options
context:
space:
mode:
authorsatok <satok@google.com>2012-05-16 20:42:12 +0900
committersatok <satok@google.com>2012-05-16 20:45:05 +0900
commit0028ed3627ff4f37a62a80f3b2c857e373cd5090 (patch)
tree5dfb19c9605b73416987d3daf3941671fab0f87d /java/src/com/android/inputmethod
parentf837b57bf51b2767ec62a6140b28d84383ad75b1 (diff)
downloadlatinime-0028ed3627ff4f37a62a80f3b2c857e373cd5090.tar.gz
latinime-0028ed3627ff4f37a62a80f3b2c857e373cd5090.tar.xz
latinime-0028ed3627ff4f37a62a80f3b2c857e373cd5090.zip
Use "float" instead of "double"
Change-Id: I93ed4d88ede4058f081dd8d634b00dfff4e96d07
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r--java/src/com/android/inputmethod/keyboard/ProximityInfo.java3
-rw-r--r--java/src/com/android/inputmethod/latin/AutoCorrection.java6
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionary.java4
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsValues.java10
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java6
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java22
6 files changed, 26 insertions, 25 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
index 90394ce5e..5ea28abe2 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -18,6 +18,7 @@ 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;
@@ -147,7 +148,7 @@ public class ProximityInfo {
final float radius = touchPositionCorrection.mRadii[row];
sweetSpotCenterXs[i] = hitBoxCenterX + x * hitBoxWidth;
sweetSpotCenterYs[i] = hitBoxCenterY + y * hitBoxHeight;
- sweetSpotRadii[i] = radius * (float) Math.sqrt(
+ sweetSpotRadii[i] = radius * FloatMath.sqrt(
hitBoxWidth * hitBoxWidth + hitBoxHeight * hitBoxHeight);
}
}
diff --git a/java/src/com/android/inputmethod/latin/AutoCorrection.java b/java/src/com/android/inputmethod/latin/AutoCorrection.java
index 38444a10c..da1936aef 100644
--- a/java/src/com/android/inputmethod/latin/AutoCorrection.java
+++ b/java/src/com/android/inputmethod/latin/AutoCorrection.java
@@ -35,7 +35,7 @@ public class AutoCorrection {
public static CharSequence computeAutoCorrectionWord(
HashMap<String, Dictionary> dictionaries,
WordComposer wordComposer, ArrayList<SuggestedWordInfo> suggestions,
- CharSequence consideredWord, double autoCorrectionThreshold,
+ CharSequence consideredWord, float autoCorrectionThreshold,
CharSequence whitelistedWord) {
if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) {
return whitelistedWord;
@@ -100,14 +100,14 @@ public class AutoCorrection {
private static boolean hasAutoCorrectionForBinaryDictionary(WordComposer wordComposer,
ArrayList<SuggestedWordInfo> suggestions,
- CharSequence consideredWord, double autoCorrectionThreshold) {
+ CharSequence consideredWord, float autoCorrectionThreshold) {
if (wordComposer.size() > 1 && suggestions.size() > 0) {
final SuggestedWordInfo autoCorrectionSuggestion = suggestions.get(0);
//final int autoCorrectionSuggestionScore = sortedScores[0];
final int autoCorrectionSuggestionScore = autoCorrectionSuggestion.mScore;
// TODO: when the normalized score of the first suggestion is nearly equals to
// the normalized score of the second suggestion, behave less aggressive.
- final double normalizedScore = BinaryDictionary.calcNormalizedScore(
+ final float normalizedScore = BinaryDictionary.calcNormalizedScore(
consideredWord.toString(), autoCorrectionSuggestion.mWord.toString(),
autoCorrectionSuggestionScore);
if (DBG) {
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index cc20f4294..e18aee6ff 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -92,7 +92,7 @@ public class BinaryDictionary extends Dictionary {
private native int getBigramsNative(long dict, int[] prevWord, int prevWordLength,
int[] inputCodes, int inputCodesLength, char[] outputChars, int[] scores,
int maxWordLength, int maxBigrams);
- private static native double calcNormalizedScoreNative(
+ 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);
@@ -189,7 +189,7 @@ public class BinaryDictionary extends Dictionary {
prevWordCodePointArray, mUseFullEditDistance, outputChars, scores);
}
- public static double calcNormalizedScore(String before, String after, int score) {
+ public static float calcNormalizedScore(String before, String after, int score) {
return calcNormalizedScoreNative(before.toCharArray(), before.length(),
after.toCharArray(), after.length(), score);
}
diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index 55b896f5a..932920a60 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -77,7 +77,7 @@ public class SettingsValues {
public final float mFxVolume;
public final int mKeyPreviewPopupDismissDelay;
public final boolean mAutoCorrectEnabled;
- public final double mAutoCorrectionThreshold;
+ public final float mAutoCorrectionThreshold;
private final boolean mVoiceKeyEnabled;
private final boolean mVoiceKeyOnMain;
@@ -255,21 +255,21 @@ public class SettingsValues {
R.bool.config_default_next_word_prediction));
}
- private static double getAutoCorrectionThreshold(final Resources resources,
+ private static float getAutoCorrectionThreshold(final Resources resources,
final String currentAutoCorrectionSetting) {
final String[] autoCorrectionThresholdValues = resources.getStringArray(
R.array.auto_correction_threshold_values);
// When autoCorrectionThreshold is greater than 1.0, it's like auto correction is off.
- double autoCorrectionThreshold = Double.MAX_VALUE;
+ float autoCorrectionThreshold = Float.MAX_VALUE;
try {
final int arrayIndex = Integer.valueOf(currentAutoCorrectionSetting);
if (arrayIndex >= 0 && arrayIndex < autoCorrectionThresholdValues.length) {
- autoCorrectionThreshold = Double.parseDouble(
+ autoCorrectionThreshold = Float.parseFloat(
autoCorrectionThresholdValues[arrayIndex]);
}
} catch (NumberFormatException e) {
// Whenever the threshold settings are correct, never come here.
- autoCorrectionThreshold = Double.MAX_VALUE;
+ autoCorrectionThreshold = Float.MAX_VALUE;
Log.w(TAG, "Cannot load auto correction threshold setting."
+ " currentAutoCorrectionSetting: " + currentAutoCorrectionSetting
+ ", autoCorrectionThresholdValues: "
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index d7cd0575b..9e478fab4 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -77,7 +77,7 @@ public class Suggest implements Dictionary.WordCallback {
private static final int PREF_MAX_BIGRAMS = 60;
- private double mAutoCorrectionThreshold;
+ private float mAutoCorrectionThreshold;
private ArrayList<SuggestedWordInfo> mSuggestions = new ArrayList<SuggestedWordInfo>();
private ArrayList<SuggestedWordInfo> mBigramSuggestions = new ArrayList<SuggestedWordInfo>();
@@ -185,7 +185,7 @@ public class Suggest implements Dictionary.WordCallback {
userHistoryDictionary);
}
- public void setAutoCorrectionThreshold(double threshold) {
+ public void setAutoCorrectionThreshold(float threshold) {
mAutoCorrectionThreshold = threshold;
}
@@ -416,7 +416,7 @@ public class Suggest implements Dictionary.WordCallback {
// than i because we added the typed word to mSuggestions without touching mScores.
for (int i = 0; i < suggestionsSize - 1; ++i) {
final SuggestedWordInfo cur = suggestions.get(i + 1);
- final double normalizedScore = BinaryDictionary.calcNormalizedScore(
+ final float normalizedScore = BinaryDictionary.calcNormalizedScore(
typedWord, cur.toString(), cur.mScore);
final String scoreInfoString;
if (normalizedScore > 0) {
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index 0c9f9fb27..d7c8e3850 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -79,9 +79,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService
private Dictionary mContactsDictionary;
// The threshold for a candidate to be offered as a suggestion.
- private double mSuggestionThreshold;
+ private float mSuggestionThreshold;
// The threshold for a suggestion to be considered "recommended".
- private double mRecommendedThreshold;
+ private float mRecommendedThreshold;
// Whether to use the contacts dictionary
private boolean mUseContactsDictionary;
private final Object mUseContactsLock = new Object();
@@ -113,9 +113,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService
@Override public void onCreate() {
super.onCreate();
mSuggestionThreshold =
- Double.parseDouble(getString(R.string.spellchecker_suggestion_threshold_value));
+ Float.parseFloat(getString(R.string.spellchecker_suggestion_threshold_value));
mRecommendedThreshold =
- Double.parseDouble(getString(R.string.spellchecker_recommended_threshold_value));
+ Float.parseFloat(getString(R.string.spellchecker_recommended_threshold_value));
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this);
onSharedPreferenceChanged(prefs, PREF_USE_CONTACTS_KEY);
@@ -207,8 +207,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService
private final ArrayList<CharSequence> mSuggestions;
private final int[] mScores;
private final String mOriginalText;
- private final double mSuggestionThreshold;
- private final double mRecommendedThreshold;
+ private final float mSuggestionThreshold;
+ private final float mRecommendedThreshold;
private final int mMaxLength;
private int mLength = 0;
@@ -217,8 +217,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService
private String mBestSuggestion = null;
private int mBestScore = Integer.MIN_VALUE; // As small as possible
- SuggestionsGatherer(final String originalText, final double suggestionThreshold,
- final double recommendedThreshold, final int maxLength) {
+ SuggestionsGatherer(final String originalText, final float suggestionThreshold,
+ final float recommendedThreshold, final int maxLength) {
mOriginalText = originalText;
mSuggestionThreshold = suggestionThreshold;
mRecommendedThreshold = recommendedThreshold;
@@ -261,7 +261,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService
// Compute the normalized score and skip this word if it's normalized score does not
// make the threshold.
final String wordString = new String(word, wordOffset, wordLength);
- final double normalizedScore =
+ final float normalizedScore =
BinaryDictionary.calcNormalizedScore(mOriginalText, wordString, score);
if (normalizedScore < mSuggestionThreshold) {
if (DBG) Log.i(TAG, wordString + " does not make the score threshold");
@@ -295,7 +295,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService
hasRecommendedSuggestions = false;
} else {
gatheredSuggestions = EMPTY_STRING_ARRAY;
- final double normalizedScore = BinaryDictionary.calcNormalizedScore(
+ final float normalizedScore = BinaryDictionary.calcNormalizedScore(
mOriginalText, mBestSuggestion, mBestScore);
hasRecommendedSuggestions = (normalizedScore > mRecommendedThreshold);
}
@@ -329,7 +329,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService
final int bestScore = mScores[mLength - 1];
final CharSequence bestSuggestion = mSuggestions.get(0);
- final double normalizedScore =
+ final float normalizedScore =
BinaryDictionary.calcNormalizedScore(
mOriginalText, bestSuggestion.toString(), bestScore);
hasRecommendedSuggestions = (normalizedScore > mRecommendedThreshold);