diff options
author | cretin45 <cretin45@gmail.com> | 2014-07-23 16:32:45 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-16 19:53:26 -0800 |
commit | e0bbf0a974f9ff5bc8870f53e8dfd001c3cbacae (patch) | |
tree | 1bc9202166ffffe411e44f3f35a9b1f5a48c8908 /tests | |
parent | 3bc8f2bb1de7dd790bcb198a790d752f1a73b6fd (diff) | |
download | android_packages_apps_Dialer-e0bbf0a974f9ff5bc8870f53e8dfd001c3cbacae.tar.gz android_packages_apps_Dialer-e0bbf0a974f9ff5bc8870f53e8dfd001c3cbacae.tar.bz2 android_packages_apps_Dialer-e0bbf0a974f9ff5bc8870f53e8dfd001c3cbacae.zip |
Dialer: Refactor SmartDial for additional languages
Adds Chinese support and improved Korean support.
p4: Refactor for transliterating the displayName.
Change-Id: Id3175c6f4eda4962be9d25bd43c24a834c3c5ff1
Read option for t9 search input locale and refresh smart dial db when locale changes
Change-Id: I3cd942741310f16678ed9eb675bbba2cbc72d5e8
Add setting for t9 search input locale
Change-Id: I410b4e20afa85302a9ef3174c2f219e33b1b7987
Return match positions to enable highlighting for CN smart dial
Change-Id: I9255c582708c2fbfe22e7a2bf3ad971da692e2a9
Dialer: Fix T9 for Hebrew
Change-Id: I1c8be92acc1fc29b557eb7cda0d910cf036f3aea
Move smart dialer initialization to onStart().
The SmartDialCursorLoader expects the SmartDialPrefix map to be
initialized when it's created. As
- the loader is initialized in SmartDialSearchFragment's onStart and
- the fragment's onStart is called asynchronously after the activity's
onStart and
- the map initialization happens in
SmartDialPrefix.initializeNanpSettings() and
- the above method is currently called in the activity's onResume()
we have a race condition between the activity's onResume() and the
fragment's onStart() (at least when processing a dial intent, which is
what causes the dialpad fragment to be immediately shown).
Fix that race condition by moving the initialization into the activity's
onStart() and running it before calling the super method to ensure it
happens before fragments are started.
JIRA:NIGHTLIES-760
Change-Id: I9767cbba3b177fdd5b1de86914cb1e40d20835ab
Ensure the smart dial name matcher is initialized in onStart().
Otherwise SmartDialPrefix.getMap() might not be initialized yet.
JIRA: NIGHTLIES-1279
Change-Id: If3aca2809faf0c1f379518096a76f17d357fb8e2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java b/tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java index b0dc91d2c..0c910670c 100644 --- a/tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java +++ b/tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java @@ -33,6 +33,12 @@ import junit.framework.TestCase; public class SmartDialNameMatcherTest extends AndroidTestCase { private static final String TAG = "SmartDialNameMatcherTest"; + @Override + public void setUp() { + SmartDialPrefix.setSmartDialMap(new LatinSmartDialMap()); + SmartDialPrefix.setUserInNanpRegion(true); + } + public void testMatches() { // Test to ensure that all alphabetic characters are covered checkMatches("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", @@ -162,6 +168,30 @@ public class SmartDialNameMatcherTest extends AndroidTestCase { fail("Cyrillic letters aren't supported yet."); } + public void testMatches_chinese() { + SmartDialPrefix.setSmartDialMap(new ChineseSmartDialMap()); + + // basic cases + checkMatches("红霞李", "46", true, 0, 1); + checkMatches("红霞李", "46649", true, 0, 1, 1, 2); + checkMatches("红霞李", "5", true, 2, 3); + checkMatches("红霞李", "466494254", true, 0, 1, 1, 2, 2, 3); + + // test with spaces + checkMatches("红霞 李", "466494254", true, 0, 1, 1, 2, 2, 3); + checkMatches(" 红 霞 李", "466494254", true, 0, 1, 1, 2, 2, 3); + + // when character sets are mixed, match english only + checkMatches("Hongxia 李", "46", true, 0, 2); + checkMatches("Hongxia 李", "5", false); + + // make sure regular english cases still work + checkMatches("Meow Face", "63", true, 0, 2); + checkMatches("Meow Face", "32", true, 5, 7); + checkMatches("Meow Face", "632", true, 0, 1, 5, 7); + + SmartDialPrefix.setSmartDialMap(new LatinSmartDialMap()); + } public void testMatches_NumberBasic() { // Simple basic examples that start the match from the start of the number @@ -199,6 +229,7 @@ public class SmartDialNameMatcherTest extends AndroidTestCase { public void testMatches_NumberNANP() { SmartDialPrefix.setUserInNanpRegion(true); + // An 11 digit number prefixed with 1 should be matched by the 10 digit number, as well as // the 7 digit number (without area code) checkMatchesNumber("1-510-333-7596", "5103337596", true, true, 2, 14); @@ -253,8 +284,8 @@ public class SmartDialNameMatcherTest extends AndroidTestCase { final SmartDialNameMatcher matcher = new SmartDialNameMatcher(query, getContext()); final ArrayList<SmartDialMatchPosition> matchPositions = new ArrayList<SmartDialMatchPosition>(); - final boolean matches = matcher.matchesCombination( - displayName, query, matchPositions); + final boolean matches = + SmartDialPrefix.getMap().matchesCombination(matcher, displayName, query, matchPositions); Log.d(TAG, "query=" + query + " text=" + displayName + " nfd=" + Normalizer.normalize(displayName, Normalizer.Form.NFD) + " nfc=" + Normalizer.normalize(displayName, Normalizer.Form.NFC) |