am 2e7f74f0: am 615509cf: am 9d763910: Merge "Unfortunately, hide some broken "emoji"s"

* commit '2e7f74f00cd6e9ba7e7be9ee1ba07ec0066ffe15':
  Unfortunately, hide some broken "emoji"s
main
Satoshi Kataoka 2013-10-09 19:32:07 -07:00 committed by Android Git Automerger
commit 9d527c0225
3 changed files with 56 additions and 26 deletions

View File

@ -204,18 +204,18 @@
name="emoji_symbols"
format="string"
>
<item>fe82e|0031,20e3</item>
<item>fe82f|0032,20e3</item>
<item>fe830|0033,20e3</item>
<item>fe831|0034,20e3</item>
<item>fe832|0035,20e3</item>
<item>fe833|0036,20e3</item>
<item>fe834|0037,20e3</item>
<item>fe835|0038,20e3</item>
<item>fe836|0039,20e3</item>
<item>fe837|0030,20e3</item>
<item>fe82e|0031,20e3|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe82f|0032,20e3|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe830|0033,20e3|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe831|0034,20e3|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe832|0035,20e3|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe833|0036,20e3|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe834|0037,20e3|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe835|0038,20e3|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe836|0039,20e3|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe837|0030,20e3|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>1f51f</item>
<item>fe82c|0023,20e3</item>
<item>fe82c|0023,20e3|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>1f51d</item>
<item>1f519</item>
<item>1f51b</item>
@ -875,16 +875,16 @@
<item>1f48e</item>
<item>1f490</item>
<item>1f492</item>
<item>fe4e5|1f1ef,1f1f5</item>
<item>fe4e6|1f1fa,1f1f8</item>
<item>fe4e7|1f1eb,1f1f7</item>
<item>fe4e8|1f1e9,1f1ea</item>
<item>fe4e9|1f1ee,1f1f9</item>
<item>fe4ea|1f1ec,1f1e7</item>
<item>fe4eb|1f1ea,1f1f8</item>
<item>fe4ec|1f1f7,1f1fa</item>
<item>fe4ed|1f1e8,1f1f3</item>
<item>fe4ee|1f1f0,1f1f7</item>
<item>fe4e5|1f1ef,1f1f5|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe4e6|1f1fa,1f1f8|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe4e7|1f1eb,1f1f7|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe4e8|1f1e9,1f1ea|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe4e9|1f1ee,1f1f9|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe4ea|1f1ec,1f1e7|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe4eb|1f1ea,1f1f8|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe4ec|1f1f7,1f1fa|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe4ed|1f1e8,1f1f3|99</item> <!-- TODO: fix support min sdk version (99) -->
<item>fe4ee|1f1f0,1f1f7|99</item> <!-- TODO: fix support min sdk version (99) -->
</array>
<array
name="emoji_emoticons"

View File

@ -18,6 +18,8 @@ package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.latin.Constants;
import android.text.TextUtils;
/**
* The string parser of codesArray specification for <GridRows />. The attribute codesArray is an
* array of string.
@ -34,7 +36,7 @@ import com.android.inputmethod.latin.Constants;
public final class CodesArrayParser {
// Constants for parsing.
private static final char COMMA = ',';
private static final char VERTICAL_BAR = '|';
private static final String VERTICAL_BAR_STRING = "\\|";
private static final String COMMA_STRING = ",";
private static final int BASE_HEX = 16;
@ -43,8 +45,11 @@ public final class CodesArrayParser {
}
private static String getLabelSpec(final String codesArraySpec) {
final int pos = codesArraySpec.indexOf(VERTICAL_BAR);
return (pos < 0) ? codesArraySpec : codesArraySpec.substring(0, pos);
final String[] strs = codesArraySpec.split(VERTICAL_BAR_STRING, -1);
if (strs.length <= 1) {
return codesArraySpec;
}
return strs[0];
}
public static String parseLabel(final String codesArraySpec) {
@ -58,8 +63,25 @@ public final class CodesArrayParser {
}
private static String getCodeSpec(final String codesArraySpec) {
final int pos = codesArraySpec.indexOf(VERTICAL_BAR);
return (pos < 0) ? codesArraySpec : codesArraySpec.substring(pos + 1);
final String[] strs = codesArraySpec.split(VERTICAL_BAR_STRING, -1);
if (strs.length <= 1) {
return codesArraySpec;
}
return TextUtils.isEmpty(strs[1]) ? strs[0] : strs[1];
}
// codesArraySpec consists of:
// <label>|<code0>,<code1>,...|<minSupportSdkVersion>
public static int getMinSupportSdkVersion(final String codesArraySpec) {
final String[] strs = codesArraySpec.split(VERTICAL_BAR_STRING, -1);
if (strs.length <= 2) {
return 0;
}
try {
return Integer.parseInt(strs[2]);
} catch (NumberFormatException e) {
return 0;
}
}
public static int parseCode(final String codesArraySpec) {

View File

@ -20,6 +20,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
@ -436,17 +437,24 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
final String label;
final int code;
final String outputText;
final int supportedMinSdkVersion;
if (codesArrayId != 0) {
final String codeArraySpec = array[i];
label = CodesArrayParser.parseLabel(codeArraySpec);
code = CodesArrayParser.parseCode(codeArraySpec);
outputText = CodesArrayParser.parseOutputText(codeArraySpec);
supportedMinSdkVersion =
CodesArrayParser.getMinSupportSdkVersion(codeArraySpec);
} else {
final String textArraySpec = array[i];
// TODO: Utilize KeySpecParser or write more generic TextsArrayParser.
label = textArraySpec;
code = Constants.CODE_OUTPUT_TEXT;
outputText = textArraySpec + (char)Constants.CODE_SPACE;
supportedMinSdkVersion = 0;
}
if (Build.VERSION.SDK_INT < supportedMinSdkVersion) {
continue;
}
final int x = (int)row.getKeyX(null);
final int y = row.getKeyY();