Merge "Move INCLUDE_RAW_SUGGESTIONS flag to ProductionFlag"
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index a9474a0..4139878 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -240,6 +240,7 @@
     </declare-styleable>
 
     <declare-styleable name="Keyboard_Key">
+        <!-- TODO: Remove code attribute and consolidate with keySpec. -->
         <!-- The unicode value that this key outputs.
              Code value represented in hexadecimal prefixed with "0x" or code value reference using
              "!code/<code_name>" notation. -->
@@ -275,8 +276,10 @@
             <flag name="altCodeWhileTyping" value="0x04" />
             <flag name="enableLongPress" value="0x08" />
         </attr>
+        <!-- TODO: Remove keyOutputText attribute and consolidate with keySpec. -->
         <!-- The string of characters to output when this key is pressed. -->
         <attr name="keyOutputText" format="string" />
+        <!-- TODO: Rename keyLabel to keySpec. -->
         <!-- The label to display on the key. -->
         <attr name="keyLabel" format="string" />
         <!-- The hint label to display on the key in conjunction with the label. -->
@@ -318,6 +321,7 @@
             <!-- If true, disable additionalMoreKeys. -->
             <flag name="disableAdditionalMoreKeys" value="0x80000000" />
         </attr>
+        <!-- TODO: Remove keyIcon attribute and consolidate with keySpec. -->
         <!-- The icon to display on the key instead of the label. -->
         <attr name="keyIcon" format="string" />
         <!-- The icon for disabled key -->
diff --git a/java/res/xml-sw600dp/key_styles_common.xml b/java/res/xml-sw600dp/key_styles_common.xml
index d817add..245b433 100644
--- a/java/res/xml-sw600dp/key_styles_common.xml
+++ b/java/res/xml-sw600dp/key_styles_common.xml
@@ -101,12 +101,6 @@
         latin:keyLabelFlags="hasPopupHint"
         latin:keyActionFlags="noKeyPreview" />
     <key-style
-        latin:styleName="smileyKeyStyle"
-        latin:keyLabel=":-)"
-        latin:keyOutputText=":-) "
-        latin:keyLabelFlags="hasPopupHint|preserveCase"
-        latin:moreKeys="!text/more_keys_for_smiley" />
-    <key-style
         latin:styleName="shortcutKeyStyle"
         latin:code="!code/key_shortcut"
         latin:keyIcon="!icon/shortcut_key"
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index f7eec6b..9715557 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -267,12 +267,6 @@
                 R.styleable.Keyboard_Key_visualInsetsLeft, baseWidth, baseWidth, 0));
         final int visualInsetsRight = Math.round(keyAttr.getFraction(
                 R.styleable.Keyboard_Key_visualInsetsRight, baseWidth, baseWidth, 0));
-        mIconId = KeySpecParser.getIconId(style.getString(keyAttr,
-                R.styleable.Keyboard_Key_keyIcon));
-        final int disabledIconId = KeySpecParser.getIconId(style.getString(keyAttr,
-                R.styleable.Keyboard_Key_keyIconDisabled));
-        final int previewIconId = KeySpecParser.getIconId(style.getString(keyAttr,
-                R.styleable.Keyboard_Key_keyIconPreview));
 
         mLabelFlags = style.getFlags(keyAttr, R.styleable.Keyboard_Key_keyLabelFlags)
                 | row.getDefaultKeyLabelFlags();
@@ -321,8 +315,21 @@
         }
         mActionFlags = actionFlags;
 
