Return null if "!text/" reference is an empty text
Change-Id: I01826f3e09527348fb4cba3302a9394ff34f424amain
parent
a72e8f1ede
commit
5bf55a86d0
|
@ -78,10 +78,10 @@ public final class KeySpecParser {
|
||||||
* or has no key specifications.
|
* or has no key specifications.
|
||||||
*/
|
*/
|
||||||
public static String[] splitKeySpecs(final String text) {
|
public static String[] splitKeySpecs(final String text) {
|
||||||
final int size = text.length();
|
if (TextUtils.isEmpty(text)) {
|
||||||
if (size == 0) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
final int size = text.length();
|
||||||
// Optimization for one-letter key specification.
|
// Optimization for one-letter key specification.
|
||||||
if (size == 1) {
|
if (size == 1) {
|
||||||
return text.charAt(0) == COMMA ? null : new String[] { text };
|
return text.charAt(0) == COMMA ? null : new String[] { text };
|
||||||
|
@ -380,6 +380,9 @@ public final class KeySpecParser {
|
||||||
|
|
||||||
public static String resolveTextReference(final String rawText,
|
public static String resolveTextReference(final String rawText,
|
||||||
final KeyboardTextsSet textsSet) {
|
final KeyboardTextsSet textsSet) {
|
||||||
|
if (TextUtils.isEmpty(rawText)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
int level = 0;
|
int level = 0;
|
||||||
String text = rawText;
|
String text = rawText;
|
||||||
StringBuilder sb;
|
StringBuilder sb;
|
||||||
|
@ -392,7 +395,7 @@ public final class KeySpecParser {
|
||||||
final int prefixLen = PREFIX_TEXT.length();
|
final int prefixLen = PREFIX_TEXT.length();
|
||||||
final int size = text.length();
|
final int size = text.length();
|
||||||
if (size < prefixLen) {
|
if (size < prefixLen) {
|
||||||
return text;
|
return TextUtils.isEmpty(text) ? null : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
sb = null;
|
sb = null;
|
||||||
|
@ -421,7 +424,7 @@ public final class KeySpecParser {
|
||||||
text = sb.toString();
|
text = sb.toString();
|
||||||
}
|
}
|
||||||
} while (sb != null);
|
} while (sb != null);
|
||||||
return text;
|
return TextUtils.isEmpty(text) ? null : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int searchTextNameEnd(final String text, final int start) {
|
private static int searchTextNameEnd(final String text, final int start) {
|
||||||
|
|
|
@ -116,6 +116,16 @@ public class KeySpecParserSplitTests extends InstrumentationTestCase {
|
||||||
private static final String SURROGATE1 = PAIR1 + PAIR2;
|
private static final String SURROGATE1 = PAIR1 + PAIR2;
|
||||||
private static final String SURROGATE2 = PAIR1 + PAIR2 + PAIR3;
|
private static final String SURROGATE2 = PAIR1 + PAIR2 + PAIR3;
|
||||||
|
|
||||||
|
public void testResolveNullText() {
|
||||||
|
assertNull("resolve null", KeySpecParser.resolveTextReference(
|
||||||
|
null, mTextsSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testResolveEmptyText() {
|
||||||
|
assertNull("resolve empty text", KeySpecParser.resolveTextReference(
|
||||||
|
"!text/empty_string", mTextsSet));
|
||||||
|
}
|
||||||
|
|
||||||
public void testSplitZero() {
|
public void testSplitZero() {
|
||||||
assertTextArray("Empty string", "");
|
assertTextArray("Empty string", "");
|
||||||
assertTextArray("Empty entry", ",");
|
assertTextArray("Empty entry", ",");
|
||||||
|
|
Loading…
Reference in New Issue