diff options
author | Miroojin Bakshi <gaglu231094@gmail.com> | 2014-03-06 03:37:04 +0530 |
---|---|---|
committer | Miroojin Bakshi <gaglu231094@gmail.com> | 2014-03-06 03:37:04 +0530 |
commit | 7932dd8a81345f4f4cc10a4618c8f0856d9f45d1 (patch) | |
tree | 56688247fca4373138ba9a6ca3ab1d94637055ed /OpenPGP-Keychain/src/main | |
parent | 53f61893018403047c87e3d9618c82e9f03b0c55 (diff) | |
download | open-keychain-7932dd8a81345f4f4cc10a4618c8f0856d9f45d1.tar.gz open-keychain-7932dd8a81345f4f4cc10a4618c8f0856d9f45d1.tar.bz2 open-keychain-7932dd8a81345f4f4cc10a4618c8f0856d9f45d1.zip |
Implement search for SelectPublicKeyFragment
Diffstat (limited to 'OpenPGP-Keychain/src/main')
-rw-r--r-- | OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java | 36 | ||||
-rw-r--r-- | OpenPGP-Keychain/src/main/res/layout/select_public_key_activity.xml | 8 |
2 files changed, 39 insertions, 5 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java index 59b46dd00..e3e5c55fb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java @@ -38,17 +38,22 @@ import android.os.Bundle; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.widget.EditText; import android.widget.ListView; -public class SelectPublicKeyFragment extends ListFragmentWorkaround implements +public class SelectPublicKeyFragment extends ListFragmentWorkaround implements TextWatcher, LoaderManager.LoaderCallbacks<Cursor> { public static final String ARG_PRESELECTED_KEY_IDS = "preselected_key_ids"; private Activity mActivity; private SelectKeyCursorAdapter mAdapter; private ListView mListView; - + private EditText mSearchView; private long mSelectedMasterKeyIds[]; + private String mCurQuery; /** * Creates new instance of this fragment @@ -67,7 +72,8 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + mSearchView = (EditText)getActivity().findViewById(R.id.select_public_key_search); + mSearchView.addTextChangedListener(this); mSelectedMasterKeyIds = getArguments().getLongArray(ARG_PRESELECTED_KEY_IDS); } @@ -82,7 +88,6 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements mListView = getListView(); mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); - // Give some text to display if there is no data. In a real // application this would come from a resource. setEmptyText(getString(R.string.list_empty)); @@ -220,10 +225,14 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements // sort by selected master keys orderBy = inMasterKeyList + " DESC, " + orderBy; } + String where = null; + if(mCurQuery != null) + where = UserIds.USER_ID + " LIKE \"" + mCurQuery + "%\""; + // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. - return new CursorLoader(getActivity(), baseUri, projection, null, null, orderBy); + return new CursorLoader(getActivity(), baseUri, projection, where, null, orderBy); } @Override @@ -250,4 +259,21 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements // longer using it. mAdapter.swapCursor(null); } + + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { + + } + + @Override + public void afterTextChanged(Editable editable) { + String newQuery = !TextUtils.isEmpty(editable.toString()) ? editable.toString() : null; + mCurQuery = newQuery; + getLoaderManager().restartLoader(0, null, this); + } } diff --git a/OpenPGP-Keychain/src/main/res/layout/select_public_key_activity.xml b/OpenPGP-Keychain/src/main/res/layout/select_public_key_activity.xml index a18ce46fc..5337433c6 100644 --- a/OpenPGP-Keychain/src/main/res/layout/select_public_key_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/select_public_key_activity.xml @@ -4,8 +4,16 @@ android:layout_height="match_parent" android:layout_centerHorizontal="true" > + <EditText + android:id="@+id/select_public_key_search" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/menu_search" + android:drawableLeft="@drawable/ic_action_search"/> + <FrameLayout android:id="@+id/select_public_key_fragment_container" + android:layout_below="@id/select_public_key_search" android:layout_width="match_parent" android:layout_height="match_parent" /> |