Search in sources :

Example 36 with SearchView

use of android.support.v7.widget.SearchView in project AntennaPod by AntennaPod.

the class SearchListFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    // parent already inflated menu
    MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
    MenuItemUtils.adjustTextColor(getActivity(), sv);
    sv.setQueryHint(getString(R.string.gpodnet_search_hint));
    sv.setQuery(query, false);
    sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            sv.clearFocus();
            changeQuery(s);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Example 37 with SearchView

use of android.support.v7.widget.SearchView in project materialistic by hidroh.

the class FavoriteFragment method createSearchView.

private void createSearchView(MenuItem menuSearch) {
    final SearchView searchView = (SearchView) mActionViewResolver.getActionView(menuSearch);
    searchView.setQueryHint(getString(R.string.hint_search_saved_stories));
    searchView.setSearchableInfo(((SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE)).getSearchableInfo(getActivity().getComponentName()));
    searchView.setIconified(!mSearchViewExpanded);
    searchView.setQuery(mFilter, false);
    searchView.setOnSearchClickListener(v -> {
        mSearchViewExpanded = true;
        v.requestFocus();
    });
    searchView.setOnCloseListener(() -> {
        // trigger a dummy empty search intent, as empty query does not get submitted
        searchView.setQuery(FavoriteActivity.EMPTY_QUERY, true);
        return false;
    });
}
Also used : SearchView(android.support.v7.widget.SearchView)

Example 38 with SearchView

use of android.support.v7.widget.SearchView in project materialistic by hidroh.

the class BaseListActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (mIsMultiPane) {
        getMenuInflater().inflate(R.menu.menu_item_compact, menu);
    }
    if (isSearchable()) {
        getMenuInflater().inflate(R.menu.menu_search, menu);
        MenuItem menuSearch = menu.findItem(R.id.menu_search);
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView = (SearchView) mActionViewResolver.getActionView(menuSearch);
        searchView.setSearchableInfo(searchManager.getSearchableInfo(new ComponentName(this, SearchActivity.class)));
        searchView.setIconified(true);
        searchView.setQuery("", false);
    }
    return super.onCreateOptionsMenu(menu);
}
Also used : SearchView(android.support.v7.widget.SearchView) SearchManager(android.app.SearchManager) MenuItem(android.view.MenuItem) ComponentName(android.content.ComponentName)

Example 39 with SearchView

use of android.support.v7.widget.SearchView in project Lightning-Browser by anthonycr.

the class BrowserActivity method initialize.

