Merge "Create the path for specifying combining rules in the subtype"
diff --git a/java/res/xml-sw600dp/key_settings.xml b/java/res/xml-sw600dp/key_settings.xml
new file mode 100644
index 0000000..45915e9
--- /dev/null
+++ b/java/res/xml-sw600dp/key_settings.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 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.
+*/
+-->
+
+<merge
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <switch>
+        <case
+            latin:clobberSettingsKey="false"
+        >
+            <Key
+                latin:keyStyle="settingsKeyStyle" />
+        </case>
+        <!-- clobberSettingsKey="true" -->
+        <default>
+            <Spacer />
+        </default>
+    </switch>
+</merge>
diff --git a/java/res/xml-sw600dp/key_shortcut.xml b/java/res/xml-sw600dp/key_shortcut.xml
deleted file mode 100644
index d24e81f..0000000
--- a/java/res/xml-sw600dp/key_shortcut.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2012, 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.
-*/
--->
-
-<merge
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
-    <switch>
-        <case
-            latin:supportsSwitchingToShortcutIme="true"
-            latin:clobberSettingsKey="false"
-        >
-            <Key
-                latin:keyStyle="shortcutKeyStyle"
-                latin:keyLabelFlags="hasPopupHint|preserveCase"
-                latin:moreKeys="!text/keyspec_settings" />
-        </case>
-        <case
-            latin:supportsSwitchingToShortcutIme="true"
-            latin:clobberSettingsKey="true"
-        >
-            <Key
-                latin:keyStyle="shortcutKeyStyle" />
-        </case>
-        <case
-            latin:supportsSwitchingToShortcutIme="false"
-            latin:clobberSettingsKey="false"
-        >
-            <Key
-                latin:keyStyle="settingsKeyStyle" />
-        </case>
-        <!-- supportsSwitchingToShortcutIme="false" clobberSettingsKey="true" -->
-        <default>
-            <Spacer />
-        </default>
-    </switch>
-</merge>
diff --git a/java/res/xml-sw600dp/row_dvorak4.xml b/java/res/xml-sw600dp/row_dvorak4.xml
index 2ba6a49..d3709ef 100644
--- a/java/res/xml-sw600dp/row_dvorak4.xml
+++ b/java/res/xml-sw600dp/row_dvorak4.xml
@@ -29,7 +29,7 @@
             latin:keyStyle="toSymbolKeyStyle"
             latin:keyWidth="10.0%p" />
         <include
-            latin:keyboardLayout="@xml/key_shortcut" />
+            latin:keyboardLayout="@xml/key_settings" />
         <include
             latin:keyboardLayout="@xml/key_f1" />
         <include
diff --git a/java/res/xml-sw600dp/row_pcqwerty5.xml b/java/res/xml-sw600dp/row_pcqwerty5.xml
index 52b581a..ac07f11 100644
--- a/java/res/xml-sw600dp/row_pcqwerty5.xml
+++ b/java/res/xml-sw600dp/row_pcqwerty5.xml
@@ -26,7 +26,7 @@
     >
         <include
             latin:keyWidth="9.0%p"
-            latin:keyboardLayout="@xml/key_shortcut" />
+            latin:keyboardLayout="@xml/key_settings" />
         <switch>
             <case
                 latin:languageSwitchKeyEnabled="true"
diff --git a/java/res/xml-sw600dp/row_qwerty4.xml b/java/res/xml-sw600dp/row_qwerty4.xml
index 7969dd8..d931437 100644
--- a/java/res/xml-sw600dp/row_qwerty4.xml
+++ b/java/res/xml-sw600dp/row_qwerty4.xml
@@ -29,7 +29,7 @@
             latin:keyStyle="toSymbolKeyStyle"
             latin:keyWidth="10.0%p" />
         <include
-            latin:keyboardLayout="@xml/key_shortcut" />
+            latin:keyboardLayout="@xml/key_settings" />
         <include
             latin:keyboardLayout="@xml/key_f1" />
         <include
diff --git a/java/res/xml/key_f1.xml b/java/res/xml/key_f1.xml
index c96ddca..3471c85 100644
--- a/java/res/xml/key_f1.xml
+++ b/java/res/xml/key_f1.xml
@@ -36,27 +36,10 @@
                 latin:keySpec="\@"
                 latin:keyStyle="f1MoreKeysStyle" />
         </case>
