Commit 99f8bb10 authored by Aayush Gupta's avatar Aayush Gupta
Browse files

Merge branch '1208-search_ignore_accents' into 'master'

Remove accents from search strings

See merge request !94
parents 15dc8a71 fb442a74
Pipeline #185961 passed with stage
in 4 minutes and 19 seconds
......@@ -159,6 +159,9 @@ dependencies {
implementation Libs.AndroidX.Room.runtime
kapt Libs.AndroidX.Room.compiler
// Apache Commons
implementation Libs.ApacheCommons.commonsLang
// Unit test dependencies
testImplementation Libs.junit
testImplementation Libs.robolectric
......
......@@ -14,6 +14,8 @@ import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import org.apache.commons.lang3.StringUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
......@@ -217,4 +219,8 @@ public class Utilities {
public static int boundToRange(int value, int lowerBound, int upperBound) {
return Math.max(lowerBound, Math.min(value, upperBound));
}
public static String stripCaseAndAccents(String input) {
return StringUtils.stripAccents(input.toLowerCase());
}
}
......@@ -79,6 +79,7 @@ import androidx.viewpager.widget.ViewPager;
import com.jakewharton.rxbinding3.widget.RxTextView;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
......@@ -1595,7 +1596,7 @@ public class LauncherActivity extends AppCompatActivity implements
private Observable<SuggestionsResult> searchForLauncherItems(
CharSequence charSequence) {
String query = charSequence.toString().toLowerCase();
String query = Utilities.stripCaseAndAccents(charSequence.toString());
SuggestionsResult suggestionsResult = new SuggestionsResult(
query);
List<LauncherItem> launcherItems = new ArrayList<>();
......@@ -1606,11 +1607,11 @@ public class LauncherActivity extends AppCompatActivity implements
if (launcherItem.itemType == Constants.ITEM_TYPE_FOLDER) {
FolderItem folderItem = (FolderItem) launcherItem;
for (LauncherItem item : folderItem.items) {
if (item.title.toString().toLowerCase().contains(query)) {
if (Utilities.stripCaseAndAccents(item.title.toString()).contains(query)) {
launcherItems.add(item);
}
}
} else if (launcherItem.title.toString().toLowerCase().contains(query)) {
} else if (Utilities.stripCaseAndAccents(launcherItem.title.toString()).contains(query)) {
launcherItems.add(launcherItem);
}
}
......@@ -1622,11 +1623,11 @@ public class LauncherActivity extends AppCompatActivity implements
if (launcherItem.itemType == Constants.ITEM_TYPE_FOLDER) {
FolderItem folderItem = (FolderItem) launcherItem;
for (LauncherItem item : folderItem.items) {
if (item.title.toString().toLowerCase().contains(query)) {
if (Utilities.stripCaseAndAccents(item.title.toString()).contains(query)) {
launcherItems.add(item);
}
}
} else if (launcherItem.title.toString().toLowerCase().contains(query)) {
} else if (Utilities.stripCaseAndAccents(launcherItem.title.toString()).contains(query)) {
launcherItems.add(launcherItem);
}
}
......
......@@ -34,6 +34,10 @@ object Libs {
const val robolectric = "org.robolectric:robolectric:${Versions.robolectric}"
const val mockK = "io.mockk:mockk:${Versions.mockK}"
object ApacheCommons {
const val commonsLang = "org.apache.commons:commons-lang3:3.12.0"
}
object Google {
const val firebaseCore = "com.google.firebase:firebase-core:${Versions.firebase_core}"
const val crashlytics = "com.crashlytics.sdk.android:crashlytics:${Versions.crashlytics}"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment