diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain')
3 files changed, 24 insertions, 6 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 3fd958bcc..941c95cb0 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -264,8 +264,17 @@ public class KeyListFragment extends LoaderFragment String where = null; String whereArgs[] = null; if (mCurQuery != null) { - where = KeyRings.USER_ID + " LIKE ?"; - whereArgs = new String[]{"%" + mCurQuery + "%"}; + String[] words = mCurQuery.trim().split("\\s+"); + whereArgs = new String[words.length]; + for (int i = 0; i < words.length; ++i) { + if (where == null) { + where = ""; + } else { + where += " AND "; + } + where += KeyRings.USER_ID + " LIKE ?"; + whereArgs[i] = "%" + words[i] + "%"; + } } // Now create and return a CursorLoader that will take care of diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java index 2ad769b00..25fa698ef 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java @@ -282,8 +282,17 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T String where = null; String whereArgs[] = null; if (mCurQuery != null) { - where = KeyRings.USER_ID + " LIKE ?"; - whereArgs = new String[]{"%" + mCurQuery + "%"}; + String[] words = mCurQuery.trim().split("\\s+"); + whereArgs = new String[words.length]; + for (int i = 0; i < words.length; ++i) { + if (where == null) { + where = ""; + } else { + where += " AND "; + } + where += KeyRings.USER_ID + " LIKE ?"; + whereArgs[i] = "%" + words[i] + "%"; + } } // Now create and return a CursorLoader that will take care of diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/HighlightQueryCursorAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/HighlightQueryCursorAdapter.java index fd7a2dc30..4a37a9a3a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/HighlightQueryCursorAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/HighlightQueryCursorAdapter.java @@ -49,9 +49,9 @@ public abstract class HighlightQueryCursorAdapter extends CursorAdapter { Spannable highlight = Spannable.Factory.getInstance().newSpannable(text); if (mCurQuery != null) { - Pattern pattern = Pattern.compile("(?i)" + mCurQuery); + Pattern pattern = Pattern.compile("(?i)(" + mCurQuery.trim().replaceAll("\\s+", "|") + ")"); Matcher matcher = pattern.matcher(text); - if (matcher.find()) { + while (matcher.find()) { highlight.setSpan( new ForegroundColorSpan(mContext.getResources().getColor(R.color.emphasis)), matcher.start(), |