Skip to content

Commit 6272442

Browse files
committed
CategoriesModel: make category search case-insensitive
1 parent 5b05c97 commit 6272442

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

app/src/main/java/fr/free/nrw/commons/category/CategoriesModel.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ public Observable<CategoryItem> searchAll(String term, List<String> imageTitleLi
123123
}
124124

125125
//otherwise, search API for matching categories
126+
//term passed as lower case to make search case-insensitive(taking only lower case for everything)
126127
return categoryClient
127-
.searchCategoriesForPrefix(term, SEARCH_CATS_LIMIT)
128+
.searchCategoriesForPrefix(term.toLowerCase(), SEARCH_CATS_LIMIT)
128129
.map(name -> new CategoryItem(name, false));
129130
}
130131

@@ -183,11 +184,12 @@ private Observable<CategoryItem> titleCategories(List<String> titleList) {
183184

184185
/**
185186
* Return category for single title
187+
* title is converted to lower case to make search case-insensitive
186188
* @param title
187189
* @return
188190
*/
189191
private Observable<CategoryItem> getTitleCategories(String title) {
190-
return categoryClient.searchCategories(title, SEARCH_CATS_LIMIT)
192+
return categoryClient.searchCategories(title.toLowerCase(), SEARCH_CATS_LIMIT)
191193
.map(name -> new CategoryItem(name, false));
192194
}
193195

app/src/main/java/fr/free/nrw/commons/category/CategoryClient.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ public CategoryClient(CategoryInterface CategoryInterface) {
3030

3131
/**
3232
* Searches for categories containing the specified string.
33-
* It will be converted to Lower Case as the server performs Case-insensitive search.
3433
*
3534
* @param filter The string to be searched
3635
* @param itemLimit How many results are returned
3736
* @param offset Starts returning items from the nth result. If offset is 9, the response starts with the 9th item of the search result
3837
* @return
3938
*/
4039
public Observable<String> searchCategories(String filter, int itemLimit, int offset) {
41-
return responseToCategoryName(CategoryInterface.searchCategories(filter.toLowerCase(), itemLimit, offset));
40+
return responseToCategoryName(CategoryInterface.searchCategories(filter, itemLimit, offset));
4241

4342
}
4443

@@ -56,15 +55,14 @@ public Observable<String> searchCategories(String filter, int itemLimit) {
5655

5756
/**
5857
* Searches for categories starting with the specified string.
59-
* It will be converted to Lower Case as the server performs Case-insensitive search.
6058
*
6159
* @param prefix The prefix to be searched
6260
* @param itemLimit How many results are returned
6361
* @param offset Starts returning items from the nth result. If offset is 9, the response starts with the 9th item of the search result
6462
* @return
6563
*/
6664
public Observable<String> searchCategoriesForPrefix(String prefix, int itemLimit, int offset) {
67-
return responseToCategoryName(CategoryInterface.searchCategoriesForPrefix(prefix.toLowerCase(), itemLimit, offset));
65+
return responseToCategoryName(CategoryInterface.searchCategoriesForPrefix(prefix, itemLimit, offset));
6866
}
6967

7068
/**

0 commit comments

Comments
 (0)