use of android.widget.SearchView in project android_frameworks_base by DirtyUnicorns.
the class SelectPrinterActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.select_printer_activity, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) searchItem.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
@Override
public boolean onQueryTextChange(String searchString) {
((DestinationAdapter) mListView.getAdapter()).getFilter().filter(searchString);
return true;
}
});
searchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View view) {
if (AccessibilityManager.getInstance(SelectPrinterActivity.this).isEnabled()) {
view.announceForAccessibility(getString(R.string.print_search_box_shown_utterance));
}
}
@Override
public void onViewDetachedFromWindow(View view) {
if (!isFinishing() && AccessibilityManager.getInstance(SelectPrinterActivity.this).isEnabled()) {
view.announceForAccessibility(getString(R.string.print_search_box_hidden_utterance));
}
}
});
return true;
}
use of android.widget.SearchView in project android_packages_apps_Settings by LineageOS.
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 MGit by maks.
the class RepoDetailActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.repo_detail, menu);
mSearchItem = menu.findItem(R.id.action_search);
MenuItemCompat.setOnActionExpandListener(mSearchItem, mTabItemPagerAdapter);
mSearchItem.setVisible(mSelectedTab == COMMITS_FRAGMENT_INDEX);
SearchView searchView = (SearchView) mSearchItem.getActionView();
if (searchView != null) {
searchView.setIconifiedByDefault(true);
searchView.setOnQueryTextListener(mTabItemPagerAdapter);
}
return true;
}
use of android.widget.SearchView in project android_packages_apps_Settings by omnirom.
the class SearchFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.search_panel, container, false);
mResultsRecyclerView = view.findViewById(R.id.list_results);
mResultsRecyclerView.setAdapter(mSearchAdapter);
mResultsRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mResultsRecyclerView.addOnScrollListener(mScrollListener);
mNoResultsView = view.findViewById(R.id.no_results_layout);
Toolbar toolbar = view.findViewById(R.id.search_toolbar);
getActivity().setActionBar(toolbar);
getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
mSearchView = toolbar.findViewById(R.id.search_view);
mSearchView.setQuery(mQuery, false);
mSearchView.setOnQueryTextListener(this);
mSearchView.requestFocus();
// Updating internal views inside SearchView was the easiest way to get this too look right.
// Instead of grabbing the TextView directly, we grab it as a view and do an instanceof
// check. This ensures if we return, say, a LinearLayout in the tests, they won't fail.
View searchText = mSearchView.findViewById(com.android.internal.R.id.search_src_text);
if (searchText instanceof TextView) {
TextView searchTextView = (TextView) searchText;
searchTextView.setTextColor(getContext().getColorStateList(com.android.internal.R.color.text_color_primary));
searchTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.search_bar_text_size));
}
View editFrame = mSearchView.findViewById(com.android.internal.R.id.search_edit_frame);
if (editFrame != null) {
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) editFrame.getLayoutParams();
params.setMarginStart(0);
editFrame.setLayoutParams(params);
}
ActionBarShadowController.attachToRecyclerView(view.findViewById(R.id.search_bar_container), getLifecycle(), mResultsRecyclerView);
return view;
}
use of android.widget.SearchView in project android_packages_apps_Settings by DirtyUnicorns.
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);
}
}
Aggregations