Fields Summary |
---|
private android.webkit.WebView | mWebView |
private android.widget.TextView | mMatches |
private BrowserActivity | mBrowserActivity |
private android.view.View | mOk |
private android.widget.EditText | mEditText |
private android.view.View | mNextButton |
private android.view.View | mPrevButton |
private android.view.View | mMatchesView |
private View.OnClickListener | mFindListener |
private View.OnClickListener | mFindCancelListener |
private View.OnClickListener | mFindPreviousListener |
Methods Summary |
---|
public void | afterTextChanged(android.text.Editable s)
|
public void | beforeTextChanged(java.lang.CharSequence s, int start, int count, int after)
|
private void | disableButtons()
mPrevButton.setEnabled(false);
mNextButton.setEnabled(false);
mPrevButton.setFocusable(false);
mNextButton.setFocusable(false);
|
public void | dismiss()
super.dismiss();
mBrowserActivity.closeFind();
mWebView.clearMatches();
|
public boolean | dispatchKeyEvent(android.view.KeyEvent event)
int code = event.getKeyCode();
boolean up = event.getAction() == KeyEvent.ACTION_UP;
switch (code) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
if (!mEditText.hasFocus()) {
break;
}
if (up) {
findNext();
}
return true;
default:
break;
}
return super.dispatchKeyEvent(event);
|
private void | findNext()
if (mWebView == null) {
throw new AssertionError("No WebView for FindDialog::findNext");
}
mWebView.findNext(true);
hideSoftInput();
|
private void | hideSoftInput()
/*
* Remove the soft keyboard from the screen.
*/
InputMethodManager imm = (InputMethodManager)
mBrowserActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
|
void | onConfigurationChanged(android.content.res.Configuration newConfig)
// FIXME: Would like to call mWebView.findAll again, so that the
// matches would refresh, but the new picture has not yet been
// created, so it is too soon.
mEditText.getText().clear();
|
protected void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
Window theWindow = getWindow();
theWindow.setGravity(Gravity.BOTTOM|Gravity.FILL_HORIZONTAL);
setContentView(R.layout.browser_find);
theWindow.setLayout(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
mEditText = (EditText) findViewById(R.id.edit);
View button = findViewById(R.id.next);
button.setOnClickListener(mFindListener);
mNextButton = button;
button = findViewById(R.id.previous);
button.setOnClickListener(mFindPreviousListener);
mPrevButton = button;
button = findViewById(R.id.done);
button.setOnClickListener(mFindCancelListener);
mOk = button;
mMatches = (TextView) findViewById(R.id.matches);
mMatchesView = findViewById(R.id.matches_view);
disableButtons();
theWindow.setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
public void | onTextChanged(java.lang.CharSequence s, int start, int before, int count)
if (mWebView == null) {
throw new AssertionError(
"No WebView for FindDialog::onTextChanged");
}
CharSequence find = mEditText.getText();
if (0 == find.length()) {
disableButtons();
mWebView.clearMatches();
mMatchesView.setVisibility(View.INVISIBLE);
} else {
mMatchesView.setVisibility(View.VISIBLE);
int found = mWebView.findAll(find.toString());
setMatchesFound(found);
if (found < 2) {
disableButtons();
if (found == 0) {
setMatchesFound(0);
}
} else {
mPrevButton.setFocusable(true);
mNextButton.setFocusable(true);
mPrevButton.setEnabled(true);
mNextButton.setEnabled(true);
}
}
|
private void | setMatchesFound(int found)
String template = mBrowserActivity.getResources().
getQuantityString(R.plurals.matches_found, found, found);
mMatches.setText(template);
|
void | setWebView(android.webkit.WebView webview)
mWebView = webview;
|
public void | show()
super.show();
mEditText.requestFocus();
mEditText.setText("");
Spannable span = (Spannable) mEditText.getText();
span.setSpan(this, 0, span.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
setMatchesFound(0);
disableButtons();
|