-        final int code = KeySpecParser.parseCode(style.getString(keyAttr,
+        final String keySpec = style.getString(keyAttr, R.styleable.Keyboard_Key_keyLabel);
+
+        final int iconIdInAttr = KeySpecParser.getIconId(style.getString(keyAttr,
+                R.styleable.Keyboard_Key_keyIcon));
+        mIconId = (iconIdInAttr != ICON_UNDEFINED) ? iconIdInAttr
+                : KeySpecParser.getIconId(keySpec);
+        final int disabledIconId = KeySpecParser.getIconId(style.getString(keyAttr,
+                R.styleable.Keyboard_Key_keyIconDisabled));
+        final int previewIconId = KeySpecParser.getIconId(style.getString(keyAttr,
+                R.styleable.Keyboard_Key_keyIconPreview));
+
+        final int codeInAttr = KeySpecParser.parseCode(style.getString(keyAttr,
                 R.styleable.Keyboard_Key_code), params.mCodesSet, CODE_UNSPECIFIED);
+        final int code = (codeInAttr != CODE_UNSPECIFIED) ? codeInAttr
+                : KeySpecParser.getCode(keySpec, params.mCodesSet);
         if ((mLabelFlags & LABEL_FLAGS_FROM_CUSTOM_ACTION_LABEL) != 0) {
             mLabel = params.mId.mCustomActionLabel;
         } else if (code >= Character.MIN_SUPPLEMENTARY_CODE_POINT) {
@@ -331,8 +338,8 @@
             // code point nor as a surrogate pair.
             mLabel = new StringBuilder().appendCodePoint(code).toString();
         } else {
-            mLabel = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr,
-                    R.styleable.Keyboard_Key_keyLabel), needsToUpperCase, locale);
+            mLabel = StringUtils.toUpperCaseOfStringForLocale(
+                    KeySpecParser.getLabel(keySpec), needsToUpperCase, locale);
         }
         if ((mLabelFlags & LABEL_FLAGS_DISABLE_HINT_LABEL) != 0) {
             mHintLabel = null;
@@ -340,8 +347,12 @@
             mHintLabel = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr,
                     R.styleable.Keyboard_Key_keyHintLabel), needsToUpperCase, locale);
         }
-        String outputText = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr,
-                R.styleable.Keyboard_Key_keyOutputText), needsToUpperCase, locale);
+        final String outputTextInAttr = style.getString(
+                keyAttr, R.styleable.Keyboard_Key_keyOutputText);
+        final String rawOutputText = (outputTextInAttr != null) ? outputTextInAttr
+                : KeySpecParser.getOutputText(keySpec);
+        String outputText = StringUtils.toUpperCaseOfStringForLocale(
+                rawOutputText, needsToUpperCase, locale);
         // Choose the first letter of the label as primary code if not specified.
         if (code == CODE_UNSPECIFIED && TextUtils.isEmpty(outputText)
                 && !TextUtils.isEmpty(mLabel)) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
index f8c0988..f9f183e 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
@@ -309,23 +309,22 @@
         /* 137 */ "label_time_pm",
         /* 138 */ "keylabel_for_popular_domain",
         /* 139 */ "more_keys_for_popular_domain",
-        /* 140 */ "more_keys_for_smiley",
-        /* 141 */ "single_laqm_raqm",
-        /* 142 */ "single_laqm_raqm_rtl",
-        /* 143 */ "single_raqm_laqm",
-        /* 144 */ "double_laqm_raqm",
-        /* 145 */ "double_laqm_raqm_rtl",
-        /* 146 */ "double_raqm_laqm",
-        /* 147 */ "single_lqm_rqm",
-        /* 148 */ "single_9qm_lqm",
-        /* 149 */ "single_9qm_rqm",
-        /* 150 */ "double_lqm_rqm",
-        /* 151 */ "double_9qm_lqm",
-        /* 152 */ "double_9qm_rqm",
-        /* 153 */ "more_keys_for_single_quote",
-        /* 154 */ "more_keys_for_double_quote",
-        /* 155 */ "more_keys_for_tablet_double_quote",
-        /* 156 */ "emoji_key_as_more_key",
+        /* 140 */ "single_laqm_raqm",
+        /* 141 */ "single_laqm_raqm_rtl",
+        /* 142 */ "single_raqm_laqm",
+        /* 143 */ "double_laqm_raqm",
+        /* 144 */ "double_laqm_raqm_rtl",
+        /* 145 */ "double_raqm_laqm",
+        /* 146 */ "single_lqm_rqm",
+        /* 147 */ "single_9qm_lqm",
+        /* 148 */ "single_9qm_rqm",
+        /* 149 */ "double_lqm_rqm",
+        /* 150 */ "double_9qm_lqm",
+        /* 151 */ "double_9qm_rqm",
+        /* 152 */ "more_keys_for_single_quote",
+        /* 153 */ "more_keys_for_double_quote",
+        /* 154 */ "more_keys_for_tablet_double_quote",
+        /* 155 */ "emoji_key_as_more_key",
     };
 
     private static final String EMPTY = "";
@@ -477,7 +476,6 @@
         /* 138 */ ".com",
         // popular web domains for the locale - most popular, displayed on the keyboard
         /* 139 */ "!hasLabels!,.net,.org,.gov,.edu",
