summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/contacts
diff options
context:
space:
mode:
authorJay Shrauner <shrauner@google.com>2015-04-29 16:34:44 -0700
committerJay Shrauner <shrauner@google.com>2015-04-30 13:52:48 -0700
commit61ec18168fea70e5c10a28776fd5b9257d9961bc (patch)
tree37ef23f46f29452f10644b21fb563de945d39361 /src/com/android/providers/contacts
parent3891893bf85d30963caf47a419114349c6520b2f (diff)
downloadpackages_providers_ContactsProvider-61ec18168fea70e5c10a28776fd5b9257d9961bc.tar.gz
packages_providers_ContactsProvider-61ec18168fea70e5c10a28776fd5b9257d9961bc.tar.bz2
packages_providers_ContactsProvider-61ec18168fea70e5c10a28776fd5b9257d9961bc.zip
Use transliterator for Simplified Chinese buckets
Use Pinyin name transliterator instead of AlphabeticIndex for bucketing Simplified Chinese names. Bug:19835686 Change-Id: I350a4375e2b5ba05320143581c7b532678f69120
Diffstat (limited to 'src/com/android/providers/contacts')
-rw-r--r--src/com/android/providers/contacts/ContactLocaleUtils.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/com/android/providers/contacts/ContactLocaleUtils.java b/src/com/android/providers/contacts/ContactLocaleUtils.java
index 340b6a55..4ca9118b 100644
--- a/src/com/android/providers/contacts/ContactLocaleUtils.java
+++ b/src/com/android/providers/contacts/ContactLocaleUtils.java
@@ -71,7 +71,7 @@ public class ContactLocaleUtils {
protected final ImmutableIndex mAlphabeticIndex;
private final int mAlphabeticIndexBucketCount;
private final int mNumberBucketIndex;
- private final boolean mEnableSecondaryLocalePinyin;
+ private final boolean mUsePinyinTransliterator;
public ContactLocaleUtilsBase(LocaleSet locales) {
// AlphabeticIndex.getBucketLabel() uses a binary search across
@@ -87,7 +87,8 @@ public class ContactLocaleUtils {
// Cyrillic because their alphabets are complementary supersets
// of Russian.
final Locale secondaryLocale = locales.getSecondaryLocale();
- mEnableSecondaryLocalePinyin = locales.isSecondaryLocaleSimplifiedChinese();
+ mUsePinyinTransliterator = locales.isPrimaryLocaleSimplifiedChinese() ||
+ locales.isSecondaryLocaleSimplifiedChinese();
AlphabeticIndex ai = new AlphabeticIndex(locales.getPrimaryLocale())
.setMaxLabelCount(300);
if (secondaryLocale != null) {
@@ -144,10 +145,13 @@ public class ContactLocaleUtils {
}
/**
- * TODO: ICU 52 AlphabeticIndex doesn't support Simplified Chinese
- * as a secondary locale. Remove the following if that is added.
+ * ICU 55 AlphabeticIndex doesn't support Simplified Chinese
+ * as a secondary locale so it is necessary to use the
+ * Pinyin transliterator. We also use this for a Simplified
+ * Chinese primary locale because it gives more accurate letter
+ * buckets. b/19835686
*/
- if (mEnableSecondaryLocalePinyin) {
+ if (mUsePinyinTransliterator) {
name = HanziToPinyin.getInstance().transliterate(name);
}
final int bucket = mAlphabeticIndex.getBucketIndex(name);