Merge pull request #681 from SamWhited/searchlocalefix
Use `Locale.US' for string comparisons in search
This commit is contained in:
commit
c058594ff5
|
@ -2,6 +2,7 @@ package eu.siacs.conversations.entities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import eu.siacs.conversations.utils.UIHelper;
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
@ -126,13 +127,16 @@ public class Bookmark extends Element implements ListItem {
|
||||||
if (needle == null) {
|
if (needle == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
needle = needle.toLowerCase();
|
needle = needle.toLowerCase(Locale.US);
|
||||||
return getJid().toString().contains(needle) || getDisplayName().toLowerCase().contains(needle) || matchInTag(needle);
|
return getJid().toString().contains(needle) ||
|
||||||
|
getDisplayName().toLowerCase(Locale.US).contains(needle) ||
|
||||||
|
matchInTag(needle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matchInTag(String needle) {
|
private boolean matchInTag(String needle) {
|
||||||
|
needle = needle.toLowerCase(Locale.US);
|
||||||
for (Tag tag : getTags()) {
|
for (Tag tag : getTags()) {
|
||||||
if (tag.getName().toLowerCase().contains(needle)) {
|
if (tag.getName().toLowerCase(Locale.US).contains(needle)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import eu.siacs.conversations.utils.UIHelper;
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
@ -148,7 +149,7 @@ public class Contact implements ListItem {
|
||||||
if (needle == null || needle.isEmpty()) {
|
if (needle == null || needle.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
needle = needle.toLowerCase().trim();
|
needle = needle.toLowerCase(Locale.US).trim();
|
||||||
String[] parts = needle.split("\\s+");
|
String[] parts = needle.split("\\s+");
|
||||||
if (parts.length > 1) {
|
if (parts.length > 1) {
|
||||||
for(int i = 0; i < parts.length; ++i) {
|
for(int i = 0; i < parts.length; ++i) {
|
||||||
|
@ -158,13 +159,16 @@ public class Contact implements ListItem {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return jid.toString().contains(needle) || getDisplayName().toLowerCase().contains(needle) || matchInTag(needle);
|
return jid.toString().contains(needle) ||
|
||||||
|
getDisplayName().toLowerCase(Locale.US).contains(needle) ||
|
||||||
|
matchInTag(needle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matchInTag(String needle) {
|
private boolean matchInTag(String needle) {
|
||||||
|
needle = needle.toLowerCase(Locale.US);
|
||||||
for (Tag tag : getTags()) {
|
for (Tag tag : getTags()) {
|
||||||
if (tag.getName().toLowerCase().contains(needle)) {
|
if (tag.getName().toLowerCase(Locale.US).contains(needle)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue