diff options
author | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-08-20 20:58:58 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2013-08-20 20:58:58 +0000 |
commit | 6b7e48d092408c21be814f8dac25ce14e872992e (patch) | |
tree | 0594cad8c263b5dcdd763cb17d02e4d5f4f961dc | |
parent | 9e58d716d94b67f5c3fe92fc6366bcd16ef548b2 (diff) | |
parent | 2c3bbe4109a415997197af62aa2aee6ad33d9bfe (diff) | |
download | android_packages_inputmethods_LatinIME-6b7e48d092408c21be814f8dac25ce14e872992e.tar.gz android_packages_inputmethods_LatinIME-6b7e48d092408c21be814f8dac25ce14e872992e.tar.bz2 android_packages_inputmethods_LatinIME-6b7e48d092408c21be814f8dac25ce14e872992e.zip |
Merge "LatinIME: fix broken ( after 4.3 sources merge ) Armenian auto-capitalization" into cm-10.2
-rw-r--r-- | java/src/com/android/inputmethod/latin/CapsModeUtils.java | 41 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/Constants.java | 3 |
2 files changed, 41 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/CapsModeUtils.java b/java/src/com/android/inputmethod/latin/CapsModeUtils.java index 4b8d1ac11..ef323be5a 100644 --- a/java/src/com/android/inputmethod/latin/CapsModeUtils.java +++ b/java/src/com/android/inputmethod/latin/CapsModeUtils.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2013 The Android Open Source Project + * Copyright (C) 2013 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,9 +103,11 @@ public final class CapsModeUtils { // Step 2 : Skip (ignore at the end of input) any opening punctuation. This includes // opening parentheses, brackets, opening quotes, everything that *opens* a span of // text in the linguistic sense. In RTL languages, this is still an opening sign, although - // it may look like a right parenthesis for example. We also include double quote and - // single quote since they aren't start punctuation in the unicode sense, but should still - // be skipped for English. TODO: does this depend on the language? + // it may look like a right parenthesis for example. We also include single quote, + // double quote and left double angle quote since they aren't start punctuation in the + // unicode sense, but should still be skipped for English. + // TODO: does this depend on the language? + int i; if (hasSpaceBefore) { i = cs.length() + 1; @@ -112,6 +115,7 @@ public final class CapsModeUtils { for (i = cs.length(); i > 0; i--) { final char c = cs.charAt(i - 1); if (c != Constants.CODE_DOUBLE_QUOTE && c != Constants.CODE_SINGLE_QUOTE + && c != Constants.CODE_LEFT_DOUBLE_ANGLE_QUOTE && Character.getType(c) != Character.START_PUNCTUATION) { break; } @@ -187,6 +191,37 @@ public final class CapsModeUtils { if (c == Constants.CODE_QUESTION_MARK || c == Constants.CODE_EXCLAMATION_MARK) { return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_SENTENCES) & reqModes; } + + // In Armenian a sentence ends by an Armenian full stop (like a colon) and not by a period. + // It also can end by three dots. Occasionally two dots can be used instead of three. + // Thus allow a sentence to end by two or more dots. + // Armenian full stop: U+0589 - '։'. + // Also allow a sentence to end by a question mark or an exclamation mark (the code above). + // Don't allow a sentence to end by a single dot. + + final int CODE_ARMENIAN_FULL_STOP = 0x589; + + if (locale.getLanguage().equals("hy")) { + if (c == Constants.CODE_COLON || c == CODE_ARMENIAN_FULL_STOP) { + return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_SENTENCES) & reqModes; + } else if (c == Constants.CODE_PERIOD) { + if (j <= 0) { + return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_WORDS) & reqModes; + } else { + c = cs.charAt(--j); + if (c == Constants.CODE_PERIOD) { + return (TextUtils.CAP_MODE_CHARACTERS + | TextUtils.CAP_MODE_SENTENCES) & reqModes; + } else { + return (TextUtils.CAP_MODE_CHARACTERS + | TextUtils.CAP_MODE_WORDS) & reqModes; + } + } + } else { + return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_WORDS) & reqModes; + } + } + if (c != Constants.CODE_PERIOD || j <= 0) { return (TextUtils.CAP_MODE_CHARACTERS | TextUtils.CAP_MODE_WORDS) & reqModes; } diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java index 86bb25562..19408eede 100644 --- a/java/src/com/android/inputmethod/latin/Constants.java +++ b/java/src/com/android/inputmethod/latin/Constants.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 The Android Open Source Project + * Copyright (C) 2013 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -158,10 +159,12 @@ public final class Constants { public static final int CODE_DASH = '-'; public static final int CODE_SINGLE_QUOTE = '\''; public static final int CODE_DOUBLE_QUOTE = '"'; + public static final int CODE_LEFT_DOUBLE_ANGLE_QUOTE = 0xAB; public static final int CODE_QUESTION_MARK = '?'; public static final int CODE_EXCLAMATION_MARK = '!'; public static final int CODE_SLASH = '/'; public static final int CODE_COMMERCIAL_AT = '@'; + public static final int CODE_COLON = ':'; // TODO: Check how this should work for right-to-left languages. It seems to stand // that for rtl languages, a closing parenthesis is a left parenthesis. Is this // managed by the font? Or is it a different char? |