summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/AndroidTests/src/com/android/unit_tests/AppCacheTest.java82
-rw-r--r--tests/AndroidTests/src/com/android/unit_tests/BluetoothTest.java21
-rw-r--r--tests/FrameworkTest/res/layout/remote_view_test_good.xml9
-rw-r--r--tests/FrameworkTest/tests/src/com/android/frameworktest/view/RemoteViewsActivityTest.java2
-rw-r--r--tests/GadgetHost/AndroidManifest.xml4
-rw-r--r--tests/GadgetHost/res/xml/gadget_info.xml7
-rw-r--r--tests/GadgetHost/src/com/android/gadgethost/GadgetHostActivity.java3
-rw-r--r--tests/GadgetHost/src/com/android/gadgethost/GadgetPickActivity.java17
-rwxr-xr-xtests/ImfTest/Android.mk15
-rwxr-xr-xtests/ImfTest/AndroidManifest.xml24
-rwxr-xr-xtests/ImfTest/res/layout/sample_edit_text.xml53
-rwxr-xr-xtests/ImfTest/res/values/strings.xml39
-rw-r--r--tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java52
-rwxr-xr-xtests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java140
14 files changed, 438 insertions, 30 deletions
diff --git a/tests/AndroidTests/src/com/android/unit_tests/AppCacheTest.java b/tests/AndroidTests/src/com/android/unit_tests/AppCacheTest.java
index 914d98b..6a9ac86 100755
--- a/tests/AndroidTests/src/com/android/unit_tests/AppCacheTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/AppCacheTest.java
@@ -21,7 +21,12 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageDataObserver;
import android.content.pm.IPackageStatsObserver;
@@ -33,12 +38,13 @@ import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.Suppress;
import android.util.Log;
+import android.os.Handler;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.StatFs;
public class AppCacheTest extends AndroidTestCase {
- private static final boolean localLOGV = false;
+ private static final boolean localLOGV = true;
public static final String TAG="AppCacheTest";
public final long MAX_WAIT_TIME=60*1000;
public final long WAIT_TIME_INCR=10*1000;
@@ -471,12 +477,11 @@ public class AppCacheTest extends AndroidTestCase {
boolean invokePMFreeApplicationCache(long idealStorageSize) throws Exception {
try {
-
String packageName = mContext.getPackageName();
PackageDataObserver observer = new PackageDataObserver();
//wait on observer
synchronized(observer) {
- getPm().freeApplicationCache(idealStorageSize, observer);
+ getPm().freeStorageAndNotify(idealStorageSize, observer);
long waitTime = 0;
while(!observer.isDone() || (waitTime > MAX_WAIT_TIME)) {
observer.wait(WAIT_TIME_INCR);
@@ -495,6 +500,31 @@ public class AppCacheTest extends AndroidTestCase {
return false;
}
}
+
+ boolean invokePMFreeStorage(long idealStorageSize, FreeStorageReceiver r,
+ PendingIntent pi) throws Exception {
+ try {
+ // Spin lock waiting for call back
+ synchronized(r) {
+ getPm().freeStorage(idealStorageSize, pi);
+ long waitTime = 0;
+ while(!r.isDone() && (waitTime < MAX_WAIT_TIME)) {
+ r.wait(WAIT_TIME_INCR);
+ waitTime += WAIT_TIME_INCR;
+ }
+ if(!r.isDone()) {
+ throw new Exception("timed out waiting for call back from PendingIntent");
+ }
+ }
+ return r.getResultCode() == 1;
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to get handle for PackageManger Exception: "+e);
+ return false;
+ } catch (InterruptedException e) {
+ Log.w(TAG, "InterruptedException :"+e);
+ return false;
+ }
+ }
@LargeTest
public void testDeleteAppCacheFiles() throws Exception {
@@ -563,6 +593,52 @@ public class AppCacheTest extends AndroidTestCase {
", cache="+stats.cacheSize);
}
+ class FreeStorageReceiver extends BroadcastReceiver {
+ public static final String ACTION_FREE = "com.android.unit_tests.testcallback";
+ private boolean doneFlag = false;
+
+ public boolean isDone() {
+ return doneFlag;
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if(intent.getAction().equalsIgnoreCase(ACTION_FREE)) {
+ if (localLOGV) Log.i(TAG, "Got notification: clear cache succeeded "+getResultCode());
+ synchronized (this) {
+ doneFlag = true;
+ notifyAll();
+ }
+ }
+ }
+ }
+
+ @SmallTest
+ public void testFreeStorage() throws Exception {
+ StatFs st = new StatFs("/data");
+ long blks1 = getFreeStorageBlks(st);
+ if(localLOGV) Log.i(TAG, "Available free blocks="+blks1);
+ long availableMem = getFreeStorageSize(st);
+ File cacheDir = mContext.getCacheDir();
+ assertNotNull(cacheDir);
+ createTestFiles1(cacheDir, "testtmpdir", 5);
+ long blks2 = getFreeStorageBlks(st);
+ if(localLOGV) Log.i(TAG, "Available blocks after writing test files in application cache="+blks2);
+ // Create receiver and register it
+ FreeStorageReceiver receiver = new FreeStorageReceiver();
+ mContext.registerReceiver(receiver, new IntentFilter(FreeStorageReceiver.ACTION_FREE));
+ PendingIntent pi = PendingIntent.getBroadcast(mContext,
+ 0, new Intent(FreeStorageReceiver.ACTION_FREE), 0);
+ // Invoke PackageManager api
+ invokePMFreeStorage(availableMem, receiver, pi);
+ long blks3 = getFreeStorageBlks(st);
+ if(localLOGV) Log.i(TAG, "Available blocks after freeing cache"+blks3);
+ assertEquals(receiver.getResultCode(), 1);
+ mContext.unregisterReceiver(receiver);
+ // Verify result
+ verifyTestFiles1(cacheDir, "testtmpdir", 5);
+ }
+
/* utility method used to create observer and check async call back from PackageManager.
* ClearApplicationUserData
*/
diff --git a/tests/AndroidTests/src/com/android/unit_tests/BluetoothTest.java b/tests/AndroidTests/src/com/android/unit_tests/BluetoothTest.java
index 48a02c4..21fb94b 100644
--- a/tests/AndroidTests/src/com/android/unit_tests/BluetoothTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/BluetoothTest.java
@@ -234,30 +234,18 @@ public class BluetoothTest extends AndroidTestCase {
}
Log.i(TAG, "onEnableResult(" + result + ")");
}
- public void onCreateBondingResult(String device, int res) {
- String result = "unknown";
- switch (res) {
- case BluetoothDevice.RESULT_SUCCESS:
- result = "success";
- break;
- case BluetoothDevice.RESULT_FAILURE:
- result = "FAILURE";
- break;
- }
- Log.i(TAG, "onEnableResult(" + device + ", " + result + ")");
- }
public void onGetRemoteServiceChannelResult(String device, int channel) {}
};
@SmallTest
- public void testCreateBondingWithCallback() throws Exception {
+ public void testCreateBond() throws Exception {
BluetoothDevice device =
(BluetoothDevice)getContext().getSystemService(Context.BLUETOOTH_SERVICE);
if (device == null) {
Log.i(TAG, "Device not Bluetooth capable, skipping test");
return;
}
- if (!device.createBonding("01:23:45:67:89:AB", mCallback)) {
+ if (!device.createBond("01:23:45:67:89:AB")) {
Log.e(TAG, "createBonding() failed");
}
}
@@ -286,7 +274,7 @@ public class BluetoothTest extends AndroidTestCase {
Log.i(TAG, "Device not Bluetooth capable, skipping test");
return;
}
- String[] addresses = device.listBondings();
+ String[] addresses = device.listBonds();
if (addresses == null) {
Log.i(TAG, "Bluetooth disabled");
return;
@@ -363,8 +351,7 @@ public class BluetoothTest extends AndroidTestCase {
filter.addAction(BluetoothIntent.REMOTE_NAME_FAILED_ACTION);
filter.addAction(BluetoothIntent.REMOTE_ALIAS_CHANGED_ACTION);
filter.addAction(BluetoothIntent.REMOTE_ALIAS_CLEARED_ACTION);
- filter.addAction(BluetoothIntent.BONDING_CREATED_ACTION);
- filter.addAction(BluetoothIntent.BONDING_REMOVED_ACTION);
+ filter.addAction(BluetoothIntent.BOND_STATE_CHANGED_ACTION);
filter.addAction(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION);
getContext().registerReceiver(
(BroadcastReceiver)new BluetoothIntentReceiver(), filter);
diff --git a/tests/FrameworkTest/res/layout/remote_view_test_good.xml b/tests/FrameworkTest/res/layout/remote_view_test_good.xml
index 92ff21c..54f4db9 100644
--- a/tests/FrameworkTest/res/layout/remote_view_test_good.xml
+++ b/tests/FrameworkTest/res/layout/remote_view_test_good.xml
@@ -47,4 +47,13 @@
<ProgressBar android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
+
+ <ImageButton android:id="@+id/image_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <Button android:id="@+id/button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
</LinearLayout>
diff --git a/tests/FrameworkTest/tests/src/com/android/frameworktest/view/RemoteViewsActivityTest.java b/tests/FrameworkTest/tests/src/com/android/frameworktest/view/RemoteViewsActivityTest.java
index 5f63178..3dcb252 100644
--- a/tests/FrameworkTest/tests/src/com/android/frameworktest/view/RemoteViewsActivityTest.java
+++ b/tests/FrameworkTest/tests/src/com/android/frameworktest/view/RemoteViewsActivityTest.java
@@ -62,6 +62,8 @@ public class RemoteViewsActivityTest extends ActivityInstrumentationTestCase<Rem
assertTrue("RelateiveLayout not inflated", result.findViewById(R.id.relative) != null);
assertTrue("AbsoluteLayout not inflated", result.findViewById(R.id.absolute) != null);
assertTrue("ProgressBar not inflated", result.findViewById(R.id.progress) != null);
+ assertTrue("ImageButton not inflated", result.findViewById(R.id.image_button) != null);
+ assertTrue("Button not inflated", result.findViewById(R.id.button) != null);
}
@MediumTest
diff --git a/tests/GadgetHost/AndroidManifest.xml b/tests/GadgetHost/AndroidManifest.xml
index 8da4485..eeb8979 100644
--- a/tests/GadgetHost/AndroidManifest.xml
+++ b/tests/GadgetHost/AndroidManifest.xml
@@ -17,6 +17,10 @@
</intent-filter>
</activity>
<receiver android:name="TestGadgetProvider">
+ <intent-filter>
+ <action android:name="android.gadget.action.GADGET_UPDATE" />
+ </intent-filter>
+ <meta-data android:name="android.gadget.provider" android:resource="@xml/gadget_info" />
</receiver>
</application>
</manifest>
diff --git a/tests/GadgetHost/res/xml/gadget_info.xml b/tests/GadgetHost/res/xml/gadget_info.xml
new file mode 100644
index 0000000..84d0603
--- /dev/null
+++ b/tests/GadgetHost/res/xml/gadget_info.xml
@@ -0,0 +1,7 @@
+<gadget-provider xmlns:android="http://schemas.android.com/apk/res/android"
+ android:minWidth="40dp"
+ android:minHeight="30dp"
+ android:updatePeriodMillis="30000"
+ android:initialLayout="@layout/test_gadget"
+ >
+</gadget-provider>
diff --git a/tests/GadgetHost/src/com/android/gadgethost/GadgetHostActivity.java b/tests/GadgetHost/src/com/android/gadgethost/GadgetHostActivity.java
index 323141e..38073fa 100644
--- a/tests/GadgetHost/src/com/android/gadgethost/GadgetHostActivity.java
+++ b/tests/GadgetHost/src/com/android/gadgethost/GadgetHostActivity.java
@@ -81,9 +81,6 @@ public class GadgetHostActivity extends Activity
}
void addGadgetView(int gadgetId, GadgetInfo gadget) {
- // TODO: Remove this hard-coded value when the GadgetInfo is real.
- gadget.initialLayout = R.layout.test_gadget;
-
// Inflate the gadget's RemoteViews
GadgetHostView view = mHost.createView(this, gadgetId, gadget);
diff --git a/tests/GadgetHost/src/com/android/gadgethost/GadgetPickActivity.java b/tests/GadgetHost/src/com/android/gadgethost/GadgetPickActivity.java
index e8b3121..a995544 100644
--- a/tests/GadgetHost/src/com/android/gadgethost/GadgetPickActivity.java
+++ b/tests/GadgetHost/src/com/android/gadgethost/GadgetPickActivity.java
@@ -27,11 +27,14 @@ import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.util.Log;
+import java.util.List;
+
public class GadgetPickActivity extends ListActivity
{
private static final String TAG = "GadgetPickActivity";
GadgetManager mGadgetManager;
+ List<GadgetInfo> mInstalled;
public GadgetPickActivity() {
mGadgetManager = GadgetManager.getInstance(this);
@@ -43,9 +46,12 @@ public class GadgetPickActivity extends ListActivity
Bundle extras = getIntent().getExtras();
- String[] labels = new String[10];
- for (int i=0; i<labels.length; i++) {
- labels[i] = "Gadget " + (i+1);
+ List<GadgetInfo> installed = mGadgetManager.getInstalledProviders();
+ mInstalled = installed;
+ final int N = installed.size();
+ String[] labels = new String[N];
+ for (int i=0; i<N; i++) {
+ labels[i] = installed.get(i).provider.getClassName();
}
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, labels));
@@ -54,11 +60,8 @@ public class GadgetPickActivity extends ListActivity
@Override
public void onListItemClick(ListView l, View v, int position, long id)
{
- Log.d(TAG, "Clicked item " + position);
-
int gadgetId = mGadgetManager.allocateGadgetId(getCallingPackage());
- mGadgetManager.bindGadgetId(gadgetId, new ComponentName(
- "com.android.gadgethost", "com.android.gadgethost.TestGadgetProvider"));
+ mGadgetManager.bindGadgetId(gadgetId, mInstalled.get(position).provider);
Intent result = new Intent();
result.putExtra(GadgetManager.EXTRA_GADGET_ID, gadgetId);
diff --git a/tests/ImfTest/Android.mk b/tests/ImfTest/Android.mk
new file mode 100755
index 0000000..eb5327b
--- /dev/null
+++ b/tests/ImfTest/Android.mk
@@ -0,0 +1,15 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+# We only want this apk build for tests.
+LOCAL_MODULE_TAGS := tests
+
+# Only compile source java files in this apk.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := ImfTest
+
+include $(BUILD_PACKAGE)
+
+# Use the following include to make our test apk.
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/ImfTest/AndroidManifest.xml b/tests/ImfTest/AndroidManifest.xml
new file mode 100755
index 0000000..85d6b0c
--- /dev/null
+++ b/tests/ImfTest/AndroidManifest.xml
@@ -0,0 +1,24 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.imftest">
+
+ <application>
+
+ <activity android:name=".samples.InputTypeActivity" android:label="Input Type Activity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER" />
+ <category android:name="android.intent.category.IMF_TEST" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".samples.ButtonActivity" android:label="Button Activity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER" />
+ <category android:name="android.intent.category.IMF_TEST" />
+ </intent-filter>
+ </activity>
+
+ </application>
+
+</manifest>
diff --git a/tests/ImfTest/res/layout/sample_edit_text.xml b/tests/ImfTest/res/layout/sample_edit_text.xml
new file mode 100755
index 0000000..99a5cf8
--- /dev/null
+++ b/tests/ImfTest/res/layout/sample_edit_text.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/samples/SampleCode/res/layout/baseline_1.xml
+**
+** Copyright 2007, 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.
+*/
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+>
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:orientation="horizontal"
+ android:baselineAligned="false"
+ android:gravity="center_vertical"
+ >
+
+ <TextView android:id="@+id/label"
+ android:layout_width="100dip"
+ android:layout_height="wrap_content"
+ android:gravity="right|center_vertical"
+ />
+
+ <EditText android:id="@+id/data"
+ android:layout_width="0dip"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="8dip"
+ />
+ </LinearLayout>
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1dip"
+ android:background="@android:drawable/divider_horizontal_dark"
+ />
+</LinearLayout>
diff --git a/tests/ImfTest/res/values/strings.xml b/tests/ImfTest/res/values/strings.xml
new file mode 100755
index 0000000..a56c363
--- /dev/null
+++ b/tests/ImfTest/res/values/strings.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 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.
+*/
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Strings for sample activities -->
+ <string name="normal_edit_text_label">Normal</string>
+ <string name="uri_edit_text_label">Uri</string>
+ <string name="email_address_edit_text_label">Email Address</string>
+ <string name="email_subject_edit_text_label">Email Subject</string>
+ <string name="email_content_edit_text_label">Email Content</string>
+ <string name="person_name_edit_text_label">Person Name</string>
+ <string name="postal_address_edit_text_label">Postal Address</string>
+ <string name="password_edit_text_label">Password</string>
+ <string name="search_string_edit_text_label">Search String</string>
+ <string name="web_edit_text_label">Web Edit Text</string>
+ <string name="signed_number_edit_text_label">Signed Number</string>
+ <string name="decimal_number_edit_text_label">Decimal Number</string>
+ <string name="phone_number_edit_text_label">Phone Number</string>
+ <string name="normal_datetime_edit_text_label">Datetime</string>
+ <string name="date_edit_text_label">Date</string>
+ <string name="time_edit_text_label">Time</string>
+
+</resources>
diff --git a/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java b/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java
new file mode 100644
index 0000000..4233811
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java
@@ -0,0 +1,52 @@
+package com.android.imftest.samples;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.Button;
+import android.widget.TextView;
+
+public class ButtonActivity extends Activity
+{
+ static boolean mKeyboardIsActive = false;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ final ButtonActivity instance = this;
+
+ final Button myButton = new Button(this);
+ myButton.setClickable(true);
+ myButton.setText("Keyboard UP!");
+ myButton.setOnClickListener(new View.OnClickListener()
+ {
+ public void onClick (View v)
+ {
+ InputMethodManager imm = InputMethodManager.getInstance(instance);
+ if (mKeyboardIsActive)
+ {
+ imm.hideSoftInputFromInputMethod(v.getWindowToken(), 0);
+ myButton.setText("Keyboard UP!");
+
+ }
+ else
+ {
+ imm.showSoftInput(null, 0);
+ myButton.setText("Keyboard DOWN!");
+ }
+
+ mKeyboardIsActive = !mKeyboardIsActive;
+ }
+ });
+
+ LinearLayout layout = new LinearLayout(this);
+ layout.setOrientation(LinearLayout.VERTICAL);
+ layout.addView(myButton);
+ setContentView(layout);
+ }
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java b/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java
new file mode 100755
index 0000000..f7aaa7b
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2007 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.imftest.samples;
+
+import com.android.imftest.R;
+
+import android.app.Activity;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.Button;
+import android.widget.ScrollView;
+import android.widget.TextView;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
+import android.view.ViewRoot;
+import android.view.inputmethod.EditorInfo;
+import android.content.Context;
+
+public class InputTypeActivity extends Activity {
+
+ private LinearLayout mLayout;
+ private ScrollView mScrollView;
+ private LayoutInflater mInflater;
+ private ViewGroup mParent;
+
+ @Override
+ protected void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ mScrollView = new ScrollView(this);
+
+ mLayout = new LinearLayout(this);
+ mLayout.setOrientation(LinearLayout.VERTICAL);
+ mLayout.setLayoutParams(new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.FILL_PARENT,
+ ViewGroup.LayoutParams.FILL_PARENT));
+
+ mInflater = getLayoutInflater();
+ mParent = mLayout;
+
+ /* Normal Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_NORMAL,
+ R.string.normal_edit_text_label));
+
+ /* Uri Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_URI,
+ R.string.uri_edit_text_label));
+
+ /* Email Address Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS,
+ R.string.email_address_edit_text_label));
+
+ /* Email Subject Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_EMAIL_SUBJECT,
+ R.string.email_subject_edit_text_label));
+
+ /* Email Content Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_EMAIL_CONTENT,
+ R.string.email_content_edit_text_label));
+
+ /* Person Name Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_PERSON_NAME,
+ R.string.person_name_edit_text_label));
+
+ /* Postal Address Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_POSTAL_ADDRESS,
+ R.string.postal_address_edit_text_label));
+
+ /* Password Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_PASSWORD,
+ R.string.password_edit_text_label));
+
+ /* Search String Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_SEARCH_STRING,
+ R.string.search_string_edit_text_label));
+
+ /* Web Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT,
+ R.string.web_edit_text_label));
+
+ /* Signed Number Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_NUMBER|EditorInfo.TYPE_NUMBER_FLAG_SIGNED,
+ R.string.signed_number_edit_text_label));
+
+ /* Decimal Number Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_NUMBER|EditorInfo.TYPE_NUMBER_FLAG_DECIMAL,
+ R.string.decimal_number_edit_text_label));
+
+ /* Phone Number Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_PHONE,
+ R.string.phone_number_edit_text_label));
+
+ /* Normal Datetime Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_DATETIME|EditorInfo.TYPE_DATETIME_VARIATION_NORMAL,
+ R.string.normal_datetime_edit_text_label));
+
+ /* Date Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_DATETIME|EditorInfo.TYPE_DATETIME_VARIATION_DATE,
+ R.string.date_edit_text_label));
+
+ /* Time Edit Text */
+ mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_DATETIME|EditorInfo.TYPE_DATETIME_VARIATION_TIME,
+ R.string.time_edit_text_label));
+
+ mScrollView.addView(mLayout);
+ setContentView(mScrollView);
+ }
+
+ private View buildEntryView(int inputType, int label) {
+
+
+ View view = mInflater.inflate(R.layout.sample_edit_text, mParent, false);
+
+ EditText editText = (EditText) view.findViewById(R.id.data);
+ editText.setInputType(inputType);
+
+ TextView textView = (TextView) view.findViewById(R.id.label);
+ textView.setText(label);
+
+ return view;
+ }
+
+}