summaryrefslogtreecommitdiff
path: root/src/com/android/timezonepicker
diff options
context:
space:
mode:
authorSam Blitzstein <sblitz@google.com>2013-04-15 18:07:06 -0700
committerSam Blitzstein <sblitz@google.com>2013-04-15 18:22:00 -0700
commit020b0c4329f432946df13a43a2831be0ee3b32cd (patch)
treee6c46d1ba95784ce018f3c947447a2870dbef5fa /src/com/android/timezonepicker
parentff072e1dd75b339efcfbba22e8f14096a6c112cc (diff)
downloadtimezonepicker-020b0c4329f432946df13a43a2831be0ee3b32cd.tar.gz
Allow all words in country name to be searched.
For example, search "korea" to bring up "South Korea" Bug: 8621171 Change-Id: Ic0b35fdd7895f0ca374120d3fd209699b69d5638
Diffstat (limited to 'src/com/android/timezonepicker')
-rw-r--r--src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java13
1 files changed, 13 insertions, 0 deletions
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 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
// 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));
}
}