Source:
public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.card_browser, menu); mSaveSearchItem = menu.findItem(R.id.action_save_search); mSaveSearchItem.setVisible(false); mMySearchesItem = menu.findItem(R.id.action_list_my_searches); JSONObject savedFiltersObj = getCol().getConf().optJSONObject("savedFilters"); mMySearchesItem.setVisible(savedFiltersObj != null && savedFiltersObj.length() > 0); mSearchItem = menu.findItem(R.id.action_search); MenuItemCompat.setOnActionExpandListener(mSearchItem, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { mSearchTerms = ""; mSearchView.setQuery(mSearchTerms, false); searchCards(); return true; } }); mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem); mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { mSaveSearchItem.setVisible(!TextUtils.isEmpty(newText)); return true; } @Override public boolean onQueryTextSubmit(String query) { onSearch(); mSearchView.clearFocus(); return true; } }); mSearchView.setOnSearchClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mSearchView.setQuery(mSearchTerms, false); } }); Intent intent = getIntent(); Compat compat = CompatHelper.getCompat(); if (intent.getAction() == compat.ACTION_PROCESS_TEXT) { CharSequence search = intent.getCharSequenceExtra(compat.EXTRA_PROCESS_TEXT); assert search != null; if (search.length() != 0) { Timber.d("CardBrowser :: Called with search intent", search); mSearchView.setQuery(search, true); } } return super.onCreateOptionsMenu(menu); }

Target:
public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.card_browser, menu); mSaveSearchItem = menu.findItem(R.id.action_save_search); mSaveSearchItem.setVisible(false); mMySearchesItem = menu.findItem(R.id.action_list_my_searches); JSONObject savedFiltersObj = getCol().getConf().optJSONObject("savedFilters"); mMySearchesItem.setVisible(savedFiltersObj != null && savedFiltersObj.length() > 0); mSearchItem = menu.findItem(R.id.action_search); MenuItemCompat.setOnActionExpandListener(mSearchItem, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { mSearchTerms = ""; mSearchView.setQuery(mSearchTerms, false); searchCards(); return true; } }); mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem); mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { mSaveSearchItem.setVisible(!TextUtils.isEmpty(newText)); return true; } @Override public boolean onQueryTextSubmit(String query) { onSearch(); mSearchView.clearFocus(); return true; } }); mSearchView.setOnSearchClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mSearchView.setQuery(mSearchTerms, false); } }); Intent intent = getIntent(); Compat compat = CompatHelper.getCompat(); if (intent.getAction() == compat.ACTION_PROCESS_TEXT) { CharSequence search = intent.getCharSequenceExtra(compat.EXTRA_PROCESS_TEXT); if (search != null && search.length() != 0) { Timber.d("CardBrowser :: Called with search intent: %s", search.toString()); mSearchView.setQuery(search, true); } } return super.onCreateOptionsMenu(menu); }