diff options
author | 2014-09-18 07:22:15 +0000 | |
---|---|---|
committer | 2014-09-18 07:22:15 +0000 | |
commit | 8c9948f436bd764c6483d9af8c730e1b91e3b7ab (patch) | |
tree | d91132078608db0f2f7e9b69ee619111bc6209d5 /java/src/com/android/inputmethod/latin/utils | |
parent | 97ad496868d147e311404d6f2dc0c9bca18f6231 (diff) | |
parent | fa63d910950621d820d28b177a9de199e492557c (diff) | |
download | latinime-8c9948f436bd764c6483d9af8c730e1b91e3b7ab.tar.gz latinime-8c9948f436bd764c6483d9af8c730e1b91e3b7ab.tar.xz latinime-8c9948f436bd764c6483d9af8c730e1b91e3b7ab.zip |
am fa63d910: Merge "Use Add-To-Dictionary indicator only" into lmp-dev
* commit 'fa63d910950621d820d28b177a9de199e492557c':
Use Add-To-Dictionary indicator only
Diffstat (limited to 'java/src/com/android/inputmethod/latin/utils')
-rw-r--r-- | java/src/com/android/inputmethod/latin/utils/StringUtils.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/utils/StringUtils.java b/java/src/com/android/inputmethod/latin/utils/StringUtils.java index 38f0b3fee..1781924ac 100644 --- a/java/src/com/android/inputmethod/latin/utils/StringUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/StringUtils.java @@ -37,6 +37,14 @@ public final class StringUtils { private static final String EMPTY_STRING = ""; + private static final char CHAR_LINE_FEED = 0X000A; + private static final char CHAR_VERTICAL_TAB = 0X000B; + private static final char CHAR_FORM_FEED = 0X000C; + private static final char CHAR_CARRIAGE_RETURN = 0X000D; + private static final char CHAR_NEXT_LINE = 0X0085; + private static final char CHAR_LINE_SEPARATOR = 0X2028; + private static final char CHAR_PARAGRAPH_SEPARATOR = 0X2029; + private StringUtils() { // This utility class is not publicly instantiable. } @@ -594,4 +602,30 @@ public final class StringUtils { return sb + "]"; } } + + /** + * Returns whether the last composed word contains line-breaking character (e.g. CR or LF). + * @param text the text to be examined. + * @return {@code true} if the last composed word contains line-breaking separator. + */ + @UsedForTesting + public static boolean hasLineBreakCharacter(final String text) { + if (TextUtils.isEmpty(text)) { + return false; + } + for (int i = text.length() - 1; i >= 0; --i) { + final char c = text.charAt(i); + switch (c) { + case CHAR_LINE_FEED: + case CHAR_VERTICAL_TAB: + case CHAR_FORM_FEED: + case CHAR_CARRIAGE_RETURN: + case CHAR_NEXT_LINE: + case CHAR_LINE_SEPARATOR: + case CHAR_PARAGRAPH_SEPARATOR: + return true; + } + } + return false; + } } |