/** callback from the suggestion dropdown copy text to input field and stay in edit mode */ @Override public void onCopySuggestion(String text) { mUrlInput.setText(text, true); if (text != null) { mUrlInput.setSelection(text.length()); } }
@Override protected void onFinishInflate() { super.onFinishInflate(); mLockIcon = (ImageView) findViewById(R.id.lock); mFavicon = (ImageView) findViewById(R.id.favicon); mUrlInput = (UrlInputView) findViewById(R.id.url); mUrlInput.setUrlInputListener(this); mUrlInput.setOnFocusChangeListener(this); mUrlInput.setSelectAllOnFocus(true); mUrlInput.addQueryTextWatcher(this); }
@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(); }
/** * called from the Ui when the user wants to edit * * @param clearInput clear the input field */ void startEditingUrl(boolean clearInput) { // editing takes preference of progress setVisibility(View.VISIBLE); if (mTitleBar.useQuickControls()) { mTitleBar.getProgressView().setVisibility(View.GONE); } if (!mUrlInput.hasFocus()) { mUrlInput.requestFocus(); } if (clearInput) { mUrlInput.setText(""); } else if (mInVoiceMode) { mUrlInput.showDropDown(); } }
@Override public void onTextChanged(String newText) { if (mUrlInput.hasFocus()) { // clear voice mode when user types setInVoiceMode(false, null); } }
@Override public boolean dispatchKeyEventPreIme(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.KEYCODE_BACK) { // catch back key in order to do slightly more cleanup than usual mUrlInput.clearFocus(); return true; } return super.dispatchKeyEventPreIme(evt); }
public void setTitleBar(TitleBar titleBar) { mTitleBar = titleBar; mBaseUi = mTitleBar.getUi(); mUiController = mTitleBar.getUiController(); mUrlInput.setController(mUiController); }
void registerDropdownChangeListener(DropdownChangeListener d) { mUrlInput.registerDropdownChangeListener(d); }
void clearCompletions() { mUrlInput.setSuggestedText(null); }
void setIncognitoMode(boolean incognito) { mUrlInput.setIncognitoMode(incognito); }
public void setInVoiceMode(boolean voicemode, List<String> voiceResults) { mInVoiceMode = voicemode; mUrlInput.setVoiceResults(voiceResults); }
void setDisplayTitle(String title) { if (!isEditingUrl()) { mUrlInput.setText(title, false); } }
void stopEditingUrl() { mUrlInput.clearFocus(); }
public boolean isEditingUrl() { return mUrlInput.hasFocus(); }