diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-01-20 14:03:58 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-01-20 14:03:58 -0800 |
commit | 22f7dfd23490a3de2f21ff96949ba47003aac8f8 (patch) | |
tree | 41bc290bb2f1f08a0e37cfda4955742a85d42ecf /core/java/android/webkit/TextDialog.java | |
parent | 9266c558bf1d21ff647525ff99f7dadbca417309 (diff) | |
download | frameworks_base-22f7dfd23490a3de2f21ff96949ba47003aac8f8.zip frameworks_base-22f7dfd23490a3de2f21ff96949ba47003aac8f8.tar.gz frameworks_base-22f7dfd23490a3de2f21ff96949ba47003aac8f8.tar.bz2 |
auto import from //branches/cupcake/...@127101
Diffstat (limited to 'core/java/android/webkit/TextDialog.java')
-rw-r--r-- | core/java/android/webkit/TextDialog.java | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/core/java/android/webkit/TextDialog.java b/core/java/android/webkit/TextDialog.java index 30b519a..b7b40b1 100644 --- a/core/java/android/webkit/TextDialog.java +++ b/core/java/android/webkit/TextDialog.java @@ -38,13 +38,20 @@ import android.text.method.MovementMethod; import android.text.method.PasswordTransformationMethod; import android.text.method.TextKeyListener; import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; import android.view.View.MeasureSpec; import android.view.ViewConfiguration; import android.widget.AbsoluteLayout.LayoutParams; +import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; +import android.widget.TextView; + +import java.util.ArrayList; /** * TextDialog is a specialized version of EditText used by WebView @@ -281,7 +288,7 @@ import android.widget.AutoCompleteTextView; } return false; } - + /** * Determine whether this TextDialog currently represents the node * represented by ptr. @@ -406,6 +413,9 @@ import android.widget.AutoCompleteTextView; * focus to the host. */ /* package */ void remove() { + // hide the soft keyboard when the edit text is out of focus + InputMethodManager.getInstance(mContext).hideSoftInputFromWindow( + getWindowToken(), 0); mHandler.removeMessages(LONGPRESS); mWebView.removeView(this); mWebView.requestFocus(); @@ -427,6 +437,43 @@ import android.widget.AutoCompleteTextView; mWebView.passToJavaScript(getText().toString(), event); } + public void setAdapterCustom(AutoCompleteAdapter adapter) { + adapter.setTextView(this); + super.setAdapter(adapter); + } + + /** + * This is a special version of ArrayAdapter which changes its text size + * to match the text size of its host TextView. + */ + public static class AutoCompleteAdapter extends ArrayAdapter<String> { + private TextView mTextView; + + public AutoCompleteAdapter(Context context, ArrayList<String> entries) { + super(context, com.android.internal.R.layout + .search_dropdown_item_1line, entries); + } + + /** + * {@inheritDoc} + */ + public View getView(int position, View convertView, ViewGroup parent) { + TextView tv = + (TextView) super.getView(position, convertView, parent); + if (tv != null && mTextView != null) { + tv.setTextSize(mTextView.getTextSize()); + } + return tv; + } + + /** + * Set the TextView so we can match its text size. + */ + private void setTextView(TextView tv) { + mTextView = tv; + } + } + /** * Determine whether to use the system-wide password disguising method, * or to use none. |