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.java1
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java39
-rw-r--r--java/src/com/android/inputmethod/keyboard/ProximityInfo.java21
-rw-r--r--java/src/com/android/inputmethod/latin/DebugSettings.java5
4 files changed, 22 insertions, 44 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 5660d1942..320b1bea2 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -388,6 +388,7 @@ public class Keyboard {
}
}
+ // TODO: Move this method to KeyboardSwitcher.
public static String toThemeName(int themeId) {
// This should be aligned with theme-*.xml resource files' themeId attribute.
switch (themeId) {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index ac8dd1b95..efe5aa9cf 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -39,8 +39,7 @@ import com.android.inputmethod.latin.SettingsValues;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.Utils;
-public class KeyboardSwitcher implements KeyboardState.SwitchActions,
- SharedPreferences.OnSharedPreferenceChangeListener {
+public class KeyboardSwitcher implements KeyboardState.SwitchActions {
private static final String TAG = KeyboardSwitcher.class.getSimpleName();
public static final String PREF_KEYBOARD_LAYOUT = "pref_keyboard_layout_20110916";
@@ -94,7 +93,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mState = new KeyboardState(this);
setContextThemeWrapper(ims, getKeyboardThemeIndex(ims, prefs));
- prefs.registerOnSharedPreferenceChangeListener(this);
mForceNonDistinctMultitouch = prefs.getBoolean(
DebugSettings.FORCE_NON_DISTINCT_MULTITOUCH_KEY, false);
}
@@ -341,34 +339,26 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
}
public View onCreateInputView() {
- return createInputView(mThemeIndex, true);
- }
-
- private View createInputView(final int newThemeIndex, final boolean forceRecreate) {
- if (mCurrentInputView != null && mThemeIndex == newThemeIndex && !forceRecreate)
- return mCurrentInputView;
-
if (mKeyboardView != null) {
mKeyboardView.closing();
}
- final int oldThemeIndex = mThemeIndex;
Utils.GCUtils.getInstance().reset();
boolean tryGC = true;
for (int i = 0; i < Utils.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) {
try {
- setContextThemeWrapper(mInputMethodService, newThemeIndex);
+ setContextThemeWrapper(mInputMethodService, mThemeIndex);
mCurrentInputView = (InputView)LayoutInflater.from(mThemeContext).inflate(
R.layout.input_view, null);
tryGC = false;
} catch (OutOfMemoryError e) {
Log.w(TAG, "load keyboard failed: " + e);
tryGC = Utils.GCUtils.getInstance().tryGCOrWait(
- oldThemeIndex + "," + newThemeIndex, e);
+ Keyboard.toThemeName(mThemeIndex), e);
} catch (InflateException e) {
Log.w(TAG, "load keyboard failed: " + e);
tryGC = Utils.GCUtils.getInstance().tryGCOrWait(
- oldThemeIndex + "," + newThemeIndex, e);
+ Keyboard.toThemeName(mThemeIndex), e);
}
}
@@ -385,27 +375,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
return mCurrentInputView;
}
- private void postSetInputView(final View newInputView) {
- final LatinIME latinIme = mInputMethodService;
- latinIme.mHandler.post(new Runnable() {
- @Override
- public void run() {
- if (newInputView != null) {
- latinIme.setInputView(newInputView);
- }
- latinIme.updateInputViewShown();
- }
- });
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- if (PREF_KEYBOARD_LAYOUT.equals(key)) {
- final int themeIndex = getKeyboardThemeIndex(mInputMethodService, sharedPreferences);
- postSetInputView(createInputView(themeIndex, false));
- }
- }
-
public void onNetworkStateChanged() {
if (mKeyboardView != null) {
mKeyboardView.updateShortcutKey(SubtypeSwitcher.getInstance().isShortcutImeReady());
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
index f96f71e8a..721ea135f 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -44,10 +44,11 @@ public class ProximityInfo {
// TODO: Find a proper name for mKeyboardMinWidth
private final int mKeyboardMinWidth;
private final int mKeyboardHeight;
+ private final int mMostCommonKeyWidth;
private final Key[][] mGridNeighbors;
- ProximityInfo(int gridWidth, int gridHeight, int minWidth, int height, int keyWidth,
- int keyHeight, Set<Key> keys, TouchPositionCorrection touchPositionCorrection,
+ ProximityInfo(int gridWidth, int gridHeight, int minWidth, int height, int mostCommonKeyWidth,
+ int mostCommonKeyHeight, Set<Key> keys, TouchPositionCorrection touchPositionCorrection,
Map<Integer, List<Integer>> additionalProximityChars) {
mGridWidth = gridWidth;
mGridHeight = gridHeight;
@@ -56,13 +57,15 @@ public class ProximityInfo {
mCellHeight = (height + mGridHeight - 1) / mGridHeight;
mKeyboardMinWidth = minWidth;
mKeyboardHeight = height;
- mKeyHeight = keyHeight;
+ mKeyHeight = mostCommonKeyHeight;
+ mMostCommonKeyWidth = mostCommonKeyWidth;
mGridNeighbors = new Key[mGridSize][];
if (minWidth == 0 || height == 0) {
// No proximity required. Keyboard might be more keys keyboard.
return;
}
- computeNearestNeighbors(keyWidth, keys, touchPositionCorrection, additionalProximityChars);
+ computeNearestNeighbors(
+ mostCommonKeyWidth, keys, touchPositionCorrection, additionalProximityChars);
}
public static ProximityInfo createDummyProximityInfo() {
@@ -74,8 +77,8 @@ public class ProximityInfo {
final ProximityInfo spellCheckerProximityInfo = createDummyProximityInfo();
spellCheckerProximityInfo.mNativeProximityInfo =
spellCheckerProximityInfo.setProximityInfoNative(
- SpellCheckerProximityInfo.ROW_SIZE, 480, 300, 11, 3, proximity, 0,
- null, null, null, null, null, null, null, null);
+ SpellCheckerProximityInfo.ROW_SIZE, 480, 300, 11, 3, (480 / 10), proximity,
+ 0, null, null, null, null, null, null, null, null);
return spellCheckerProximityInfo;
}
@@ -85,7 +88,8 @@ public class ProximityInfo {
}
private native long setProximityInfoNative(int maxProximityCharsSize, int displayWidth,
- int displayHeight, int gridWidth, int gridHeight, int[] proximityCharsArray,
+ int displayHeight, int gridWidth, int gridHeight,
+ int mostCommonKeyWidth, int[] proximityCharsArray,
int keyCount, int[] keyXCoordinates, int[] keyYCoordinates,
int[] keyWidths, int[] keyHeights, int[] keyCharCodes,
float[] sweetSpotCenterX, float[] sweetSpotCenterY, float[] sweetSpotRadii);
@@ -151,7 +155,8 @@ public class ProximityInfo {
}
mNativeProximityInfo = setProximityInfoNative(MAX_PROXIMITY_CHARS_SIZE,
- keyboardWidth, keyboardHeight, mGridWidth, mGridHeight, proximityCharsArray,
+ keyboardWidth, keyboardHeight, mGridWidth, mGridHeight, mMostCommonKeyWidth,
+ proximityCharsArray,
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
sweetSpotCenterXs, sweetSpotCenterYs, sweetSpotRadii);
}
diff --git a/java/src/com/android/inputmethod/latin/DebugSettings.java b/java/src/com/android/inputmethod/latin/DebugSettings.java
index 3805da154..870b33f9a 100644
--- a/java/src/com/android/inputmethod/latin/DebugSettings.java
+++ b/java/src/com/android/inputmethod/latin/DebugSettings.java
@@ -25,6 +25,8 @@ import android.preference.CheckBoxPreference;
import android.preference.PreferenceActivity;
import android.util.Log;
+import com.android.inputmethod.keyboard.KeyboardSwitcher;
+
public class DebugSettings extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener {
@@ -61,7 +63,8 @@ public class DebugSettings extends PreferenceActivity
updateDebugMode();
mServiceNeedsRestart = true;
}
- } else if (key.equals(FORCE_NON_DISTINCT_MULTITOUCH_KEY)) {
+ } else if (key.equals(FORCE_NON_DISTINCT_MULTITOUCH_KEY)
+ || key.equals(KeyboardSwitcher.PREF_KEYBOARD_LAYOUT)) {
mServiceNeedsRestart = true;
}
}