diff options
author | Amith Yamasani <yamasani@google.com> | 2009-09-08 14:18:34 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2009-09-08 14:25:25 -0700 |
commit | 38d838d3aef5716c72936b3c0573bc5d4135c02c (patch) | |
tree | 9cdeb4add916c2cc733aa5334d88139cab4631eb /core/java/android | |
parent | 1ab3ebad95e6b537719ee2f608c1fbc321e51f06 (diff) | |
download | frameworks_base-38d838d3aef5716c72936b3c0573bc5d4135c02c.zip frameworks_base-38d838d3aef5716c72936b3c0573bc5d4135c02c.tar.gz frameworks_base-38d838d3aef5716c72936b3c0573bc5d4135c02c.tar.bz2 |
Make the hardkeyboard long press dialog look the same as that of soft keyboard.
New assets for transparent buttons and background.
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/text/method/CharacterPickerDialog.java | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/core/java/android/text/method/CharacterPickerDialog.java b/core/java/android/text/method/CharacterPickerDialog.java index 3c406751..880e46d 100644 --- a/core/java/android/text/method/CharacterPickerDialog.java +++ b/core/java/android/text/method/CharacterPickerDialog.java @@ -25,15 +25,14 @@ import android.text.*; import android.view.LayoutInflater; import android.view.View.OnClickListener; import android.view.View; -import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup; +import android.view.Window; import android.view.WindowManager; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.GridView; -import android.widget.TextView; /** * Dialog for choosing accented characters related to a base character. @@ -45,6 +44,7 @@ public class CharacterPickerDialog extends Dialog private String mOptions; private boolean mInsert; private LayoutInflater mInflater; + private Button mCancelButton; /** * Creates a new CharacterPickerDialog that presents the specified @@ -54,7 +54,7 @@ public class CharacterPickerDialog extends Dialog public CharacterPickerDialog(Context context, View view, Editable text, String options, boolean insert) { - super(context); + super(context, com.android.internal.R.style.Theme_Panel); mView = view; mText = text; @@ -70,28 +70,32 @@ public class CharacterPickerDialog extends Dialog WindowManager.LayoutParams params = getWindow().getAttributes(); params.token = mView.getApplicationWindowToken(); params.type = params.TYPE_APPLICATION_ATTACHED_DIALOG; + params.flags = params.flags | Window.FEATURE_NO_TITLE; - setTitle(R.string.select_character); setContentView(R.layout.character_picker); GridView grid = (GridView) findViewById(R.id.characterPicker); grid.setAdapter(new OptionsAdapter(getContext())); grid.setOnItemClickListener(this); - findViewById(R.id.cancel).setOnClickListener(this); + mCancelButton = (Button) findViewById(R.id.cancel); + mCancelButton.setOnClickListener(this); } /** * Handles clicks on the character buttons. */ public void onItemClick(AdapterView parent, View view, int position, long id) { - int selEnd = Selection.getSelectionEnd(mText); String result = String.valueOf(mOptions.charAt(position)); + replaceCharacterAndClose(result); + } + private void replaceCharacterAndClose(CharSequence replace) { + int selEnd = Selection.getSelectionEnd(mText); if (mInsert || selEnd == 0) { - mText.insert(selEnd, result); + mText.insert(selEnd, replace); } else { - mText.replace(selEnd - 1, selEnd, result); + mText.replace(selEnd - 1, selEnd, replace); } dismiss(); @@ -101,21 +105,25 @@ public class CharacterPickerDialog extends Dialog * Handles clicks on the Cancel button. */ public void onClick(View v) { - dismiss(); + if (v == mCancelButton) { + dismiss(); + } else if (v instanceof Button) { + CharSequence result = ((Button) v).getText(); + replaceCharacterAndClose(result); + } } private class OptionsAdapter extends BaseAdapter { - private Context mContext; public OptionsAdapter(Context context) { super(); - mContext = context; } public View getView(int position, View convertView, ViewGroup parent) { Button b = (Button) mInflater.inflate(R.layout.character_picker_button, null); b.setText(String.valueOf(mOptions.charAt(position))); + b.setOnClickListener(CharacterPickerDialog.this); return b; } |