Make category searching case insensitive. Only works for ASCII :(

This commit is contained in:
Peter Serwylo 2016-11-01 00:24:10 +11:00
parent 25d2659b93
commit f4c03c6baa
3 changed files with 12 additions and 2 deletions

View File

@ -701,7 +701,10 @@ public class AppProvider extends FDroidProvider {
return new AppQuerySelection();
}
final String selection = CategoryTable.NAME + "." + CategoryTable.Cols.NAME + " = ? ";
// Note, the COLLATE NOCASE only works for ASCII columns. The "ICU extension" for SQLite
// provides proper case management for Unicode characters, but is not something provided
// by Android.
final String selection = CategoryTable.NAME + "." + CategoryTable.Cols.NAME + " = ? COLLATE NOCASE ";
final String[] args = {category};
return new AppQuerySelection(selection, args);
}

View File

@ -185,7 +185,7 @@ public class CategoryProvider extends FDroidProvider {
}
protected QuerySelection querySingle(String categoryName) {
final String selection = getTableName() + "." + Cols.NAME + " = ?";
final String selection = getTableName() + "." + Cols.NAME + " = ? COLLATE NOCASE";
final String[] args = {categoryName};
return new QuerySelection(selection, args);
}

View File

@ -82,6 +82,13 @@ public class CategoryProviderTest extends FDroidProviderTest {
"com.chicken",
});
assertPackagesInCategory("animal", new String[] {
"com.dog",
"com.cat",
"com.crow",
"com.chicken",
});
assertPackagesInCategory("Bird", new String[]{
"com.crow",
"com.chicken",