From 38d838d3aef5716c72936b3c0573bc5d4135c02c Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Tue, 8 Sep 2009 14:18:34 -0700 Subject: Make the hardkeyboard long press dialog look the same as that of soft keyboard. New assets for transparent buttons and background. --- .../android/text/method/CharacterPickerDialog.java | 30 +++++++++++++-------- core/res/res/drawable-hdpi/btn_close_normal.png | Bin 1681 -> 1884 bytes core/res/res/drawable-hdpi/btn_close_pressed.png | Bin 2429 -> 2737 bytes core/res/res/drawable-hdpi/btn_close_selected.png | Bin 0 -> 2807 bytes .../btn_keyboard_key_trans_normal.9.png | Bin 0 -> 1200 bytes .../btn_keyboard_key_trans_pressed.9.png | Bin 0 -> 1706 bytes .../btn_keyboard_key_trans_selected.9.png | Bin 0 -> 1730 bytes .../keyboard_popup_panel_trans_background.9.png | Bin 0 -> 1677 bytes core/res/res/drawable-mdpi/btn_close_normal.png | Bin 1213 -> 1259 bytes core/res/res/drawable-mdpi/btn_close_pressed.png | Bin 1585 -> 1726 bytes core/res/res/drawable-mdpi/btn_close_selected.png | Bin 0 -> 1716 bytes .../btn_keyboard_key_trans_normal.9.png | Bin 0 -> 780 bytes .../btn_keyboard_key_trans_pressed.9.png | Bin 0 -> 1018 bytes .../btn_keyboard_key_trans_selected.9.png | Bin 0 -> 1037 bytes .../keyboard_popup_panel_trans_background.9.png | Bin 0 -> 3734 bytes core/res/res/drawable/btn_close.xml | 4 ++- core/res/res/drawable/btn_keyboard_key_trans.xml | 28 +++++++++++++++++++ core/res/res/layout/character_picker.xml | 26 +++++++++--------- core/res/res/layout/character_picker_button.xml | 9 ++++--- 19 files changed, 68 insertions(+), 29 deletions(-) create mode 100644 core/res/res/drawable-hdpi/btn_close_selected.png create mode 100644 core/res/res/drawable-hdpi/btn_keyboard_key_trans_normal.9.png create mode 100644 core/res/res/drawable-hdpi/btn_keyboard_key_trans_pressed.9.png create mode 100644 core/res/res/drawable-hdpi/btn_keyboard_key_trans_selected.9.png create mode 100644 core/res/res/drawable-hdpi/keyboard_popup_panel_trans_background.9.png create mode 100644 core/res/res/drawable-mdpi/btn_close_selected.png create mode 100644 core/res/res/drawable-mdpi/btn_keyboard_key_trans_normal.9.png create mode 100644 core/res/res/drawable-mdpi/btn_keyboard_key_trans_pressed.9.png create mode 100644 core/res/res/drawable-mdpi/btn_keyboard_key_trans_selected.9.png create mode 100644 core/res/res/drawable-mdpi/keyboard_popup_panel_trans_background.9.png create mode 100644 core/res/res/drawable/btn_keyboard_key_trans.xml diff --git a/core/java/android/text/method/CharacterPickerDialog.java b/core/java/android/text/method/CharacterPickerDialog.java index 3c4067511804..880e46daf1aa 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; } diff --git a/core/res/res/drawable-hdpi/btn_close_normal.png b/core/res/res/drawable-hdpi/btn_close_normal.png index df3d56cbbb1f..38b49f1a392c 100644 Binary files a/core/res/res/drawable-hdpi/btn_close_normal.png and b/core/res/res/drawable-hdpi/btn_close_normal.png differ diff --git a/core/res/res/drawable-hdpi/btn_close_pressed.png b/core/res/res/drawable-hdpi/btn_close_pressed.png index ef88fe08662f..aa9ea49f00c5 100644 Binary files a/core/res/res/drawable-hdpi/btn_close_pressed.png and b/core/res/res/drawable-hdpi/btn_close_pressed.png differ diff --git a/core/res/res/drawable-hdpi/btn_close_selected.png b/core/res/res/drawable-hdpi/btn_close_selected.png new file mode 100644 index 000000000000..870c670f7236 Binary files /dev/null and b/core/res/res/drawable-hdpi/btn_close_selected.png differ diff --git a/core/res/res/drawable-hdpi/btn_keyboard_key_trans_normal.9.png b/core/res/res/drawable-hdpi/btn_keyboard_key_trans_normal.9.png new file mode 100644 index 000000000000..9c7e483351ba Binary files /dev/null and b/core/res/res/drawable-hdpi/btn_keyboard_key_trans_normal.9.png differ diff --git a/core/res/res/drawable-hdpi/btn_keyboard_key_trans_pressed.9.png b/core/res/res/drawable-hdpi/btn_keyboard_key_trans_pressed.9.png new file mode 100644 index 000000000000..e01a49db1d42 Binary files /dev/null and b/core/res/res/drawable-hdpi/btn_keyboard_key_trans_pressed.9.png differ diff --git a/core/res/res/drawable-hdpi/btn_keyboard_key_trans_selected.9.png b/core/res/res/drawable-hdpi/btn_keyboard_key_trans_selected.9.png new file mode 100644 index 000000000000..544655e43cb9 Binary files /dev/null and b/core/res/res/drawable-hdpi/btn_keyboard_key_trans_selected.9.png differ diff --git a/core/res/res/drawable-hdpi/keyboard_popup_panel_trans_background.9.png b/core/res/res/drawable-hdpi/keyboard_popup_panel_trans_background.9.png new file mode 100644 index 000000000000..fd7366e20432 Binary files /dev/null and b/core/res/res/drawable-hdpi/keyboard_popup_panel_trans_background.9.png differ diff --git a/core/res/res/drawable-mdpi/btn_close_normal.png b/core/res/res/drawable-mdpi/btn_close_normal.png index ecc4ddee6bc7..4c6e79dc8881 100644 Binary files a/core/res/res/drawable-mdpi/btn_close_normal.png and b/core/res/res/drawable-mdpi/btn_close_normal.png differ diff --git a/core/res/res/drawable-mdpi/btn_close_pressed.png b/core/res/res/drawable-mdpi/btn_close_pressed.png index 49223c54df82..fc983afdcf06 100644 Binary files a/core/res/res/drawable-mdpi/btn_close_pressed.png and b/core/res/res/drawable-mdpi/btn_close_pressed.png differ diff --git a/core/res/res/drawable-mdpi/btn_close_selected.png b/core/res/res/drawable-mdpi/btn_close_selected.png new file mode 100644 index 000000000000..f2bf91a2d716 Binary files /dev/null and b/core/res/res/drawable-mdpi/btn_close_selected.png differ diff --git a/core/res/res/drawable-mdpi/btn_keyboard_key_trans_normal.9.png b/core/res/res/drawable-mdpi/btn_keyboard_key_trans_normal.9.png new file mode 100644 index 000000000000..652c05f6cf12 Binary files /dev/null and b/core/res/res/drawable-mdpi/btn_keyboard_key_trans_normal.9.png differ diff --git a/core/res/res/drawable-mdpi/btn_keyboard_key_trans_pressed.9.png b/core/res/res/drawable-mdpi/btn_keyboard_key_trans_pressed.9.png new file mode 100644 index 000000000000..1d1e9c075c28 Binary files /dev/null and b/core/res/res/drawable-mdpi/btn_keyboard_key_trans_pressed.9.png differ diff --git a/core/res/res/drawable-mdpi/btn_keyboard_key_trans_selected.9.png b/core/res/res/drawable-mdpi/btn_keyboard_key_trans_selected.9.png new file mode 100644 index 000000000000..b168e0c9fc29 Binary files /dev/null and b/core/res/res/drawable-mdpi/btn_keyboard_key_trans_selected.9.png differ diff --git a/core/res/res/drawable-mdpi/keyboard_popup_panel_trans_background.9.png b/core/res/res/drawable-mdpi/keyboard_popup_panel_trans_background.9.png new file mode 100644 index 000000000000..4ba2a4908cb8 Binary files /dev/null and b/core/res/res/drawable-mdpi/keyboard_popup_panel_trans_background.9.png differ diff --git a/core/res/res/drawable/btn_close.xml b/core/res/res/drawable/btn_close.xml index 9d90e4b6eb52..598ab0f4685a 100644 --- a/core/res/res/drawable/btn_close.xml +++ b/core/res/res/drawable/btn_close.xml @@ -16,10 +16,12 @@ - + diff --git a/core/res/res/drawable/btn_keyboard_key_trans.xml b/core/res/res/drawable/btn_keyboard_key_trans.xml new file mode 100644 index 000000000000..970aed759d21 --- /dev/null +++ b/core/res/res/drawable/btn_keyboard_key_trans.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + diff --git a/core/res/res/layout/character_picker.xml b/core/res/res/layout/character_picker.xml index 03448497f5fd..70867d076b00 100644 --- a/core/res/res/layout/character_picker.xml +++ b/core/res/res/layout/character_picker.xml @@ -15,35 +15,35 @@ --> + android:layout_height="fill_parent" + android:background="@drawable/keyboard_popup_panel_trans_background">