use of android.widget.SearchView in project glimmr by brk3.
the class BaseActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
return super.onCreateOptionsMenu(menu);
}
use of android.widget.SearchView in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ManageApplicationsTest method onCreateOptionsMenu_shouldSetSearchQueryListener.
@Test
public void onCreateOptionsMenu_shouldSetSearchQueryListener() {
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.onCreateOptionsMenu(mMenu, mock(MenuInflater.class));
verify(searchView).setOnQueryTextListener(mFragment);
}
use of android.widget.SearchView in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BaseTimeZonePicker method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (mSearchEnabled) {
inflater.inflate(R.menu.time_zone_base_search_menu, menu);
final MenuItem searchMenuItem = menu.findItem(R.id.time_zone_search_menu);
mSearchView = (SearchView) searchMenuItem.getActionView();
mSearchView.setQueryHint(getText(mSearchHintResId));
mSearchView.setOnQueryTextListener(this);
if (mDefaultExpandSearch) {
searchMenuItem.expandActionView();
mSearchView.setIconified(false);
mSearchView.setActivated(true);
mSearchView.setQuery("", true);
}
// Set zero margin and padding to align with the text horizontally in the preference
final TextView searchViewView = (TextView) mSearchView.findViewById(com.android.internal.R.id.search_src_text);
searchViewView.setPadding(0, searchViewView.getPaddingTop(), 0, searchViewView.getPaddingBottom());
final View editFrame = mSearchView.findViewById(com.android.internal.R.id.search_edit_frame);
final LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) editFrame.getLayoutParams();
params.setMarginStart(0);
params.setMarginEnd(0);
editFrame.setLayoutParams(params);
}
}
use of android.widget.SearchView in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PrintServiceSettingsFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.print_service_settings, menu);
MenuItem addPrinters = menu.findItem(R.id.print_menu_item_add_printer);
if (mServiceEnabled && mAddPrintersIntent != null) {
addPrinters.setIntent(mAddPrintersIntent);
} else {
menu.removeItem(R.id.print_menu_item_add_printer);
}
MenuItem settings = menu.findItem(R.id.print_menu_item_settings);
if (mServiceEnabled && mSettingsIntent != null) {
settings.setIntent(mSettingsIntent);
} else {
menu.removeItem(R.id.print_menu_item_settings);
}
MenuItem searchItem = menu.findItem(R.id.print_menu_item_search);
if (mServiceEnabled && mPrintersAdapter.getUnfilteredCount() > 0) {
mSearchView = (SearchView) searchItem.getActionView();
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
@Override
public boolean onQueryTextChange(String searchString) {
mPrintersAdapter.getFilter().filter(searchString);
return true;
}
});
mSearchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View view) {
if (AccessibilityManager.getInstance(getActivity()).isEnabled()) {
view.announceForAccessibility(getString(R.string.print_search_box_shown_utterance));
}
}
@Override
public void onViewDetachedFromWindow(View view) {
Activity activity = getActivity();
if (activity != null && !activity.isFinishing() && AccessibilityManager.getInstance(activity).isEnabled()) {
view.announceForAccessibility(getString(R.string.print_search_box_hidden_utterance));
}
}
});
} else {
menu.removeItem(R.id.print_menu_item_search);
}
}
use of android.widget.SearchView in project Xposed-Tinted-Status-Bar by MohammadAG.
the class ActivitesListActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activites_list, menu);
mSearchItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
mSearchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem menuItem) {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
mNameFilter = query;
mActivityListAdapter.getFilter().filter(mNameFilter);
findViewById(R.id.action_search).clearFocus();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
mNameFilter = newText;
mActivityListAdapter.getFilter().filter(mNameFilter);
return false;
}
});
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
mActivityListAdapter.getFilter().filter("");
return true;
}
});
MenuItem actionSwitch = menu.findItem(R.id.switch_button);
mSwitch = (Switch) actionSwitch.getActionView().findViewById(R.id.color_switch);
if (mSwitch != null) {
mSwitch.setChecked(mSettingsHelper.isEnabled(mPackageName, null));
// Toggle the visibility of the lower panel when changed
mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mDirty = true;
String keyName = SettingsHelper.getKeyName(mPackageName, null, SettingsKeys.IS_ACTIVE);
mSettingsHelper.getSharedPreferences().edit().putBoolean(keyName, isChecked).commit();
mActivityListAdapter.notifyDataSetChanged();
}
});
}
return true;
}
Aggregations