Search in sources :

Example 46 with SearchView

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;
}
Also used : SearchView(android.widget.SearchView) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) SearchView(android.widget.SearchView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 47 with SearchView

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);
    }
}
Also used : SearchView(android.widget.SearchView) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) SearchView(android.widget.SearchView)

Example 48 with SearchView

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;
}
Also used : SearchView(android.widget.SearchView)

Example 49 with SearchView

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;
}
Also used : ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) SearchView(android.widget.SearchView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Toolbar(android.widget.Toolbar)

Example 50 with SearchView

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);
    }
}
Also used : SearchView(android.widget.SearchView) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) SearchView(android.widget.SearchView)

Aggregations

SearchView (android.widget.SearchView)72 View (android.view.View)37 TextView (android.widget.TextView)30 MenuItem (android.view.MenuItem)28 ImageView (android.widget.ImageView)16 ListView (android.widget.ListView)15 AdapterView (android.widget.AdapterView)14 RecyclerView (android.support.v7.widget.RecyclerView)12 SearchManager (android.app.SearchManager)11 Test (org.junit.Test)8 Activity (android.app.Activity)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 RecyclerView (androidx.recyclerview.widget.RecyclerView)7 SettingsActivity (com.android.settings.SettingsActivity)7 MenuInflater (android.view.MenuInflater)6 ViewGroup (android.view.ViewGroup)6 Toolbar (android.widget.Toolbar)6 Intent (android.content.Intent)4 RoboMenuItem (org.robolectric.fakes.RoboMenuItem)4 Nullable (android.support.annotation.Nullable)3