Merge "Allow all words in country name to be searched." into jb-mr2-dev
diff --git a/src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java b/src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java
index 65bd530..ffc699b 100644
--- a/src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java
+++ b/src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java
@@ -209,9 +209,22 @@
                 // TODO Perf - cache toLowerCase()?
                 if (!TextUtils.isEmpty(country)) {
                     final String lowerCaseCountry = country.toLowerCase();
+                    boolean isMatch = false;
                     if (lowerCaseCountry.startsWith(prefixString)
                             || (lowerCaseCountry.charAt(0) == prefixString.charAt(0) &&
                             isStartingInitialsFor(prefixString, lowerCaseCountry))) {
+                        isMatch = true;
+                    } else if (lowerCaseCountry.contains(" ")){
+                        // We should also search other words in the country name, so that
+                        // searches like "Korea" yield "South Korea".
+                        for (String word : lowerCaseCountry.split(" ")) {
+                            if (word.startsWith(prefixString)) {
+                                isMatch = true;
+                                break;
+                            }
+                        }
+                    }
+                    if (isMatch) {
                         filtered.add(new FilterTypeResult(FILTER_TYPE_COUNTRY, country, 0));
                     }
                 }