Ejemplo n.º 1
0
 /** callback from suggestion dropdown user selected a suggestion */
 @Override
 public void onAction(String text, String extra, String source) {
   mUiController.getCurrentTopWebView().requestFocus();
   if (UrlInputView.TYPED.equals(source)) {
     String url = UrlUtils.smartUrlFilter(text, false);
     Tab t = mBaseUi.getActiveTab();
     // Only shortcut javascript URIs for now, as there is special
     // logic in UrlHandler for other schemas
     if (url != null && t != null && url.startsWith("javascript:")) {
       mUiController.loadUrl(t, url);
       setDisplayTitle(text);
       return;
     }
   }
   Intent i = new Intent();
   String action = null;
   if (UrlInputView.VOICE.equals(source)) {
     action = RecognizerResultsIntent.ACTION_VOICE_SEARCH_RESULTS;
     source = null;
   } else {
     action = Intent.ACTION_SEARCH;
   }
   i.setAction(action);
   i.putExtra(SearchManager.QUERY, text);
   if (extra != null) {
     i.putExtra(SearchManager.EXTRA_DATA_KEY, extra);
   }
   if (source != null) {
     Bundle appData = new Bundle();
     appData.putString(com.android.common.Search.SOURCE, source);
     i.putExtra(SearchManager.APP_DATA, appData);
   }
   mUiController.handleNewIntent(i);
   setDisplayTitle(text);
 }
Ejemplo n.º 2
0
 @Override
 public void onFocusChange(View view, boolean hasFocus) {
   // if losing focus and not in touch mode, leave as is
   if (hasFocus || view.isInTouchMode() || mUrlInput.needsUpdate()) {
     setFocusState(hasFocus);
   }
   if (hasFocus) {
     mBaseUi.showTitleBar();
     mUrlInput.forceIme();
     if (mInVoiceMode) {
       mUrlInput.forceFilter();
     }
   } else if (!mUrlInput.needsUpdate()) {
     mUrlInput.dismissDropDown();
     mUrlInput.hideIME();
     if (mUrlInput.getText().length() == 0) {
       Tab currentTab = mUiController.getTabControl().getCurrentTab();
       if (currentTab != null) {
         setDisplayTitle(currentTab.getUrl());
       }
     }
     mBaseUi.suggestHideTitleBar();
   }
   mUrlInput.clearNeedsUpdate();
 }