diff options
author | Bai Tao <michaelbai@google.com> | 2010-01-21 08:40:45 +0800 |
---|---|---|
committer | Bai Tao <michaelbai@google.com> | 2010-01-27 09:18:57 +0800 |
commit | 4cd13c4266d8e476e1a49c4b6bcd5b18c33d0de3 (patch) | |
tree | 0fc798c6377fe2e4b63908ae091d5931dc629eb3 /src/com/android/providers/contacts/NameSplitter.java | |
parent | 8be93f4d062ad3919ba48245dd147a49715db82d (diff) | |
download | packages_providers_ContactsProvider-4cd13c4266d8e476e1a49c4b6bcd5b18c33d0de3.zip packages_providers_ContactsProvider-4cd13c4266d8e476e1a49c4b6bcd5b18c33d0de3.tar.gz packages_providers_ContactsProvider-4cd13c4266d8e476e1a49c4b6bcd5b18c33d0de3.tar.bz2 |
a. Fix the issue that the FullNameStyle is not updated when user edits the contact or the contacts being synced.
b. Add Chinese sort and search.
c. Adds a CJK check for each contact at runtime. per discussion with component owner, will tune performance later after Korean and Japanese features are added.
Diffstat (limited to 'src/com/android/providers/contacts/NameSplitter.java')
-rw-r--r-- | src/com/android/providers/contacts/NameSplitter.java | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/com/android/providers/contacts/NameSplitter.java b/src/com/android/providers/contacts/NameSplitter.java index 476e098..0b98343 100644 --- a/src/com/android/providers/contacts/NameSplitter.java +++ b/src/com/android/providers/contacts/NameSplitter.java @@ -804,6 +804,9 @@ public class NameSplitter { */ public void guessNameStyle(Name name) { guessFullNameStyle(name); + if (FullNameStyle.CJK == name.fullNameStyle) { + name.fullNameStyle = getAdjustedFullNameStyle(name.fullNameStyle); + } guessPhoneticNameStyle(name); name.fullNameStyle = getAdjustedNameStyleBasedOnPhoneticNameStyle(name.fullNameStyle, name.phoneticNameStyle); @@ -840,14 +843,17 @@ public class NameSplitter { } int bestGuess = guessFullNameStyle(name.givenNames); - if (bestGuess != FullNameStyle.UNDEFINED && bestGuess != FullNameStyle.CJK) { + // A mix of Hanzi and latin chars are common in China, so we have to go through all names + // if the name is not JANPANESE or KOREAN. + if (bestGuess != FullNameStyle.UNDEFINED && bestGuess != FullNameStyle.CJK + && bestGuess != FullNameStyle.WESTERN) { name.fullNameStyle = bestGuess; return; } int guess = guessFullNameStyle(name.familyName); if (guess != FullNameStyle.UNDEFINED) { - if (guess != FullNameStyle.CJK) { + if (guess != FullNameStyle.CJK && guess != FullNameStyle.WESTERN) { name.fullNameStyle = guess; return; } @@ -856,7 +862,7 @@ public class NameSplitter { guess = guessFullNameStyle(name.middleName); if (guess != FullNameStyle.UNDEFINED) { - if (guess != FullNameStyle.CJK) { + if (guess != FullNameStyle.CJK && guess != FullNameStyle.WESTERN) { name.fullNameStyle = guess; return; } @@ -879,26 +885,23 @@ public class NameSplitter { if (Character.isLetter(codePoint)) { UnicodeBlock unicodeBlock = UnicodeBlock.of(codePoint); - if (isLatinUnicodeBlock(unicodeBlock)) { - return FullNameStyle.WESTERN; - } - - if (isCJKUnicodeBlock(unicodeBlock)) { + if (!isLatinUnicodeBlock(unicodeBlock)) { - // We don't know if this is Chinese, Japanese or Korean - - // trying to figure out by looking at other characters in the name - return guessCJKNameStyle(name, offset + Character.charCount(codePoint)); - } + if (isCJKUnicodeBlock(unicodeBlock)) { + // We don't know if this is Chinese, Japanese or Korean - + // trying to figure out by looking at other characters in the name + return guessCJKNameStyle(name, offset + Character.charCount(codePoint)); + } - if (isJapanesePhoneticUnicodeBlock(unicodeBlock)) { - return FullNameStyle.JAPANESE; - } + if (isJapanesePhoneticUnicodeBlock(unicodeBlock)) { + return FullNameStyle.JAPANESE; + } - if (isKoreanUnicodeBlock(unicodeBlock)) { - return FullNameStyle.KOREAN; + if (isKoreanUnicodeBlock(unicodeBlock)) { + return FullNameStyle.KOREAN; + } } - - return FullNameStyle.WESTERN; + nameStyle = FullNameStyle.WESTERN; } offset += Character.charCount(codePoint); } |