Allow all words in country name to be searched.
For example, search "korea" to bring up "South Korea"
Bug: 8621171
Change-Id: Ic0b35fdd7895f0ca374120d3fd209699b69d5638
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));
}
}