summaryrefslogtreecommitdiffstats
path: root/tests/ImfTest
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-01-22 00:13:42 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-01-22 00:13:42 -0800
commitf1e484acb594a726fb57ad0ae4cfe902c7f35858 (patch)
tree99d2b34512f0dc2ae67666e756c1cfcd331e5fe3 /tests/ImfTest
parent22f7dfd23490a3de2f21ff96949ba47003aac8f8 (diff)
downloadframeworks_base-f1e484acb594a726fb57ad0ae4cfe902c7f35858.zip
frameworks_base-f1e484acb594a726fb57ad0ae4cfe902c7f35858.tar.gz
frameworks_base-f1e484acb594a726fb57ad0ae4cfe902c7f35858.tar.bz2
auto import from //branches/cupcake/...@127436
Diffstat (limited to 'tests/ImfTest')
-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
6 files changed, 323 insertions, 0 deletions
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;
+ }
+
+}