use of android.widget.SearchView in project YalpStore by yeriomin.
the class BaseActivity method addQueryTextListener.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void addQueryTextListener(MenuItem searchItem) {
SearchView searchView = (SearchView) searchItem.getActionView();
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (null != searchManager) {
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setQueryHint(getString(R.string.search_title));
}
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String query) {
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
Intent i = new Intent(BaseActivity.this, SearchActivity.class);
i.setAction(Intent.ACTION_SEARCH);
i.putExtra(SearchManager.QUERY, query);
startActivity(i);
return false;
}
});
}
use of android.widget.SearchView in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ManageApplicationsTest method onCreateOptionsMenu_hasExpandSearchFlag_shouldExpandSearchView.
@Test
public void onCreateOptionsMenu_hasExpandSearchFlag_shouldExpandSearchView() {
final SearchView searchView = mock(SearchView.class);
final MenuItem searchMenu = mock(MenuItem.class);
final MenuItem helpMenu = mock(MenuItem.class);
when(searchMenu.getActionView()).thenReturn(searchView);
when(mMenu.findItem(R.id.search_app_list_menu)).thenReturn(searchMenu);
when(mMenu.add(anyInt(), /* groupId */
anyInt(), /* itemId */
anyInt(), /* order */
anyInt())).thenReturn(helpMenu);
doReturn("Test").when(mFragment).getText(anyInt());
doNothing().when(mFragment).updateOptionsMenu();
mFragment.mExpandSearch = true;
mFragment.onCreateOptionsMenu(mMenu, mock(MenuInflater.class));
verify(searchMenu).expandActionView();
}
use of android.widget.SearchView in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ManageApplicationsTest method onRebuildComplete_hasSearchQuery_shouldFilterSearch.
@Test
public void onRebuildComplete_hasSearchQuery_shouldFilterSearch() {
final String query = "Test";
final RecyclerView recyclerView = mock(RecyclerView.class);
final View emptyView = mock(View.class);
ReflectionHelpers.setField(mFragment, "mRecyclerView", recyclerView);
ReflectionHelpers.setField(mFragment, "mEmptyView", emptyView);
final SearchView searchView = mock(SearchView.class);
ReflectionHelpers.setField(mFragment, "mSearchView", searchView);
when(searchView.isVisibleToUser()).thenReturn(true);
when(searchView.getQuery()).thenReturn(query);
final View listContainer = mock(View.class);
when(listContainer.getVisibility()).thenReturn(View.VISIBLE);
ReflectionHelpers.setField(mFragment, "mListContainer", listContainer);
ReflectionHelpers.setField(mFragment, "mFilterAdapter", mock(ManageApplications.FilterSpinnerAdapter.class));
final ArrayList<ApplicationsState.AppEntry> appList = new ArrayList<>();
appList.add(mock(ApplicationsState.AppEntry.class));
final ManageApplications.ApplicationsAdapter adapter = spy(new ManageApplications.ApplicationsAdapter(mState, mFragment, AppFilterRegistry.getInstance().get(FILTER_APPS_ALL), null));
adapter.onRebuildComplete(appList);
verify(adapter).filterSearch(query);
}
use of android.widget.SearchView in project glimmr by brk3.
the class BaseFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
inflater.inflate(R.menu.fragment_main_menu, menu);
SearchManager searchManager = (SearchManager) mActivity.getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(mActivity.getComponentName()));
if (mOAuth == null || mOAuth.getUser() == null) {
menu.findItem(R.id.menu_login).setVisible(true);
menu.findItem(R.id.menu_logout).setVisible(false);
} else {
menu.findItem(R.id.menu_login).setVisible(false);
menu.findItem(R.id.menu_logout).setVisible(true);
}
}
use of android.widget.SearchView in project android_packages_apps_Settings by omnirom.
the class ManageApplicationsTest method onSaveInstanceState_searchViewSet_shouldSetBundleValue.
@Test
public void onSaveInstanceState_searchViewSet_shouldSetBundleValue() {
final SearchView searchView = mock(SearchView.class);
final Bundle bundle = new Bundle();
ReflectionHelpers.setField(mFragment, "mResetAppsHelper", mock(ResetAppsHelper.class));
ReflectionHelpers.setField(mFragment, "mFilter", mock(AppFilterItem.class));
ReflectionHelpers.setField(mFragment, "mApplications", mock(ManageApplications.ApplicationsAdapter.class));
ReflectionHelpers.setField(mFragment, "mSearchView", searchView);
when(searchView.isIconified()).thenReturn(true);
mFragment.onSaveInstanceState(bundle);
assertThat(bundle.containsKey(ManageApplications.EXTRA_EXPAND_SEARCH_VIEW)).isTrue();
assertThat(bundle.getBoolean(ManageApplications.EXTRA_EXPAND_SEARCH_VIEW)).isFalse();
}
Aggregations