OSDN Git Service

Show search results when query string contains trailing space
authorlong.x.qiao <long.x.qiao@sonymobile.com>
Tue, 29 Nov 2016 05:50:51 +0000 (13:50 +0800)
committerYoshinori Hirano <yoshinori.hirano@sonymobile.com>
Wed, 1 Mar 2017 12:00:57 +0000 (21:00 +0900)
The query expression used to search for a term prefix is the prefix
itself with a '*' character appended to it. However, if query string
contains trailing space, the query expresssion (e.g. "screen *") doesn't
work. So to fix this issue, the unnecessary trailing space should be
removed.

Bug: 35231587
Test: manual - go to search in Settings and enter "screen "

Change-Id: Ifa5d96f5d38ad5454272f140da440b8ff55d5614

src/com/android/settings/search/Index.java

index 084f9c3..fe89d4f 100644 (file)
@@ -707,7 +707,7 @@ public class Index {
     }
 
     private String buildSearchMatchStringForColumns(String query, String[] columnNames) {
-        final String value = query + "*";
+        final String value = (query != null ? query.trim() : "") + "*";
         StringBuilder sb = new StringBuilder();
         final int count = columnNames.length;
         for (int n = 0; n < count; n++) {