private synchronized void initialize(Bundle savedInstanceState) {
    initializeToolbarHeight(getResources().getConfiguration());
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getSupportActionBar();
    //TODO make sure dark theme flag gets set correctly
    mDarkTheme = mPreferences.getUseTheme() != 0 || isIncognito();
    mIconColor = mDarkTheme ? ThemeUtils.getIconDarkThemeColor(this) : ThemeUtils.getIconLightThemeColor(this);
    mDisabledIconColor = mDarkTheme ? ContextCompat.getColor(this, R.color.icon_dark_theme_disabled) : ContextCompat.getColor(this, R.color.icon_light_theme_disabled);
    mShowTabsInDrawer = mPreferences.getShowTabsInDrawer(!isTablet());
    mSwapBookmarksAndTabs = mPreferences.getBookmarksAndTabsSwapped();
    // initialize background ColorDrawable
    int primaryColor = ThemeUtils.getPrimaryColor(this);
    mBackground.setColor(primaryColor);
    // Drawer stutters otherwise
    mDrawerLeft.setLayerType(View.LAYER_TYPE_NONE, null);
    mDrawerRight.setLayerType(View.LAYER_TYPE_NONE, null);
    mDrawerLayout.addDrawerListener(new DrawerListener() {

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
        }

        @Override
        public void onDrawerOpened(View drawerView) {
        }

        @Override
        public void onDrawerClosed(View drawerView) {
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            if (newState == DrawerLayout.STATE_DRAGGING) {
                mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null);
                mDrawerRight.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            } else if (newState == DrawerLayout.STATE_IDLE) {
                mDrawerLeft.setLayerType(View.LAYER_TYPE_NONE, null);
                mDrawerRight.setLayerType(View.LAYER_TYPE_NONE, null);
            }
        }
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !mShowTabsInDrawer) {
        getWindow().setStatusBarColor(Color.BLACK);
    }
    setNavigationDrawerWidth();
    mDrawerLayout.addDrawerListener(new DrawerLocker());
    mWebpageBitmap = ThemeUtils.getThemedBitmap(this, R.drawable.ic_webpage, mDarkTheme);
    final FragmentManager fragmentManager = getSupportFragmentManager();
    TabsFragment tabsFragment = (TabsFragment) fragmentManager.findFragmentByTag(TAG_TABS_FRAGMENT);
    BookmarksFragment bookmarksFragment = (BookmarksFragment) fragmentManager.findFragmentByTag(TAG_BOOKMARK_FRAGMENT);
    if (tabsFragment != null) {
        fragmentManager.beginTransaction().remove(tabsFragment).commit();
    }
    tabsFragment = TabsFragment.createTabsFragment(isIncognito(), mShowTabsInDrawer);
    mTabsView = tabsFragment;
    if (bookmarksFragment != null) {
        fragmentManager.beginTransaction().remove(bookmarksFragment).commit();
    }
    bookmarksFragment = BookmarksFragment.createFragment(isIncognito());
    mBookmarksView = bookmarksFragment;
    fragmentManager.executePendingTransactions();
    fragmentManager.beginTransaction().replace(getTabsFragmentViewId(), tabsFragment, TAG_TABS_FRAGMENT).replace(getBookmarksFragmentViewId(), bookmarksFragment, TAG_BOOKMARK_FRAGMENT).commit();
    if (mShowTabsInDrawer) {
        mToolbarLayout.removeView(findViewById(R.id.tabs_toolbar_container));
    }
    Preconditions.checkNonNull(actionBar);
    // set display options of the ActionBar
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(R.layout.toolbar_content);
    View customView = actionBar.getCustomView();
    LayoutParams lp = customView.getLayoutParams();
    lp.width = LayoutParams.MATCH_PARENT;
    lp.height = LayoutParams.MATCH_PARENT;
    customView.setLayoutParams(lp);
    mArrowImage = (ImageView) customView.findViewById(R.id.arrow);
    FrameLayout arrowButton = (FrameLayout) customView.findViewById(R.id.arrow_button);
    if (mShowTabsInDrawer) {
        if (mArrowImage.getWidth() <= 0) {
            mArrowImage.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        }
        updateTabNumber(0);
        // Post drawer locking in case the activity is being recreated
        Handlers.MAIN.post(new Runnable() {

            @Override
            public void run() {
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, getTabDrawer());
            }
        });
    } else {
        // Post drawer locking in case the activity is being recreated
        Handlers.MAIN.post(new Runnable() {

            @Override
            public void run() {
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, getTabDrawer());
            }
        });
        mArrowImage.setImageResource(R.drawable.ic_action_home);
        mArrowImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
    }
    // Post drawer locking in case the activity is being recreated
    Handlers.MAIN.post(new Runnable() {

        @Override
        public void run() {
            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, getBookmarkDrawer());
        }
    });
    arrowButton.setOnClickListener(this);
    // create the search EditText in the ToolBar
    mSearch = (SearchView) customView.findViewById(R.id.search);
    mSearchBackground = customView.findViewById(R.id.search_container);
    // initialize search background color
    mSearchBackground.getBackground().setColorFilter(getSearchBarColor(primaryColor, primaryColor), PorterDuff.Mode.SRC_IN);
    mSearch.setHintTextColor(ThemeUtils.getThemedTextHintColor(mDarkTheme));
    mSearch.setTextColor(mDarkTheme ? Color.WHITE : Color.BLACK);
    mUntitledTitle = getString(R.string.untitled);
    mBackgroundColor = ThemeUtils.getPrimaryColor(this);
    mDeleteIcon = ThemeUtils.getThemedDrawable(this, R.drawable.ic_action_delete, mDarkTheme);
    mRefreshIcon = ThemeUtils.getThemedDrawable(this, R.drawable.ic_action_refresh, mDarkTheme);
    mClearIcon = ThemeUtils.getThemedDrawable(this, R.drawable.ic_action_delete, mDarkTheme);
    int iconBounds = Utils.dpToPx(24);
    mDeleteIcon.setBounds(0, 0, iconBounds, iconBounds);
    mRefreshIcon.setBounds(0, 0, iconBounds, iconBounds);
    mClearIcon.setBounds(0, 0, iconBounds, iconBounds);
    mIcon = mRefreshIcon;
    SearchListenerClass search = new SearchListenerClass();
    mSearch.setCompoundDrawablePadding(Utils.dpToPx(3));
    mSearch.setCompoundDrawables(null, null, mRefreshIcon, null);
    mSearch.setOnKeyListener(search);
    mSearch.setOnFocusChangeListener(search);
    mSearch.setOnEditorActionListener(search);
    mSearch.setOnTouchListener(search);
    mSearch.setOnPreFocusListener(search);
    initializeSearchSuggestions(mSearch);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_left_shadow, GravityCompat.START);
    if (API <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        //noinspection deprecation
        WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
    }
    @SuppressWarnings("VariableNotUsedInsideIf") Intent intent = savedInstanceState == null ? getIntent() : null;
    boolean launchedFromHistory = intent != null && (intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0;
    if (isPanicTrigger(intent)) {
        setIntent(null);
        panicClean();
    } else {
        if (launchedFromHistory) {
            intent = null;
        }
        mPresenter.setupTabs(intent);
        setIntent(null);
        mProxyUtils.checkForProxy(this);
    }
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) TabsFragment(acr.browser.lightning.fragment.TabsFragment) Intent(android.content.Intent) ImageView(android.widget.ImageView) BookmarksView(acr.browser.lightning.browser.BookmarksView) BrowserView(acr.browser.lightning.browser.BrowserView) SearchView(acr.browser.lightning.view.SearchView) AutoCompleteTextView(android.widget.AutoCompleteTextView) LightningView(acr.browser.lightning.view.LightningView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) VideoView(android.widget.VideoView) TabsView(acr.browser.lightning.browser.TabsView) DrawerListener(android.support.v4.widget.DrawerLayout.DrawerListener) FragmentManager(android.support.v4.app.FragmentManager) BookmarksFragment(acr.browser.lightning.fragment.BookmarksFragment) FrameLayout(android.widget.FrameLayout) ActionBar(android.support.v7.app.ActionBar)

