aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java21
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionary.java11
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java20
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java7
4 files changed, 29 insertions, 30 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 2b1cc43cd..07b9c1e8c 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -31,6 +31,7 @@ import com.android.inputmethod.keyboard.internal.KeyStyles;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.latin.XmlParseUtils;
import org.xmlpull.v1.XmlPullParser;
@@ -715,22 +716,30 @@ public class Keyboard {
R.styleable.Keyboard_Key);
try {
final int displayHeight = mDisplayMetrics.heightPixels;
- final int keyboardHeight = (int)keyboardAttr.getDimension(
- R.styleable.Keyboard_keyboardHeight, displayHeight / 2);
- final int maxKeyboardHeight = (int)getDimensionOrFraction(keyboardAttr,
+ final String keyboardHeightString = Utils.getDeviceOverrideValue(
+ mResources, R.array.keyboard_heights, null);
+ final float keyboardHeight;
+ if (keyboardHeightString != null) {
+ keyboardHeight = Float.parseFloat(keyboardHeightString)
+ * mDisplayMetrics.density;
+ } else {
+ keyboardHeight = keyboardAttr.getDimension(
+ R.styleable.Keyboard_keyboardHeight, displayHeight / 2);
+ }
+ final float maxKeyboardHeight = getDimensionOrFraction(keyboardAttr,
R.styleable.Keyboard_maxKeyboardHeight, displayHeight, displayHeight / 2);
- int minKeyboardHeight = (int)getDimensionOrFraction(keyboardAttr,
+ float minKeyboardHeight = getDimensionOrFraction(keyboardAttr,
R.styleable.Keyboard_minKeyboardHeight, displayHeight, displayHeight / 2);
if (minKeyboardHeight < 0) {
// Specified fraction was negative, so it should be calculated against display
// width.
- minKeyboardHeight = -(int)getDimensionOrFraction(keyboardAttr,
+ minKeyboardHeight = -getDimensionOrFraction(keyboardAttr,
R.styleable.Keyboard_minKeyboardHeight, displayWidth, displayWidth / 2);
}
final Params params = mParams;
// Keyboard height will not exceed maxKeyboardHeight and will not be less than
// minKeyboardHeight.
- params.mOccupiedHeight = Math.max(
+ params.mOccupiedHeight = (int)Math.max(
Math.min(keyboardHeight, maxKeyboardHeight), minKeyboardHeight);
params.mOccupiedWidth = params.mId.mWidth;
params.mTopPadding = (int)getDimensionOrFraction(keyboardAttr,
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index dfc8c8e9d..a9df1ce12 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -55,6 +55,8 @@ public class BinaryDictionary extends Dictionary {
public static final Flag FLAG_REQUIRES_GERMAN_UMLAUT_PROCESSING =
new Flag(R.bool.config_require_umlaut_processing, 0x1);
+ public static final Flag FLAG_REQUIRES_FRENCH_LIGATURES_PROCESSING =
+ new Flag(R.bool.config_require_ligatures_processing, 0x4);
// FULL_EDIT_DISTANCE is a flag that forces the dictionary to use full words
// when computing edit distance, instead of the default behavior of stopping
@@ -77,6 +79,7 @@ public class BinaryDictionary extends Dictionary {
// actual value will be read from the configuration/extra value at run time for
// the configuration at dictionary creation time.
FLAG_REQUIRES_GERMAN_UMLAUT_PROCESSING,
+ FLAG_REQUIRES_FRENCH_LIGATURES_PROCESSING,
};
private int mFlags = 0;
@@ -202,9 +205,11 @@ public class BinaryDictionary extends Dictionary {
Arrays.fill(mInputCodes, WordComposer.NOT_A_CODE);
for (int i = 0; i < codesSize; i++) {
- int[] alternatives = codes.getCodesAt(i);
- System.arraycopy(alternatives, 0, mInputCodes, i * MAX_PROXIMITY_CHARS_SIZE,
- Math.min(alternatives.length, MAX_PROXIMITY_CHARS_SIZE));
+ final int[] alternatives = codes.getCodesAt(i);
+ if (alternatives == null || alternatives.length < 1) {
+ continue;
+ }
+ mInputCodes[i] = alternatives[0];
}
Arrays.fill(outputChars, (char) 0);
Arrays.fill(scores, 0);
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index 231211d31..cabf68099 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -20,8 +20,6 @@ import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyDetector;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
-import com.android.inputmethod.latin.spellcheck.AndroidSpellCheckerService;
-import com.android.inputmethod.latin.spellcheck.SpellCheckerProximityInfo;
import java.util.ArrayList;
import java.util.Arrays;
@@ -172,8 +170,7 @@ public class WordComposer {
/**
* Internal method to retrieve reasonable proximity info for a character.
*/
- private void addKeyInfo(final int codePoint, final Keyboard keyboard,
- final KeyDetector keyDetector) {
+ private void addKeyInfo(final int codePoint, final Keyboard keyboard) {
for (final Key key : keyboard.mKeys) {
if (key.mCode == codePoint) {
final int x = key.mX + key.mWidth / 2;
@@ -191,27 +188,16 @@ public class WordComposer {
* Set the currently composing word to the one passed as an argument.
* This will register NOT_A_COORDINATE for X and Ys, and use the passed keyboard for proximity.
*/
- private void setComposingWord(final CharSequence word, final Keyboard keyboard,
- final KeyDetector keyDetector) {
+ public void setComposingWord(final CharSequence word, final Keyboard keyboard) {
reset();
final int length = word.length();
for (int i = 0; i < length; i = Character.offsetByCodePoints(word, i, 1)) {
int codePoint = Character.codePointAt(word, i);
- addKeyInfo(codePoint, keyboard, keyDetector);
+ addKeyInfo(codePoint, keyboard);
}
}
/**
- * Shortcut for the above method, this will create a new KeyDetector for the passed keyboard.
- */
- public void setComposingWord(final CharSequence word, final Keyboard keyboard) {
- final KeyDetector keyDetector = new KeyDetector(0);
- keyDetector.setKeyboard(keyboard, 0, 0);
- keyDetector.setProximityCorrectionEnabled(true);
- setComposingWord(word, keyboard, keyDetector);
- }
-
- /**
* Delete the last keystroke as a result of hitting backspace.
*/
public void deleteLast() {
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java
index 90c0aac1b..7627700dd 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java
@@ -39,7 +39,7 @@ public class SpellCheckerProximityInfo {
final protected static void buildProximityIndices(final int[] proximity,
final TreeMap<Integer, Integer> indices) {
for (int i = 0; i < proximity.length; i += ROW_SIZE) {
- if (NUL != proximity[i]) indices.put(proximity[i], i);
+ if (NUL != proximity[i]) indices.put(proximity[i], i / ROW_SIZE);
}
}
final protected static int computeIndex(final int characterCode,
@@ -198,9 +198,8 @@ public class SpellCheckerProximityInfo {
// inferior to 1 << 16
public static int getXYForCodePointAndScript(final int codePoint, final int script) {
final int index = getIndexOfCodeForScript(codePoint, script);
- // TODO: precompute index / ROW_SIZE
- final int y = index / (PROXIMITY_GRID_WIDTH * ROW_SIZE);
- final int x = (index / ROW_SIZE) % PROXIMITY_GRID_WIDTH;
+ final int y = index / PROXIMITY_GRID_WIDTH;
+ final int x = index % PROXIMITY_GRID_WIDTH;
if (y > PROXIMITY_GRID_HEIGHT) {
// Safety check, should be entirely useless
throw new RuntimeException("Wrong y coordinate in spell checker proximity");