Search in sources :

Example 66 with SearchManager

use of android.app.SearchManager in project platform_frameworks_base by android.

the class PhoneWindow method launchDefaultSearch.

/**
     * Helper method for adding launch-search to most applications. Opens the
     * search window using default settings.
     *
     * @return true if search window opened
     */
private boolean launchDefaultSearch(KeyEvent event) {
    boolean result;
    final Callback cb = getCallback();
    if (cb == null || isDestroyed()) {
        result = false;
    } else {
        sendCloseSystemWindows("search");
        int deviceId = event.getDeviceId();
        SearchEvent searchEvent = null;
        if (deviceId != 0) {
            searchEvent = new SearchEvent(InputDevice.getDevice(deviceId));
        }
        try {
            result = cb.onSearchRequested(searchEvent);
        } catch (AbstractMethodError e) {
            Log.e(TAG, "WindowCallback " + cb.getClass().getName() + " does not implement" + " method onSearchRequested(SearchEvent); fa", e);
            result = cb.onSearchRequested();
        }
    }
    if (!result && (getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_TELEVISION) {
        // On TVs, if the app doesn't implement search, we want to launch assist.
        Bundle args = new Bundle();
        args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, event.getDeviceId());
        return ((SearchManager) getContext().getSystemService(Context.SEARCH_SERVICE)).launchLegacyAssist(null, UserHandle.myUserId(), args);
    }
    return result;
}
Also used : SearchManager(android.app.SearchManager) Bundle(android.os.Bundle) SearchEvent(android.view.SearchEvent)

Example 67 with SearchManager

use of android.app.SearchManager in project weiciyuan by qii.

the class SearchMainParentFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.actionbar_menu_searchmainactivity, menu);
    final SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    searchView.setIconifiedByDefault(false);
    searchView.setSubmitButtonEnabled(false);
    searchView.setMaxWidth(Utility.dip2px(250));
    ThemeUtility.customActionBarSearchViewTextColor(searchView);
    searchView.requestFocus();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

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

        @Override
        public boolean onQueryTextChange(String newText) {
            SearchMainParentFragment.this.q = newText;
            return false;
        }
    });
    searchView.setOnSearchClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            search(q);
        }
    });
    if (!TextUtils.isEmpty(this.q)) {
        searchView.setQuery(this.q, false);
    }
}
Also used : SearchView(android.widget.SearchView) SearchManager(android.app.SearchManager) View(android.view.View) SearchView(android.widget.SearchView) TextView(android.widget.TextView)

Example 68 with SearchManager

use of android.app.SearchManager in project PocketHub by pockethub.

the class IssuesFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu optionsMenu, MenuInflater inflater) {
    inflater.inflate(R.menu.fragment_issues, optionsMenu);
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = optionsMenu.findItem(R.id.m_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    Bundle args = new Bundle();
    args.putParcelable(EXTRA_REPOSITORY, repository);
    searchView.setAppSearchData(args);
}
Also used : SearchView(android.support.v7.widget.SearchView) SearchManager(android.app.SearchManager) Bundle(android.os.Bundle) MenuItem(android.view.MenuItem)

Example 69 with SearchManager

use of android.app.SearchManager in project PocketHub by pockethub.

the class SearchActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu options) {
    getMenuInflater().inflate(R.menu.activity_search, options);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = options.findItem(R.id.m_search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    return true;
}
Also used : SearchManager(android.app.SearchManager) MenuItem(android.view.MenuItem)

Example 70 with SearchManager

use of android.app.SearchManager in project plaid by nickbutcher.

the class SearchActivity method setupSearchView.

private void setupSearchView() {
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    // hint, inputType & ime options seem to be ignored from XML! Set in code
    searchView.setQueryHint(getString(R.string.search_hint));
    searchView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    searchView.setImeOptions(searchView.getImeOptions() | EditorInfo.IME_ACTION_SEARCH | EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_FLAG_NO_FULLSCREEN);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            searchFor(query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            if (TextUtils.isEmpty(query)) {
                clearResults();
            }
            return true;
        }
    });
    searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus && confirmSaveContainer.getVisibility() == View.VISIBLE) {
                hideSaveConfirmation();
            }
        }
    });
}
Also used : SearchView(android.widget.SearchView) SearchManager(android.app.SearchManager) BindView(butterknife.BindView) View(android.view.View) SearchView(android.widget.SearchView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView)

Aggregations

SearchManager (android.app.SearchManager)101 Intent (android.content.Intent)31 ISearchManager (android.app.ISearchManager)26 ActivityNotFoundException (android.content.ActivityNotFoundException)20 ComponentName (android.content.ComponentName)20 Bundle (android.os.Bundle)14 SearchView (android.support.v7.widget.SearchView)14 MenuItem (android.view.MenuItem)14 RecognizerIntent (android.speech.RecognizerIntent)12 UserHandle (android.os.UserHandle)10 View (android.view.View)9 ImageView (android.widget.ImageView)8 SearchView (android.widget.SearchView)8 TextView (android.widget.TextView)8 ActivityOptions (android.app.ActivityOptions)7 LargeTest (android.test.suitebuilder.annotation.LargeTest)6 MenuInflater (android.view.MenuInflater)6 AppWidgetHostView (android.appwidget.AppWidgetHostView)5 PackageManager (android.content.pm.PackageManager)5 ResolveInfo (android.content.pm.ResolveInfo)5