Return null if "!text/" reference is an empty text
Change-Id: I01826f3e09527348fb4cba3302a9394ff34f424a
This commit is contained in:
parent
a72e8f1ede
commit
5bf55a86d0
2 changed files with 17 additions and 4 deletions
|
@ -78,10 +78,10 @@ public final class KeySpecParser {
|
|||
* or has no key specifications.
|
||||
*/
|
||||
public static String[] splitKeySpecs(final String text) {
|
||||
final int size = text.length();
|
||||
if (size == 0) {
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
return null;
|
||||
}
|
||||
final int size = text.length();
|
||||
// Optimization for one-letter key specification.
|
||||
if (size == 1) {
|
||||
return text.charAt(0) == COMMA ? null : new String[] { text };
|
||||
|
@ -380,6 +380,9 @@ public final class KeySpecParser {
|
|||
|
||||
public static String resolveTextReference(final String rawText,
|
||||
final KeyboardTextsSet textsSet) {
|
||||
if (TextUtils.isEmpty(rawText)) {
|
||||
return null;
|
||||
}
|
||||
int level = 0;
|
||||
String text = rawText;
|
||||
StringBuilder sb;
|
||||
|
@ -392,7 +395,7 @@ public final class KeySpecParser {
|
|||
final int prefixLen = PREFIX_TEXT.length();
|
||||
final int size = text.length();
|
||||
if (size < prefixLen) {
|
||||
return text;
|
||||
return TextUtils.isEmpty(text) ? null : text;
|
||||
}
|
||||
|
||||
sb = null;
|
||||
|
@ -421,7 +424,7 @@ public final class KeySpecParser {
|
|||
text = sb.toString();
|
||||
}
|
||||
} while (sb != null);
|
||||
return text;
|
||||
return TextUtils.isEmpty(text) ? null : text;
|
||||
}
|
||||
|
||||
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 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() {
|
||||
assertTextArray("Empty string", "");
|
||||
assertTextArray("Empty entry", ",");
|
||||
|
|
Loading…
Reference in a new issue