-        /* 140 */ "!fixedColumnOrder!5,!hasLabels!,=-O|=-O ,:-P|:-P ,;-)|;-) ,:-(|:-( ,:-)|:-) ,:-!|:-! ,:-$|:-$ ,B-)|B-) ,:O|:O ,:-*|:-* ,:-D|:-D ,:\'(|:\'( ,:-\\\\|:-\\\\ ,O:-)|O:-) ,:-[|:-[ ",
         // U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK
         // U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
         // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
@@ -499,25 +497,25 @@
         // The following each quotation mark pair consist of
         // <opening quotation mark>, <closing quotation mark>
         // and is named after (single|double)_<opening quotation mark>_<closing quotation mark>.
-        /* 141 */ "\u2039,\u203A",
-        /* 142 */ "\u2039|\u203A,\u203A|\u2039",
-        /* 143 */ "\u203A,\u2039",
-        /* 144 */ "\u00AB,\u00BB",
-        /* 145 */ "\u00AB|\u00BB,\u00BB|\u00AB",
-        /* 146 */ "\u00BB,\u00AB",
+        /* 140 */ "\u2039,\u203A",
+        /* 141 */ "\u2039|\u203A,\u203A|\u2039",
+        /* 142 */ "\u203A,\u2039",
+        /* 143 */ "\u00AB,\u00BB",
+        /* 144 */ "\u00AB|\u00BB,\u00BB|\u00AB",
+        /* 145 */ "\u00BB,\u00AB",
         // The following each quotation mark triplet consists of
         // <another quotation mark>, <opening quotation mark>, <closing quotation mark>
         // and is named after (single|double)_<opening quotation mark>_<closing quotation mark>.
-        /* 147 */ "\u201A,\u2018,\u2019",
-        /* 148 */ "\u2019,\u201A,\u2018",
-        /* 149 */ "\u2018,\u201A,\u2019",
-        /* 150 */ "\u201E,\u201C,\u201D",
-        /* 151 */ "\u201D,\u201E,\u201C",
-        /* 152 */ "\u201C,\u201E,\u201D",
-        /* 153 */ "!fixedColumnOrder!5,!text/single_quotes,!text/single_angle_quotes",
-        /* 154 */ "!fixedColumnOrder!5,!text/double_quotes,!text/double_angle_quotes",
-        /* 155 */ "!fixedColumnOrder!6,!text/double_quotes,!text/single_quotes,!text/double_angle_quotes,!text/single_angle_quotes",
-        /* 156 */ "!icon/emoji_key|!code/key_emoji",
+        /* 146 */ "\u201A,\u2018,\u2019",
+        /* 147 */ "\u2019,\u201A,\u2018",
+        /* 148 */ "\u2018,\u201A,\u2019",
+        /* 149 */ "\u201E,\u201C,\u201D",
+        /* 150 */ "\u201D,\u201E,\u201C",
+        /* 151 */ "\u201C,\u201E,\u201D",
+        /* 152 */ "!fixedColumnOrder!5,!text/single_quotes,!text/single_angle_quotes",
+        /* 153 */ "!fixedColumnOrder!5,!text/double_quotes,!text/double_angle_quotes",
+        /* 154 */ "!fixedColumnOrder!6,!text/double_quotes,!text/single_quotes,!text/double_angle_quotes,!text/single_angle_quotes",
+        /* 155 */ "!icon/emoji_key|!code/key_emoji",
     };
 
     /* Language af: Afrikaans */
diff --git a/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml
index ceb46dc..2b7ef7c 100644
--- a/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml
+++ b/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml
@@ -215,7 +215,6 @@
     <string name="keylabel_for_popular_domain">".com"</string>
     <!-- popular web domains for the locale - most popular, displayed on the keyboard -->
     <string name="more_keys_for_popular_domain">"!hasLabels!,.net,.org,.gov,.edu"</string>
-    <string name="more_keys_for_smiley">"!fixedColumnOrder!5,!hasLabels!,=-O|=-O ,:-P|:-P ,;-)|;-) ,:-(|:-( ,:-)|:-) ,:-!|:-! ,:-$|:-$ ,B-)|B-) ,:O|:O ,:-*|:-* ,:-D|:-D ,:\'(|:\'( ,:-\\\\|:-\\\\ ,O:-)|O:-) ,:-[|:-[ "</string>
     <!-- U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK
          U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
          U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK