Ignore leading and trailing whitespaces in search keywords
As reported in #58
This commit is contained in:
parent
85d7752d0a
commit
d22c714dbd
@ -497,14 +497,14 @@ public class AppProvider extends FDroidProvider {
|
||||
}
|
||||
|
||||
private AppQuerySelection querySearch(String keywords) {
|
||||
keywords = "%" + keywords + "%";
|
||||
keywords = "%" + cleanQueryKeywords(keywords) + "%";
|
||||
String selection =
|
||||
"fdroid_app.id like ? OR " +
|
||||
"fdroid_app.name like ? OR " +
|
||||
"fdroid_app.summary like ? OR " +
|
||||
"fdroid_app.description like ? ";
|
||||
String[] args = new String[] { keywords, keywords, keywords, keywords};
|
||||
return new AppQuerySelection(selection, args);
|
||||
return new AppQuerySelection(selection,
|
||||
new String[] { keywords, keywords, keywords, keywords });
|
||||
}
|
||||
|
||||
private AppQuerySelection querySingle(String id) {
|
||||
|
@ -142,5 +142,12 @@ public abstract class FDroidProvider extends ContentProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static String cleanQueryKeywords(String keywords) {
|
||||
if (keywords == null) {
|
||||
return null;
|
||||
}
|
||||
return keywords.trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,9 @@ public class InstalledAppProvider extends FDroidProvider {
|
||||
}
|
||||
|
||||
private QuerySelection querySearch(String keywords) {
|
||||
return new QuerySelection("applicationLabel LIKE ?", new String[]{ "%" + keywords + "%" });
|
||||
keywords = "%" + cleanQueryKeywords(keywords) + "%";
|
||||
return new QuerySelection("applicationLabel LIKE ?",
|
||||
new String[]{ keywords });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user