Search in sources :

Example 31 with SearchView

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

Example 32 with SearchView

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);
}
Also used : SearchView(android.widget.SearchView) MenuInflater(android.view.MenuInflater) MenuItem(android.view.MenuItem) RoboMenuItem(org.robolectric.fakes.RoboMenuItem) Test(org.junit.Test)

Example 33 with SearchView

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);
    }
}
Also used : MenuItem(android.view.MenuItem) TextView(android.widget.TextView) SearchView(android.widget.SearchView) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayout(android.widget.LinearLayout)

Example 34 with SearchView

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);
    }
}
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) RecyclerView(androidx.recyclerview.widget.RecyclerView) SearchView(android.widget.SearchView) TextView(android.widget.TextView)

Example 35 with SearchView

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

Aggregations

SearchView (android.widget.SearchView)67 View (android.view.View)35 TextView (android.widget.TextView)30 MenuItem (android.view.MenuItem)26 ImageView (android.widget.ImageView)16 ListView (android.widget.ListView)15 AdapterView (android.widget.AdapterView)14 RecyclerView (android.support.v7.widget.RecyclerView)13 SearchManager (android.app.SearchManager)11 Activity (android.app.Activity)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 SettingsActivity (com.android.settings.SettingsActivity)7 ViewGroup (android.view.ViewGroup)6 Toolbar (android.widget.Toolbar)6 Intent (android.content.Intent)4 MenuInflater (android.view.MenuInflater)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 Nullable (android.support.annotation.Nullable)3 FragmentActivity (android.support.v4.app.FragmentActivity)3 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)3