From 953d3ed8d7dcaf211d3e470681d2a01accce1db5 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Mon, 29 Dec 2014 19:58:11 +1100 Subject: [PATCH] Added search functionality to "add apps to swap" screen. This was present in the old local repo implementation, and the skeleton code for implementing it was copied to the swap fragment. The only change neccesary was to add a search button to the menu and make it have a SearchView as its action view. --- F-Droid/res/menu/swap_next_search.xml | 14 ++++++++++++++ .../fdroid/views/swap/SelectAppsFragment.java | 13 ++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 F-Droid/res/menu/swap_next_search.xml diff --git a/F-Droid/res/menu/swap_next_search.xml b/F-Droid/res/menu/swap_next_search.xml new file mode 100644 index 000000000..2c2a3f042 --- /dev/null +++ b/F-Droid/res/menu/swap_next_search.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/F-Droid/src/org/fdroid/fdroid/views/swap/SelectAppsFragment.java b/F-Droid/src/org/fdroid/fdroid/views/swap/SelectAppsFragment.java index 22d445727..294606fad 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/swap/SelectAppsFragment.java +++ b/F-Droid/src/org/fdroid/fdroid/views/swap/SelectAppsFragment.java @@ -10,6 +10,7 @@ import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.SimpleCursorAdapter; +import android.support.v7.widget.SearchView; import android.text.TextUtils; import android.view.ActionMode; import android.view.ContextThemeWrapper; @@ -20,7 +21,6 @@ import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; -import android.widget.SearchView; import android.widget.TextView; import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.R; @@ -36,7 +36,6 @@ public class SelectAppsFragment extends ThemeableListFragment private PackageManager packageManager; private Drawable defaultAppIcon; - private ActionMode mActionMode = null; private String mCurrentFilterString; private Set previouslySelectedApps = new HashSet(); @@ -52,10 +51,18 @@ public class SelectAppsFragment extends ThemeableListFragment @Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { - menuInflater.inflate(R.menu.swap_next, menu); + menuInflater.inflate(R.menu.swap_next_search, menu); MenuItem nextMenuItem = menu.findItem(R.id.action_next); int flags = MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT; MenuItemCompat.setShowAsAction(nextMenuItem, flags); + + SearchView searchView = new SearchView(getActivity()); + + MenuItem searchMenuItem = menu.findItem(R.id.action_search); + MenuItemCompat.setActionView(searchMenuItem, searchView); + MenuItemCompat.setShowAsAction(searchMenuItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); + + searchView.setOnQueryTextListener(this); } @Override