-        <case
-            latin:supportsSwitchingToShortcutIme="false"
-        >
-            <Key
-                latin:keySpec="!text/keyspec_comma"
-                latin:keyLabelFlags="hasPopupHint"
-                latin:keyStyle="f1MoreKeysStyle" />
-        </case>
-        <!-- latin:supportsSwitchingToShortcutIme="true" -->
-        <case
-            latin:hasShortcutKey="true"
-        >
-            <Key
-                latin:keyStyle="shortcutKeyStyle" />
-        </case>
-        <!-- latin:hasShortcutKey="false" -->
         <default>
             <Key
                 latin:keySpec="!text/keyspec_comma"
                 latin:keyLabelFlags="hasPopupHint"
-                latin:additionalMoreKeys="!text/keyspec_shortcut"
                 latin:keyStyle="f1MoreKeysStyle" />
         </default>
     </switch>
diff --git a/java/res/xml/row_dvorak4.xml b/java/res/xml/row_dvorak4.xml
index 91462cb..279f646 100644
--- a/java/res/xml/row_dvorak4.xml
+++ b/java/res/xml/row_dvorak4.xml
@@ -30,7 +30,6 @@
         <Key
             latin:keySpec="q"
             latin:backgroundType="normal"
-            latin:additionalMoreKeys="!text/keyspec_shortcut"
             latin:keyStyle="f1MoreKeysStyle" />
         <include
             latin:keyXPos="25%p"
diff --git a/java/res/xml/row_pcqwerty5.xml b/java/res/xml/row_pcqwerty5.xml
index 3782763..32c5389 100644
--- a/java/res/xml/row_pcqwerty5.xml
+++ b/java/res/xml/row_pcqwerty5.xml
@@ -26,13 +26,6 @@
     >
         <switch>
             <case
-                latin:hasShortcutKey="true"
-            >
-                <Key
-                    latin:keyStyle="shortcutKeyStyle"
-                    latin:keyWidth="11.538%p" />
-            </case>
-            <case
                 latin:clobberSettingsKey="false"
             >
                 <Key
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Dvorak.java b/tests/src/com/android/inputmethod/keyboard/layout/Dvorak.java
index 99cf6e5..7ba1d78 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/Dvorak.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/Dvorak.java
@@ -51,7 +51,7 @@
 
         @Override
         public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
-            return isPhone ? joinKeys(key("q", SHORTCUT_KEY, SETTINGS_KEY)) : joinKeys(key("/"));
+            return isPhone ? joinKeys(key("q", SETTINGS_KEY)) : joinKeys(key("/"));
         }
 
         @Override
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Farsi.java b/tests/src/com/android/inputmethod/keyboard/layout/Farsi.java
index a007089..16d2f86 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/Farsi.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/Farsi.java
@@ -91,7 +91,7 @@
 
         @Override
         public ExpectedKey[] getSpaceKeys(final boolean isPhone) {
-            return joinKeys(SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY));
+            return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY));
         }
 
         @Override
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java b/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java
index afd26e4..cf20149 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java
@@ -16,29 +16,12 @@
 
 package com.android.inputmethod.keyboard.layout;
 
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_ANUSVARA;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_CANDRABINDU;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_NUKTA;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_VIRAMA;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_VISARGA;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_AA;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_AI;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_AU;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_CANDRA_E;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_CANDRA_O;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_E;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_I;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_II;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_O;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_U;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_UU;
-import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_VOCALIC_R;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.*;
 
 import com.android.inputmethod.keyboard.layout.Hindi.HindiCustomizer;
 import com.android.inputmethod.keyboard.layout.Hindi.HindiSymbols;
 import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
 import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
-import com.android.inputmethod.latin.Constants;
 
 import java.util.Locale;
 
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java
index 4123a22..e4e9554 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java
@@ -29,7 +29,6 @@
  * The base class of keyboard layout.
  */
 public abstract class LayoutBase extends AbstractLayoutBase {
-
     /**
      * This class is used to customize common keyboard layout to language specific layout.
      */
@@ -152,7 +151,7 @@
          *         keyboard.
          */
         public ExpectedKey[] getSpaceKeys(final boolean isPhone) {
-            return joinKeys(SPACE_KEY);
+            return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY);
         }
 
         /**
@@ -161,7 +160,8 @@
          * @return the array of {@link ExpectedKey} that should be placed at left of the spacebar.
          */
         public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
