aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-05-12 09:33:27 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-12 09:33:27 +0000
commitfac678e13df2c6073bdd7f9dc2fca1d4e16f8309 (patch)
treed66559a94ae8165f043082c1f598a25b3e238b1b /java/src/com/android/inputmethod/latin
parent4fb490ff90423b17181e5402d7f2056d508f3f0a (diff)
parentbe99616afa2243fe48dc406d0a3f442cb05453b4 (diff)
downloadlatinime-fac678e13df2c6073bdd7f9dc2fca1d4e16f8309.tar.gz
latinime-fac678e13df2c6073bdd7f9dc2fca1d4e16f8309.tar.xz
latinime-fac678e13df2c6073bdd7f9dc2fca1d4e16f8309.zip
Merge "Create the path for specifying combining rules in the subtype"
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r--java/src/com/android/inputmethod/latin/Constants.java5
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java6
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java4
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java16
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java18
-rw-r--r--java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java4
6 files changed, 51 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java
index e71723a15..5bc9b6281 100644
--- a/java/src/com/android/inputmethod/latin/Constants.java
+++ b/java/src/com/android/inputmethod/latin/Constants.java
@@ -115,6 +115,11 @@ public final class Constants {
*/
public static final String IS_ADDITIONAL_SUBTYPE = "isAdditionalSubtype";
+ /**
+ * The subtype extra value used to specify the combining rules.
+ */
+ public static final String COMBINING_RULES = "CombiningRules";
+
private ExtraValue() {
// This utility class is not publicly instantiable.
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index d64a1a6f7..7dc566a14 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -733,6 +733,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged()
// is not guaranteed. It may even be called at the same time on a different thread.
mSubtypeSwitcher.onSubtypeChanged(subtype);
+ mInputLogic.onSubtypeChanged(SubtypeLocaleUtils.getCombiningRulesExtraValue(subtype));
loadKeyboard();
}
@@ -808,7 +809,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// The app calling setText() has the effect of clearing the composing
// span, so we should reset our state unconditionally, even if restarting is true.
- mInputLogic.startInput(restarting, editorInfo);
+ // We also tell the input logic about the combining rules for the current subtype, so
+ // it can adjust its combiners if needed.
+ mInputLogic.startInput(restarting, editorInfo,
+ mSubtypeSwitcher.getCombiningRulesExtraValueOfCurrentSubtype());
// Note: the following does a round-trip IPC on the main thread: be careful
final Locale currentLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index 998a8b490..c8a2fb2f9 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -326,4 +326,8 @@ public final class SubtypeSwitcher {
+ DUMMY_EMOJI_SUBTYPE);
return DUMMY_EMOJI_SUBTYPE;
}
+
+ public String getCombiningRulesExtraValueOfCurrentSubtype() {
+ return SubtypeLocaleUtils.getCombiningRulesExtraValue(getCurrentSubtype());
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index d755195f2..cdee496a8 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -41,6 +41,7 @@ public final class WordComposer {
public static final int CAPS_MODE_AUTO_SHIFT_LOCKED = 0x7;
private CombinerChain mCombinerChain;
+ private String mCombiningSpec; // Memory so that we don't uselessly recreate the combiner chain
// The list of events that served to compose this string.
private final ArrayList<Event> mEvents;
@@ -91,6 +92,21 @@ public final class WordComposer {
}
/**
+ * Restart input with a new combining spec.
+ * @param combiningSpec The spec string for combining. This is found in the extra value.
+ */
+ public void restart(final String combiningSpec) {
+ final String nonNullCombiningSpec = null == combiningSpec ? "" : combiningSpec;
+ if (nonNullCombiningSpec.equals(mCombiningSpec)) {
+ mCombinerChain.reset();
+ } else {
+ mCombinerChain = new CombinerChain(CombinerChain.createCombiners(nonNullCombiningSpec));
+ mCombiningSpec = nonNullCombiningSpec;
+ }
+ reset();
+ }
+
+ /**
* Clear out the keys registered so far.
*/
public void reset() {
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 75432fbac..e80ee35bd 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -97,6 +97,11 @@ public final class InputLogic {
private boolean mIsAutoCorrectionIndicatorOn;
private long mDoubleSpacePeriodCountdownStart;
+ /**
+ * Create a new instance of the input logic.
+ * @param latinIME the instance of the parent LatinIME. We should remove this when we can.
+ * @param suggestionStripViewAccessor an object to access the suggestion strip view.
+ */
public InputLogic(final LatinIME latinIME,
final SuggestionStripViewAccessor suggestionStripViewAccessor) {
mLatinIME = latinIME;
@@ -117,9 +122,12 @@ public final class InputLogic {
*
* @param restarting whether input is starting in the same field as before. Unused for now.
* @param editorInfo the editorInfo associated with the editor.
+ * @param combiningSpec the combining spec string for this subtype
*/
- public void startInput(final boolean restarting, final EditorInfo editorInfo) {
+ public void startInput(final boolean restarting, final EditorInfo editorInfo,
+ final String combiningSpec) {
mEnteredText = null;
+ mWordComposer.restart(combiningSpec);
resetComposingState(true /* alsoResetLastComposedWord */);
mDeleteCount = 0;
mSpaceState = SpaceState.NONE;
@@ -138,6 +146,14 @@ public final class InputLogic {
}
/**
+ * Call this when the subtype changes.
+ * @param combiningSpec the spec string for the combining rules
+ */
+ public void onSubtypeChanged(final String combiningSpec) {
+ mWordComposer.restart(combiningSpec);
+ }
+
+ /**
* Clean up the input logic after input is finished.
*/
public void finishInput() {
diff --git a/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java b/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java
index b37779bdc..938d27122 100644
--- a/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java
@@ -324,4 +324,8 @@ public final class SubtypeLocaleUtils {
public static boolean isRtlLanguage(final InputMethodSubtype subtype) {
return isRtlLanguage(getSubtypeLocale(subtype));
}
+
+ public static String getCombiningRulesExtraValue(final InputMethodSubtype subtype) {
+ return subtype.getExtraValueOf(Constants.Subtype.ExtraValue.COMBINING_RULES);
+ }
}