Merge change 24194 into eclair

* changes:
  Make the hardkeyboard long press dialog look the same as that of soft keyboard.
This commit is contained in:
Android (Google) Code Review
2009-09-08 15:33:50 -07:00
19 changed files with 68 additions and 29 deletions

View File

@@ -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;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -16,10 +16,12 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false"
<item android:state_pressed="false" android:state_focused="false"
android:drawable="@android:drawable/btn_close_normal" />
<item android:state_pressed="true"
android:drawable="@android:drawable/btn_close_pressed" />
<item android:state_focused="true"
android:drawable="@android:drawable/btn_close_selected" />
</selector>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:state_pressed="false"
android:drawable="@drawable/btn_keyboard_key_trans_selected" />
<item android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_trans_pressed" />
<item android:state_pressed="false" android:state_focused="false"
android:drawable="@drawable/btn_keyboard_key_trans_normal" />
</selector>

View File

@@ -15,35 +15,35 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:orientation="horizontal"
android:layout_width="304dp"
android:layout_height="fill_parent">
android:layout_height="fill_parent"
android:background="@drawable/keyboard_popup_panel_trans_background">
<GridView
android:id="@+id/characterPicker"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="4dp"
android:verticalSpacing="4dp"
android:verticalSpacing="8dp"
android:horizontalSpacing="8dp"
android:stretchMode="spacingWidth"
android:gravity="left"
android:drawSelectorOnTop="false"
android:listSelector="@drawable/grid_selector_background"
android:numColumns="4"
android:columnWidth="64dp"
android:columnWidth="48dp"
android:fadingEdge="none"
android:layout_gravity="center_horizontal"
android:layout_gravity="center_vertical"
android:listSelector="#0000"
/>
<Button
android:id="@+id/cancel"
android:text="@string/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="50dp"
android:paddingRight="50dp"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:background="@drawable/btn_close"
android:layout_gravity="center_vertical"
/>
</LinearLayout>

View File

@@ -15,11 +15,12 @@
-->
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:clickable="true"
android:focusable="false"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:textColor="#FF000000"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="@drawable/btn_keyboard_key_trans"
android:textColor="#FFFFFFFF"
/>