Commit 56334ba4 authored by Aline Bonnet's avatar Aline Bonnet Committed by Alexandre Lision
Browse files

smartlist: fix special characters

This commit normalizes strings to remove the special characters.
We can search a name with or without the special characters.

Change-Id: I76fb9609899ca5487f13b5ca2ae347522458f626
Tuleap: #702
parent 86759bbc
......@@ -37,6 +37,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import java.lang.ref.WeakReference;
import java.text.Normalizer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
......@@ -75,6 +76,10 @@ public class SmartListAdapter extends BaseAdapter {
mInfosFetcher = pool;
}
private String stringFormatting(String query){
return Normalizer.normalize(query.toLowerCase(), Normalizer.Form.NFD).replaceAll("[\u0300-\u036F]", "");
}
public void updateDataset(final Collection<Conversation> list, String query) {
Log.d(TAG, "updateDataset " + list.size()
+ " with query: " + query);
......@@ -95,7 +100,7 @@ public class SmartListAdapter extends BaseAdapter {
} else if (c.getContact() != null) {
CallContact contact = c.getContact();
if (!TextUtils.isEmpty(contact.getDisplayName()) &&
contact.getDisplayName().toLowerCase().contains(query.toLowerCase())) {
stringFormatting(contact.getDisplayName()).contains(stringFormatting(query))) {
mCalls.add(c);
} else if (contact.getPhones() != null && !contact.getPhones().isEmpty()) {
ArrayList<CallContact.Phone> phones = contact.getPhones();
......@@ -103,7 +108,7 @@ public class SmartListAdapter extends BaseAdapter {
if (phone.getNumber() != null) {
String rawUriString = phone.getNumber().getRawUriString();
if (!TextUtils.isEmpty(rawUriString) &&
rawUriString.toLowerCase().contains(query.toLowerCase())) {
stringFormatting(rawUriString.toLowerCase()).contains(stringFormatting(query))) {
mCalls.add(c);
}
}
......
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