-            return isPhone ? joinKeys(key(",", SETTINGS_KEY)) : joinKeys("/");
+            // U+002C: "," COMMA
+            return isPhone ? joinKeys(key("\u002C", SETTINGS_KEY)) : joinKeys("/");
         }
 
         /**
@@ -306,6 +306,10 @@
 
     /**
      * Get common alphabet layout. This layout doesn't contain any special keys.
+     *
+     * A keyboard layout is an array of rows, and a row consists of an array of
+     * {@link ExpectedKey}s. Each row may have different number of {@link ExpectedKey}s.
+     *
      * @param isPhone true if requesting phone's layout.
      * @return the common alphabet keyboard layout.
      */
@@ -313,6 +317,10 @@
 
     /**
      * Get common alphabet shifted layout. This layout doesn't contain any special keys.
+     *
+     * A keyboard layout is an array of rows, and a row consists of an array of
+     * {@link ExpectedKey}s. Each row may have different number of {@link ExpectedKey}s.
+     *
      * @param isPhone true if requesting phone's layout.
      * @param elementId the element id of the requesting shifted mode.
      * @return the common alphabet shifted keyboard layout.
@@ -327,9 +335,13 @@
 
     /**
      * Get the complete expected keyboard layout.
+     *
+     * A keyboard layout is an array of rows, and a row consists of an array of
+     * {@link ExpectedKey}s. Each row may have different number of {@link ExpectedKey}s.
+     *
      * @param isPhone true if requesting phone's layout.
      * @param elementId the element id of the requesting keyboard mode.
-     * @return
+     * @return the keyboard layout of the <code>elementId</code>.
      */
     public ExpectedKey[][] getLayout(final boolean isPhone, final int elementId) {
         if (elementId == KeyboardId.ELEMENT_SYMBOLS) {
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java b/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java
index 7048dbb..7933d07 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java
@@ -47,7 +47,7 @@
 
         @Override
         public ExpectedKey[] getSpaceKeys(final boolean isPhone) {
-            return joinKeys(SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY));
+            return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY));
         }
 
         // U+0930/U+0941/U+002E "रु." NEPALESE RUPEE SIGN
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java
index 3365b92..6e72104 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java
@@ -21,9 +21,9 @@
 /**
  * This class builds a keyboard that is a two dimensional array of elements <code>E</code>.
  *
- * A keyboard consists of array of rows, and a row consists of array of elements. Each row may have
- * different number of elements. A element of a keyboard can be specified by a row number and a
- * column number, both numbers starts from 1.
+ * A keyboard consists of an array of rows, and a row consists of an array of elements. Each row
+ * may have different number of elements. A element of a keyboard can be specified by a row number
+ * and a column number, both numbers starts from 1.
  *
  * @param <E> the type of a keyboard element. A keyboard element must be an immutable object.
  */
