From ab81d8903a92e1f80105f223a727d75b94754769 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 14 May 2014 19:54:20 +0200 Subject: Support mutliple search words and highlight them For the regex matching it would be smart to sort the words by length, so the longest matches come first. This only matters for queries with words containing parts of each other, which is an unlikely event and even then it doesn't break anything. --- .../org/sufficientlysecure/keychain/ui/KeyListFragment.java | 13 +++++++++++-- .../keychain/ui/SelectPublicKeyFragment.java | 13 +++++++++++-- .../keychain/ui/adapter/HighlightQueryCursorAdapter.java | 4 ++-- 3 files changed, 24 insertions(+), 6 deletions(-) (limited to 'OpenKeychain/src/main/java') 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(), -- cgit v1.2.3 From 69ce66be9429b3490511655c836f400cc30c4d4f Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 14 May 2014 20:07:30 +0200 Subject: Add highlighting to keyserver/keybase search --- .../keychain/keyimport/HkpKeyServer.java | 1 + .../keychain/keyimport/ImportKeysListEntry.java | 9 ++++ .../keychain/keyimport/KeybaseKeyServer.java | 5 +- .../keychain/ui/adapter/ImportKeysAdapter.java | 8 +-- .../keychain/util/Highlighter.java | 57 ++++++++++++++++++++++ 5 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Highlighter.java (limited to 'OpenKeychain/src/main/java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyServer.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyServer.java index 8d1e1f460..28a8c8251 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyServer.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyServer.java @@ -237,6 +237,7 @@ public class HkpKeyServer extends KeyServer { final Matcher matcher = PUB_KEY_LINE.matcher(data); while (matcher.find()) { final ImportKeysListEntry entry = new ImportKeysListEntry(); + entry.setQuery(query); entry.setBitStrength(Integer.parseInt(matcher.group(3))); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java index 4a8d58e56..04b86e295 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java @@ -51,6 +51,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable { public boolean secretKey; public String mPrimaryUserId; private String mExtraData; + private String mQuery; private boolean mSelected; @@ -209,6 +210,14 @@ public class ImportKeysListEntry implements Serializable, Parcelable { mExtraData = extraData; } + public String getQuery() { + return mQuery; + } + + public void setQuery(String query) { + mQuery = query; + } + /** * Constructor for later querying from keyserver */ diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyServer.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyServer.java index 5f729a05c..88f68b8f7 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyServer.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyServer.java @@ -34,6 +34,7 @@ import java.util.TimeZone; import java.util.WeakHashMap; public class KeybaseKeyServer extends KeyServer { + private String mQuery; @Override public ArrayList search(String query) throws QueryException, TooManyResponses, @@ -86,15 +87,15 @@ public class KeybaseKeyServer extends KeyServer { } private ImportKeysListEntry makeEntry(JSONObject match) throws QueryException, JSONException { - final ImportKeysListEntry entry = new ImportKeysListEntry(); + entry.setQuery(mQuery); + String keybaseId = JWalk.getString(match, "components", "username", "val"); String fullName = JWalk.getString(match, "components", "full_name", "val"); String fingerprint = JWalk.getString(match, "components", "key_fingerprint", "val"); fingerprint = fingerprint.replace(" ", "").toUpperCase(); // not strictly necessary but doesn't hurt entry.setFingerprintHex(fingerprint); - // in anticipation of a full fingerprint, only use the last 16 chars as 64-bit key id entry.setKeyIdHex("0x" + fingerprint.substring(Math.max(0, fingerprint.length() - 16))); // store extra info, so we can query for the keybase id directly entry.setExtraData(keybaseId); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index c1fb9ae94..9573efdfe 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -33,6 +33,7 @@ import android.widget.TextView; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; +import org.sufficientlysecure.keychain.util.Highlighter; import java.util.ArrayList; import java.util.Iterator; @@ -99,6 +100,7 @@ public class ImportKeysAdapter extends ArrayAdapter { public View getView(int position, View convertView, ViewGroup parent) { ImportKeysListEntry entry = mData.get(position); + Highlighter highlighter = new Highlighter(mActivity, entry.getQuery()); ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); @@ -128,7 +130,7 @@ public class ImportKeysAdapter extends ArrayAdapter { + " " + userIdSplit[0]); holder.mainUserId.setTextColor(Color.RED); } else { - holder.mainUserId.setText(userIdSplit[0]); + holder.mainUserId.setText(highlighter.highlight(userIdSplit[0])); holder.mainUserId.setTextColor(Color.BLACK); } } else { @@ -139,7 +141,7 @@ public class ImportKeysAdapter extends ArrayAdapter { // email if (userIdSplit[1] != null) { holder.mainUserIdRest.setVisibility(View.VISIBLE); - holder.mainUserIdRest.setText(userIdSplit[1]); + holder.mainUserIdRest.setText(highlighter.highlight(userIdSplit[1])); } else { holder.mainUserIdRest.setVisibility(View.GONE); } @@ -182,7 +184,7 @@ public class ImportKeysAdapter extends ArrayAdapter { String uid = it.next(); TextView uidView = (TextView) mInflater.inflate( R.layout.import_keys_list_entry_user_id, null); - uidView.setText(uid); + uidView.setText(highlighter.highlight(uid)); holder.userIdsList.addView(uidView); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Highlighter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Highlighter.java new file mode 100644 index 000000000..eeeacf465 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Highlighter.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2014 Thialfihar + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.util; + +import android.content.Context; +import android.text.Spannable; +import android.text.style.ForegroundColorSpan; + +import org.sufficientlysecure.keychain.R; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Highlighter { + private Context mContext; + private String mQuery; + + public Highlighter(Context context, String query) { + mContext = context; + mQuery = query; + } + + public Spannable highlight(String text) { + Spannable highlight = Spannable.Factory.getInstance().newSpannable(text); + + if (mQuery == null) { + return highlight; + } + + Pattern pattern = Pattern.compile("(?i)(" + mQuery.trim().replaceAll("\\s+", "|") + ")"); + Matcher matcher = pattern.matcher(text); + while (matcher.find()) { + highlight.setSpan( + new ForegroundColorSpan(mContext.getResources().getColor(R.color.emphasis)), + matcher.start(), + matcher.end(), + Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + } + + return highlight; + } +} -- cgit v1.2.3 From 84b754341d1628b542e1382124f3a02989ac7eea Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 14 May 2014 20:52:17 +0200 Subject: Use Highlighter instead of HighlightQueryCursorAdapter --- .../keychain/ui/KeyListFragment.java | 27 +++++---- .../ui/adapter/HighlightQueryCursorAdapter.java | 66 ---------------------- .../ui/adapter/SelectKeyCursorAdapter.java | 14 ++++- 3 files changed, 28 insertions(+), 79 deletions(-) delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/HighlightQueryCursorAdapter.java (limited to 'OpenKeychain/src/main/java') 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 941c95cb0..efaaa579b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -34,6 +34,7 @@ import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; import android.support.v4.view.MenuItemCompat; import android.support.v7.app.ActionBarActivity; +import android.support.v4.widget.CursorAdapter; import android.support.v7.widget.SearchView; import android.text.TextUtils; import android.view.ActionMode; @@ -61,8 +62,8 @@ import org.sufficientlysecure.keychain.helper.ExportHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; -import org.sufficientlysecure.keychain.ui.adapter.HighlightQueryCursorAdapter; import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; +import org.sufficientlysecure.keychain.util.Highlighter; import org.sufficientlysecure.keychain.util.Log; import java.util.Date; @@ -82,7 +83,7 @@ public class KeyListFragment extends LoaderFragment private KeyListAdapter mAdapter; private StickyListHeadersListView mStickyList; - private String mCurQuery; + private String mQuery; private SearchView mSearchView; // empty list layout private BootstrapButton mButtonEmptyCreate; @@ -263,8 +264,8 @@ public class KeyListFragment extends LoaderFragment Uri baseUri = KeyRings.buildUnifiedKeyRingsUri(); String where = null; String whereArgs[] = null; - if (mCurQuery != null) { - String[] words = mCurQuery.trim().split("\\s+"); + if (mQuery != null) { + String[] words = mQuery.trim().split("\\s+"); whereArgs = new String[words.length]; for (int i = 0; i < words.length; ++i) { if (where == null) { @@ -286,7 +287,7 @@ public class KeyListFragment extends LoaderFragment public void onLoadFinished(Loader loader, Cursor data) { // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) - mAdapter.setSearchQuery(mCurQuery); + mAdapter.setSearchQuery(mQuery); mAdapter.swapCursor(data); mStickyList.setAdapter(mAdapter); @@ -388,7 +389,7 @@ public class KeyListFragment extends LoaderFragment @Override public boolean onMenuItemActionCollapse(MenuItem item) { - mCurQuery = null; + mQuery = null; mSearchView.setQuery("", true); getLoaderManager().restartLoader(0, null, KeyListFragment.this); return true; @@ -408,7 +409,7 @@ public class KeyListFragment extends LoaderFragment // Called when the action bar search text has changed. Update // the search filter, and restart the loader to do a new query // with this filter. - mCurQuery = !TextUtils.isEmpty(s) ? s : null; + mQuery = !TextUtils.isEmpty(s) ? s : null; getLoaderManager().restartLoader(0, null, this); return true; } @@ -416,7 +417,8 @@ public class KeyListFragment extends LoaderFragment /** * Implements StickyListHeadersAdapter from library */ - private class KeyListAdapter extends HighlightQueryCursorAdapter implements StickyListHeadersAdapter { + private class KeyListAdapter extends CursorAdapter implements StickyListHeadersAdapter { + private String mQuery; private LayoutInflater mInflater; private HashMap mSelection = new HashMap(); @@ -427,6 +429,10 @@ public class KeyListFragment extends LoaderFragment mInflater = LayoutInflater.from(context); } + public void setSearchQuery(String query) { + mQuery = query; + } + @Override public Cursor swapCursor(Cursor newCursor) { return super.swapCursor(newCursor); @@ -465,18 +471,19 @@ public class KeyListFragment extends LoaderFragment */ @Override public void bindView(View view, Context context, Cursor cursor) { + Highlighter highlighter = new Highlighter(context, mQuery); ItemViewHolder h = (ItemViewHolder) view.getTag(); { // set name and stuff, common to both key types String userId = cursor.getString(INDEX_USER_ID); String[] userIdSplit = PgpKeyHelper.splitUserId(userId); if (userIdSplit[0] != null) { - h.mMainUserId.setText(highlightSearchQuery(userIdSplit[0])); + h.mMainUserId.setText(highlighter.highlight(userIdSplit[0])); } else { h.mMainUserId.setText(R.string.user_id_no_name); } if (userIdSplit[1] != null) { - h.mMainUserIdRest.setText(highlightSearchQuery(userIdSplit[1])); + h.mMainUserIdRest.setText(highlighter.highlight(userIdSplit[1])); h.mMainUserIdRest.setVisibility(View.VISIBLE); } else { h.mMainUserIdRest.setVisibility(View.GONE); 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 deleted file mode 100644 index 4a37a9a3a..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/HighlightQueryCursorAdapter.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2014 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.ui.adapter; - -import android.content.Context; -import android.database.Cursor; -import android.support.v4.widget.CursorAdapter; -import android.text.Spannable; -import android.text.style.ForegroundColorSpan; - -import org.sufficientlysecure.keychain.R; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public abstract class HighlightQueryCursorAdapter extends CursorAdapter { - - private String mCurQuery; - - public HighlightQueryCursorAdapter(Context context, Cursor c, int flags) { - super(context, c, flags); - mCurQuery = null; - } - - public void setSearchQuery(String searchQuery) { - mCurQuery = searchQuery; - } - - public String getSearchQuery() { - return mCurQuery; - } - - protected Spannable highlightSearchQuery(String text) { - Spannable highlight = Spannable.Factory.getInstance().newSpannable(text); - - if (mCurQuery != null) { - Pattern pattern = Pattern.compile("(?i)(" + mCurQuery.trim().replaceAll("\\s+", "|") + ")"); - Matcher matcher = pattern.matcher(text); - while (matcher.find()) { - highlight.setSpan( - new ForegroundColorSpan(mContext.getResources().getColor(R.color.emphasis)), - matcher.start(), - matcher.end(), - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - } - return highlight; - } else { - return highlight; - } - } -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java index cde008175..00cd554b9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java @@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.ui.adapter; import android.content.Context; import android.database.Cursor; +import android.support.v4.widget.CursorAdapter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -29,6 +30,7 @@ import android.widget.TextView; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; +import org.sufficientlysecure.keychain.util.Highlighter; import java.util.Date; @@ -36,8 +38,9 @@ import java.util.Date; /** * Yes this class is abstract! */ -abstract public class SelectKeyCursorAdapter extends HighlightQueryCursorAdapter { +abstract public class SelectKeyCursorAdapter extends CursorAdapter { + private String mQuery; private LayoutInflater mInflater; protected int mIndexUserId, mIndexMasterKeyId, mIndexRevoked, mIndexExpiry; @@ -48,6 +51,10 @@ abstract public class SelectKeyCursorAdapter extends HighlightQueryCursorAdapter initIndex(c); } + public void setSearchQuery(String query) { + mQuery = query; + } + @Override public Cursor swapCursor(Cursor newCursor) { initIndex(newCursor); @@ -101,19 +108,20 @@ abstract public class SelectKeyCursorAdapter extends HighlightQueryCursorAdapter @Override public void bindView(View view, Context context, Cursor cursor) { + Highlighter highlighter = new Highlighter(context, mQuery); ViewHolderItem h = (ViewHolderItem) view.getTag(); String userId = cursor.getString(mIndexUserId); String[] userIdSplit = PgpKeyHelper.splitUserId(userId); if (userIdSplit[0] != null) { - h.mainUserId.setText(highlightSearchQuery(userIdSplit[0])); + h.mainUserId.setText(highlighter.highlight(userIdSplit[0])); } else { h.mainUserId.setText(R.string.user_id_no_name); } if (userIdSplit[1] != null) { h.mainUserIdRest.setVisibility(View.VISIBLE); - h.mainUserIdRest.setText(highlightSearchQuery(userIdSplit[1])); + h.mainUserIdRest.setText(highlighter.highlight(userIdSplit[1])); } else { h.mainUserIdRest.setVisibility(View.GONE); } -- cgit v1.2.3 From 1386282840128529f54572b6dee216cf5c5cf044 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 14 May 2014 20:55:53 +0200 Subject: Rename mCurQuery to mQuery for consistency --- .../keychain/ui/SelectPublicKeyFragment.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenKeychain/src/main/java') 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 25fa698ef..9343b166a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java @@ -55,7 +55,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T private SelectKeyCursorAdapter mAdapter; private EditText mSearchView; private long mSelectedMasterKeyIds[]; - private String mCurQuery; + private String mQuery; // copied from ListFragment static final int INTERNAL_EMPTY_ID = 0x00ff0001; @@ -281,8 +281,8 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T } String where = null; String whereArgs[] = null; - if (mCurQuery != null) { - String[] words = mCurQuery.trim().split("\\s+"); + if (mQuery != null) { + String[] words = mQuery.trim().split("\\s+"); whereArgs = new String[words.length]; for (int i = 0; i < words.length; ++i) { if (where == null) { @@ -304,7 +304,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T public void onLoadFinished(Loader loader, Cursor data) { // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) - mAdapter.setSearchQuery(mCurQuery); + mAdapter.setSearchQuery(mQuery); mAdapter.swapCursor(data); // The list should now be shown. @@ -338,7 +338,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T @Override public void afterTextChanged(Editable editable) { - mCurQuery = !TextUtils.isEmpty(editable.toString()) ? editable.toString() : null; + mQuery = !TextUtils.isEmpty(editable.toString()) ? editable.toString() : null; getLoaderManager().restartLoader(0, null, this); } -- cgit v1.2.3