aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/event
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/event
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/event')
-rw-r--r--java/src/com/android/inputmethod/event/CombinerChain.java36
-rw-r--r--java/src/com/android/inputmethod/event/MyanmarReordering.java38
2 files changed, 74 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/event/CombinerChain.java b/java/src/com/android/inputmethod/event/CombinerChain.java
index 8b59dc52a..990f7deea 100644
--- a/java/src/com/android/inputmethod/event/CombinerChain.java
+++ b/java/src/com/android/inputmethod/event/CombinerChain.java
@@ -23,6 +23,7 @@ import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList;
+import java.util.HashMap;
/**
* This class implements the logic chain between receiving events and generating code points.
@@ -43,6 +44,13 @@ public class CombinerChain {
private SpannableStringBuilder mStateFeedback;
private final ArrayList<Combiner> mCombiners;
+ private static final HashMap<String, Class> IMPLEMENTED_COMBINERS
+ = new HashMap<String, Class>();
+ static {
+ IMPLEMENTED_COMBINERS.put("MyanmarReordering", MyanmarReordering.class);
+ }
+ private static final String COMBINER_SPEC_SEPARATOR = ";";
+
/**
* Create an combiner chain.
*
@@ -56,6 +64,9 @@ public class CombinerChain {
mCombiners = CollectionUtils.newArrayList();
// The dead key combiner is always active, and always first
mCombiners.add(new DeadKeyCombiner());
+ for (final Combiner combiner : combinerList) {
+ mCombiners.add(combiner);
+ }
mCombinedText = new StringBuilder();
mStateFeedback = new SpannableStringBuilder();
}
@@ -114,4 +125,29 @@ public class CombinerChain {
final SpannableStringBuilder s = new SpannableStringBuilder(mCombinedText);
return s.append(mStateFeedback);
}
+
+ public static Combiner[] createCombiners(final String spec) {
+ if (TextUtils.isEmpty(spec)) {
+ return new Combiner[0];
+ }
+ final String[] combinerDescriptors = spec.split(COMBINER_SPEC_SEPARATOR);
+ final Combiner[] combiners = new Combiner[combinerDescriptors.length];
+ int i = 0;
+ for (final String combinerDescriptor : combinerDescriptors) {
+ final Class combinerClass = IMPLEMENTED_COMBINERS.get(combinerDescriptor);
+ if (null == combinerClass) {
+ throw new RuntimeException("Unknown combiner descriptor: " + combinerDescriptor);
+ }
+ try {
+ combiners[i++] = (Combiner)combinerClass.newInstance();
+ } catch (InstantiationException e) {
+ throw new RuntimeException("Unable to instantiate combiner: " + combinerDescriptor,
+ e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Unable to instantiate combiner: " + combinerDescriptor,
+ e);
+ }
+ }
+ return combiners;
+ }
}
diff --git a/java/src/com/android/inputmethod/event/MyanmarReordering.java b/java/src/com/android/inputmethod/event/MyanmarReordering.java
new file mode 100644
index 000000000..0831b63ec
--- /dev/null
+++ b/java/src/com/android/inputmethod/event/MyanmarReordering.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014 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.event;
+
+import java.util.ArrayList;
+
+/**
+ * A combiner that reorders input for Myanmar.
+ */
+public class MyanmarReordering implements Combiner {
+ @Override
+ public Event processEvent(ArrayList<Event> previousEvents, Event event) {
+ return event;
+ }
+
+ @Override
+ public CharSequence getCombiningStateFeedback() {
+ return "";
+ }
+
+ @Override
+ public void reset() {
+ }
+}