Merge change 24220 into eclair
* changes:
Import revised translations. DO NOT MERGE
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.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 @@
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 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 @@
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 @@
* 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 df3d56c..38b49f1 100644
--- a/core/res/res/drawable-hdpi/btn_close_normal.png
+++ b/core/res/res/drawable-hdpi/btn_close_normal.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_close_pressed.png b/core/res/res/drawable-hdpi/btn_close_pressed.png
index ef88fe0..aa9ea49f0 100644
--- a/core/res/res/drawable-hdpi/btn_close_pressed.png
+++ b/core/res/res/drawable-hdpi/btn_close_pressed.png
Binary files 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 0000000..870c670
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_close_selected.png
Binary files 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 0000000..9c7e483
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_keyboard_key_trans_normal.9.png
Binary files 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 0000000..e01a49d
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_keyboard_key_trans_pressed.9.png
Binary files 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 0000000..544655e
--- /dev/null
+++ b/core/res/res/drawable-hdpi/btn_keyboard_key_trans_selected.9.png
Binary files 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 0000000..fd7366e
--- /dev/null
+++ b/core/res/res/drawable-hdpi/keyboard_popup_panel_trans_background.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_close_normal.png b/core/res/res/drawable-mdpi/btn_close_normal.png
index ecc4dde..4c6e79d 100644
--- a/core/res/res/drawable-mdpi/btn_close_normal.png
+++ b/core/res/res/drawable-mdpi/btn_close_normal.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_close_pressed.png b/core/res/res/drawable-mdpi/btn_close_pressed.png
index 49223c5..fc983af 100644
--- a/core/res/res/drawable-mdpi/btn_close_pressed.png
+++ b/core/res/res/drawable-mdpi/btn_close_pressed.png
Binary files 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 0000000..f2bf91a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_close_selected.png
Binary files 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 0000000..652c05f
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_keyboard_key_trans_normal.9.png
Binary files 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 0000000..1d1e9c0
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_keyboard_key_trans_pressed.9.png
Binary files 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 0000000..b168e0c
--- /dev/null
+++ b/core/res/res/drawable-mdpi/btn_keyboard_key_trans_selected.9.png
Binary files 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 0000000..4ba2a49
--- /dev/null
+++ b/core/res/res/drawable-mdpi/keyboard_popup_panel_trans_background.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_close.xml b/core/res/res/drawable/btn_close.xml
index 9d90e4b..598ab0f 100644
--- a/core/res/res/drawable/btn_close.xml
+++ b/core/res/res/drawable/btn_close.xml
@@ -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>
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 0000000..970aed7
--- /dev/null
+++ b/core/res/res/drawable/btn_keyboard_key_trans.xml
@@ -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>
diff --git a/core/res/res/layout/character_picker.xml b/core/res/res/layout/character_picker.xml
index 0344849..70867d0 100644
--- a/core/res/res/layout/character_picker.xml
+++ b/core/res/res/layout/character_picker.xml
@@ -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>
diff --git a/core/res/res/layout/character_picker_button.xml b/core/res/res/layout/character_picker_button.xml
index 40078fe..b74e620 100644
--- a/core/res/res/layout/character_picker_button.xml
+++ b/core/res/res/layout/character_picker_button.xml
@@ -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"
/>
diff --git a/tests/LowStorageTest/Android.mk b/tests/LowStorageTest/Android.mk
new file mode 100644
index 0000000..ab5b9e9
--- /dev/null
+++ b/tests/LowStorageTest/Android.mk
@@ -0,0 +1,25 @@
+# Copyright (C) 2009 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.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+LOCAL_CERTIFICATE := platform
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := lowstoragetest
+
+include $(BUILD_PACKAGE)
diff --git a/tests/LowStorageTest/AndroidManifest.xml b/tests/LowStorageTest/AndroidManifest.xml
new file mode 100644
index 0000000..9d4a63ac
--- /dev/null
+++ b/tests/LowStorageTest/AndroidManifest.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.lowstoragetest">
+ <application android:label="LowStorageTest">
+ <activity android:name="LowStorageTest"
+ android:theme="@android:style/Theme.Black.NoTitleBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
\ No newline at end of file
diff --git a/tests/LowStorageTest/res/layout/main.xml b/tests/LowStorageTest/res/layout/main.xml
new file mode 100644
index 0000000..cc99102
--- /dev/null
+++ b/tests/LowStorageTest/res/layout/main.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:stretchColumns="1">
+
+ <TextView
+ android:text="@string/total_storage"
+ android:gravity="left"
+ android:padding="3dip" />
+
+ <TextView
+ android:id="@+id/totalsize"
+ android:gravity="left"
+ android:padding="3dip" />
+
+ <View
+ android:layout_height="2dip"
+ android:background="#FF909090" />
+
+ <TextView
+ android:layout_column="1"
+ android:gravity="left"
+ android:text="@string/available_storage"
+ android:padding="3dip" />
+
+ <TextView
+ android:id="@+id/freesize"
+ android:gravity="left"
+ android:padding="3dip" />
+
+ <TextView
+ android:layout_column="1"
+ android:gravity="left"
+ android:textSize="18sp"
+ android:text="@string/status"
+ android:padding="3dip" />
+
+ <TextView
+ android:layout_column="1"
+ android:gravity="left"
+ android:textSize="18sp"
+ android:id="@+id/status"
+ android:text="@string/eat_up_storage"
+ android:padding="3dip" />
+
+ <View
+ android:layout_height="2dip"
+ android:background="#FF909090" />
+
+ <Button
+ android:id="@+id/button_run"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/run_text"
+ android:layout_alignParentRight="true" />
+
+</TableLayout>
\ No newline at end of file
diff --git a/tests/LowStorageTest/res/values/strings.xml b/tests/LowStorageTest/res/values/strings.xml
new file mode 100644
index 0000000..93d9876
--- /dev/null
+++ b/tests/LowStorageTest/res/values/strings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="total_storage">"Total Storage Size ..."</string>
+ <string name="available_storage">"Available Storage Size ..."</string>
+ <string name="eat_up_storage">"Please Wait..."</string>
+ <string name="status">"Status"</string>
+ <string name="run_text">"Start"</string>
+</resources>
diff --git a/tests/LowStorageTest/src/com/android/lowstoragetest/LowStorageTest.java b/tests/LowStorageTest/src/com/android/lowstoragetest/LowStorageTest.java
new file mode 100644
index 0000000..9f297aa
--- /dev/null
+++ b/tests/LowStorageTest/src/com/android/lowstoragetest/LowStorageTest.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+package com.android.lowstoragetest;
+
+import android.app.Activity;
+import android.content.Context;
+
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.StatFs;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import java.io.File;
+import java.io.FileOutputStream;
+import android.widget.TextView;
+import android.widget.Button;
+
+public class LowStorageTest extends Activity {
+ static final String TAG = "DiskFullTest";
+ static final long WAIT_FOR_FINISH = 5 * 60 * 60;
+ static final int NO_OF_BLOCKS_TO_FILL = 1000;
+ static final int BYTE_SIZE = 1024;
+ static final int WAIT_FOR_SYSTEM_UPDATE = 10000;
+
+ private int mBlockSize = 0;
+ private final Object fillUpDone = new Object();
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ setContentView(R.layout.main);
+
+ // Update the current data info
+ File path = Environment.getDataDirectory();
+ StatFs stat = new StatFs(path.getPath());
+ int totalBlocks = stat.getBlockCount();
+ mBlockSize = (int) (stat.getBlockSize());
+ TextView startSizeTextView = (TextView) findViewById(R.id.totalsize);
+ startSizeTextView.setText(Long.toString((totalBlocks * mBlockSize) / BYTE_SIZE));
+ Button button = (Button) findViewById(R.id.button_run);
+ button.setOnClickListener(mStartListener);
+ }
+
+ View.OnClickListener mStartListener = new OnClickListener() {
+ public void onClick(View v) {
+ fillDataAndUpdateInfo();
+ }
+ };
+
+ public void fillDataAndUpdateInfo() {
+ updateInfo(this);
+ }
+
+ // Fill up 100% of the data partition
+ public void fillupdisk(Context context) {
+ final Context contextfill = context;
+ new Thread() {
+ @Override
+ public void run() {
+ try {
+ // Fill up all the memory
+ File path = Environment.getDataDirectory();
+ StatFs stat = new StatFs(path.getPath());
+ int totalBlocks = stat.getBlockCount();
+ int noOfBlockToFill = stat.getAvailableBlocks();
+ FileOutputStream fs =
+ contextfill.openFileOutput("testdata", Context.MODE_APPEND);
+ for (int i = 0; i < (noOfBlockToFill / NO_OF_BLOCKS_TO_FILL); i++) {
+ byte buf[] = new byte[mBlockSize * NO_OF_BLOCKS_TO_FILL];
+ fs.write(buf);
+ fs.flush();
+ }
+
+ // Fill up the last few block
+ byte buf[] = new byte[(noOfBlockToFill % NO_OF_BLOCKS_TO_FILL) * mBlockSize];
+ fs.write(buf);
+ fs.flush();
+ fs.close();
+
+ // Finished, update the info
+ synchronized (fillUpDone) {
+ fillUpDone.notify();
+ }
+ } catch (Exception e) {
+ Log.v(TAG, e.toString());
+ }
+ }
+ }.start();
+ }
+
+ public void updateInfo(Context context) {
+ fillupdisk(this);
+ synchronized (fillUpDone) {
+ try {
+ fillUpDone.wait(WAIT_FOR_FINISH);
+ } catch (Exception e) {
+ Log.v(TAG, "wait was interrupted.");
+ }
+ }
+ try {
+ // The stat didn't relect the correct data right away
+ // put some extra time to make sure if get the right size.
+ Thread.sleep(WAIT_FOR_SYSTEM_UPDATE);
+ File path = Environment.getDataDirectory();
+ StatFs stat = new StatFs(path.getPath());
+ long availableBlocks = stat.getAvailableBlocks();
+ TextView freeSizeTextView = (TextView) findViewById(R.id.freesize);
+ freeSizeTextView.setText(Long.toString((availableBlocks * mBlockSize) / BYTE_SIZE));
+ TextView statusTextView = (TextView) findViewById(R.id.status);
+ statusTextView.setText("Finished. You can start the test now.");
+ } catch (Exception e) {
+ Log.v(TAG, e.toString());
+ }
+ }
+}