Example 40 with SearchView

use of android.support.v7.widget.SearchView in project WordPress-Android by wordpress-mobile.

the class ReaderBlogFragment method onCreateOptionsMenu.

/*
     * note this will only be called for followed blogs
     */
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.reader_subs, menu);
    MenuItem searchMenu = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) searchMenu.getActionView();
    searchView.setQueryHint(getString(R.string.reader_hint_search_followed_sites));
    MenuItemCompat.setOnActionExpandListener(searchMenu, new MenuItemCompat.OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            return true;
        }
    });
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            setSearchFilter(query);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            // by ignoring the next search performed after recreation
            if (mIgnoreNextSearch) {
                mIgnoreNextSearch = false;
                AppLog.i(AppLog.T.READER, "reader subs > ignoring search");
            } else {
                setSearchFilter(newText);
            }
            return false;
        }
    });
    // make sure the search view is expanded and reflects the current filter
    if (!TextUtils.isEmpty(mSearchFilter)) {
        searchMenu.expandActionView();
        searchView.clearFocus();
        searchView.setQuery(mSearchFilter, false);
    }
}
Also used : MenuItemCompat(android.support.v4.view.MenuItemCompat) SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Aggregations

SearchView (android.support.v7.widget.SearchView)74 MenuItem (android.view.MenuItem)47 View (android.view.View)24 SearchManager (android.app.SearchManager)13 MenuItemCompat (android.support.v4.view.MenuItemCompat)13 TextView (android.widget.TextView)13 RecyclerView (android.support.v7.widget.RecyclerView)12 MenuInflater (android.view.MenuInflater)11 ImageView (android.widget.ImageView)11 Toolbar (android.support.v7.widget.Toolbar)9 ListView (android.widget.ListView)8 AdapterView (android.widget.AdapterView)7 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)7 Nullable (android.support.annotation.Nullable)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 SuppressLint (android.annotation.SuppressLint)5 ActionBar (android.support.v7.app.ActionBar)5 ArrayList (java.util.ArrayList)5 Button (android.widget.Button)4 List (java.util.List)4