@@ -39,8 +39,7 @@
     abstract E[][] newArrayOfArray(final int size);
 
     /**
-     * Construct a builder filled with the default element.
-     * @param dimensions the integer array of each row's size.
+     * Construct an empty builder.
      */
     AbstractKeyboardBuilder() {
         mRows = newArrayOfArray(0);
@@ -80,7 +79,7 @@
      * Get the current contents of the specified row.
      * @param row the row number to get the contents.
      * @return the array of elements at row number <code>row</code>.
-     * @throws {@link RuntimeException} if <code>row</code> is illegal.
+     * @throws RuntimeException if <code>row</code> is illegal.
      */
     E[] getRowAt(final int row) {
         final int rowIndex = row - 1;
@@ -94,7 +93,7 @@
      * Set an array of elements to the specified row.
      * @param row the row number to set <code>elements</code>.
      * @param elements the array of elements to set at row number <code>row</code>.
-     * @throws {@link RuntimeException} if <code>row</code> is illegal.
+     * @throws RuntimeException if <code>row</code> is illegal.
      */
     void setRowAt(final int row, final E[] elements) {
         final int rowIndex = row - 1;
@@ -114,7 +113,7 @@
      * @param element the element to set or insert at <code>row,column</code>.
      * @param insert if true, the <code>element</code> is inserted at <code>row,column</code>.
      *        Otherwise the <code>element</code> replace the element at <code>row,column</code>.
-     * @throws {@link RuntimeException} if <code>row</code> or <code>column</code> is illegal.
+     * @throws RuntimeException if <code>row</code> or <code>column</code> is illegal.
      */
     void setElementAt(final int row, final int column, final E element, final boolean insert) {
         final E[] elements = getRowAt(row);
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java
index 25be2a6..9e0039d 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java
@@ -19,7 +19,6 @@
 import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
 import com.android.inputmethod.keyboard.layout.expected.ExpectedKey.ExpectedAdditionalMoreKey;
 import com.android.inputmethod.latin.Constants;
-import com.android.inputmethod.latin.utils.StringUtils;
 
 /**
  * Base class to create an expected keyboard for unit test.
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java
index 26d2e2a..d0fea58 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java
@@ -28,6 +28,9 @@
 
 /**
  * This class builds an actual keyboard for unit test.
+ *
+ * An actual keyboard is an array of rows, and a row consists of an array of {@link Key}s.
+ * Each row may have different number of {@link Key}s.
  */
 public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> {
     private static ArrayList<Key> filterOutSpacer(final List<Key> keys) {
@@ -43,7 +46,8 @@
 
     /**
      * Create the keyboard that consists of the array of rows of the actual keyboard's keys.
-     * @param sortedKeys the sorted list of keys of the actual keyboard.
+     * @param sortedKeys keys list of the actual keyboard that is sorted from top-left to
+     * bottom-right.
      * @return the actual keyboard grouped with rows.
      */
     public static Key[][] buildKeyboard(final List<Key> sortedKeys) {
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java
index f068ad1..e06d34d 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java
@@ -24,6 +24,11 @@
 
 /**
  * This class builds an expected keyboard for unit test.
+ *
+ * An expected keyboard is an array of rows, and a row consists of an array of {@link ExpectedKey}s.
+ * Each row may have different number of {@link ExpectedKey}s. While building an expected keyboard,
+ * an {@link ExpectedKey} can be specified by a row number and a column number, both numbers starts
+ * from 1.
  */
 public final class ExpectedKeyboardBuilder extends AbstractKeyboardBuilder<ExpectedKey> {
     public ExpectedKeyboardBuilder() {
@@ -212,7 +217,7 @@
      * @param keys the array of keys to insert at <code>row,column</code>. Each key can be
      *        {@link ExpectedKey}, {@link ExpectedKey} array, and {@link String}.
      * @return this builder.
-     * @throws {@link RuntimeException} if <code>row</code> or <code>column</code> is illegal.
+     * @throws RuntimeException if <code>row</code> or <code>column</code> is illegal.
      */
     public ExpectedKeyboardBuilder insertKeysAtRow(final int row, final int column,
             final Object ... keys) {
@@ -229,7 +234,7 @@
      * @param keys the array of keys to add on the left most of the row. Each key can be
      *        {@link ExpectedKey}, {@link ExpectedKey} array, and {@link String}.
      * @return this builder.
-     * @throws {@link RuntimeException} if <code>row</code> is illegal.
+     * @throws RuntimeException if <code>row</code> is illegal.
      */
     public ExpectedKeyboardBuilder addKeysOnTheLeftOfRow(final int row,
             final Object ... keys) {
@@ -247,7 +252,7 @@
      * @param keys the array of keys to add on the right most of the row. Each key can be
      *        {@link ExpectedKey}, {@link ExpectedKey} array, and {@link String}.
      * @return this builder.
-     * @throws {@link RuntimeException} if <code>row</code> is illegal.
+     * @throws RuntimeException if <code>row</code> is illegal.
      */
     public ExpectedKeyboardBuilder addKeysOnTheRightOfRow(final int row,
             final Object ... keys) {
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java
index 4002c49..d4e8fb6 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java
@@ -51,7 +51,10 @@
         mSubtype = getSubtype(mLayout.getLocale(), mLayout.getName());
         mLogTag = SubtypeLocaleUtils.getSubtypeNameForLogging(mSubtype) + "/"
                 + (isPhone() ? "phone" : "tablet");
-        mKeyboardLayoutSet = createKeyboardLayoutSet(mSubtype, null /* editorInfo */);
+        // TODO: Test with language switch key enabled and disabled.
+        mKeyboardLayoutSet = createKeyboardLayoutSet(mSubtype, null /* editorInfo */,
+                true /* isShortcutImeEnabled */, true /* showsVoiceInputKey */,
+                true /* isLanguageSwitchKeyEnabled */);
     }
 
     // Those helper methods have a lower case name to be readable when defining expected keyboard