protected void refineSuggestion(SuggestionsAdapter<?> adapter, long id) { if (DBG) Log.d(TAG, "query refine clicked, pos " + id); SuggestionPosition suggestion = getCurrentSuggestions(adapter, id); if (suggestion == null) { return; } String query = suggestion.getSuggestionQuery(); if (TextUtils.isEmpty(query)) { return; } // Log refine click getLogger() .logSuggestionClick( id, suggestion.getCursor(), getCurrentIncludedCorpora(), Logger.SUGGESTION_CLICK_TYPE_REFINE); // Put query + space in query text view String queryWithSpace = query + ' '; setQuery(queryWithSpace, false); updateSuggestions(); mSearchActivityView.focusQueryTextView(); }
@Override protected void onStop() { if (DBG) Log.d(TAG, "onStop()"); if (!mTookAction) { // TODO: This gets logged when starting other activities, e.g. by opening the search // settings, or clicking a notification in the status bar. // TODO we should log both sets of suggestions in 2-pane mode getLogger().logExit(getCurrentSuggestions(), getQuery().length()); } // Close all open suggestion cursors. The query will be redone in onResume() // if we come back to this activity. mSearchActivityView.clearSuggestions(); getQsbApplication().getShortcutRefresher().reset(); mSearchActivityView.onStop(); super.onStop(); }
@Override protected void onResume() { if (DBG) Log.d(TAG, "onResume()"); super.onResume(); updateSuggestionsBuffered(); mSearchActivityView.onResume(); if (mTraceStartUp) Debug.stopMethodTracing(); }
@Override protected void onDestroy() { if (DBG) Log.d(TAG, "onDestroy()"); getCorpora().unregisterDataSetObserver(mCorporaObserver); mSearchActivityView.destroy(); super.onDestroy(); if (mDestroyListener != null) { mDestroyListener.onDestroyed(); } }
protected void launchIntent(Intent intent) { if (DBG) Log.d(TAG, "launchIntent " + intent); if (intent == null) { return; } try { startActivity(intent); mSearchActivityView.considerHidingInputMethod(); } catch (RuntimeException ex) { // Since the intents for suggestions specified by suggestion providers, // guard against them not being handled, not allowed, etc. Log.e(TAG, "Failed to start " + intent.toUri(0), ex); } }
private void setupFromIntent(Intent intent) { if (DBG) Log.d(TAG, "setupFromIntent(" + intent.toUri(0) + ")"); String corpusName = getCorpusNameFromUri(intent.getData()); String query = intent.getStringExtra(SearchManager.QUERY); Bundle appSearchData = intent.getBundleExtra(SearchManager.APP_DATA); boolean selectAll = intent.getBooleanExtra(SearchManager.EXTRA_SELECT_QUERY, false); setCorpus(corpusName); setQuery(query, selectAll); mAppSearchData = appSearchData; if (startedIntoCorpusSelectionDialog()) { mSearchActivityView.showCorpusSelectionDialog(); } }
protected Set<Corpus> getCurrentIncludedCorpora() { Suggestions suggestions = mSearchActivityView.getSuggestions(); return suggestions == null ? null : suggestions.getIncludedCorpora(); }
protected SuggestionCursor getCurrentSuggestions() { return mSearchActivityView.getCurrentPromotedSuggestions(); }
protected Corpus getSearchCorpus() { return mSearchActivityView.getSearchCorpus(); }
protected void setQuery(String query, boolean selectAll) { mSearchActivityView.setQuery(query, selectAll); }
@Override protected void onPause() { if (DBG) Log.d(TAG, "onPause()"); mSearchActivityView.onPause(); super.onPause(); }
private void setCorpus(String name) { mSearchActivityView.setCorpus(name); }
private String getCorpusName() { return mSearchActivityView.getCorpusName(); }
private Corpus getCorpus() { return mSearchActivityView.getCorpus(); }
protected void showSuggestions(Suggestions suggestions) { mSearchActivityView.setSuggestions(suggestions); }
protected String getQuery() { return mSearchActivityView.getQuery(); }
public void run() { mSearchActivityView.showInputMethodForQuery(); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { mTraceStartUp = getIntent().hasExtra(INTENT_EXTRA_TRACE_START_UP); if (mTraceStartUp) { String traceFile = new File(getDir("traces", 0), "qsb-start.trace").getAbsolutePath(); Log.i(TAG, "Writing start-up trace to " + traceFile); Debug.startMethodTracing(traceFile); } recordStartTime(); if (DBG) Log.d(TAG, "onCreate()"); super.onCreate(savedInstanceState); // This forces the HTTP request to check the users domain to be // sent as early as possible. QsbApplication.get(this).getSearchBaseUrlHelper(); mSearchActivityView = setupContentView(); if (getConfig().showScrollingSuggestions()) { mSearchActivityView.setMaxPromotedSuggestions(getConfig().getMaxPromotedSuggestions()); } else { mSearchActivityView.limitSuggestionsToViewHeight(); } if (getConfig().showScrollingResults()) { mSearchActivityView.setMaxPromotedResults(getConfig().getMaxPromotedResults()); } else { mSearchActivityView.limitResultsToViewHeight(); } mSearchActivityView.setSearchClickListener( new SearchActivityView.SearchClickListener() { public boolean onSearchClicked(int method) { return SearchActivity.this.onSearchClicked(method); } }); mSearchActivityView.setQueryListener( new SearchActivityView.QueryListener() { public void onQueryChanged() { updateSuggestionsBuffered(); } }); mSearchActivityView.setSuggestionClickListener(new ClickHandler()); mSearchActivityView.setVoiceSearchButtonClickListener( new View.OnClickListener() { public void onClick(View view) { onVoiceSearchClicked(); } }); View.OnClickListener finishOnClick = new View.OnClickListener() { public void onClick(View v) { finish(); } }; mSearchActivityView.setExitClickListener(finishOnClick); // First get setup from intent Intent intent = getIntent(); setupFromIntent(intent); // Then restore any saved instance state restoreInstanceState(savedInstanceState); // Do this at the end, to avoid updating the list view when setSource() // is called. mSearchActivityView.start(); mCorporaObserver = new CorporaObserver(); getCorpora().registerDataSetObserver(mCorporaObserver); recordOnCreateDone(); }