From f1e484acb594a726fb57ad0ae4cfe902c7f35858 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Thu, 22 Jan 2009 00:13:42 -0800 Subject: auto import from //branches/cupcake/...@127436 --- tests/ImfTest/Android.mk | 15 +++ tests/ImfTest/AndroidManifest.xml | 24 ++++ tests/ImfTest/res/layout/sample_edit_text.xml | 53 ++++++++ tests/ImfTest/res/values/strings.xml | 39 ++++++ .../android/imftest/samples/ButtonActivity.java | 52 ++++++++ .../android/imftest/samples/InputTypeActivity.java | 140 +++++++++++++++++++++ 6 files changed, 323 insertions(+) create mode 100755 tests/ImfTest/Android.mk create mode 100755 tests/ImfTest/AndroidManifest.xml create mode 100755 tests/ImfTest/res/layout/sample_edit_text.xml create mode 100755 tests/ImfTest/res/values/strings.xml create mode 100644 tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java create mode 100755 tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java (limited to 'tests/ImfTest') 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 @@ + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + 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 @@ + + + + + Normal + Uri + Email Address + Email Subject + Email Content + Person Name + Postal Address + Password + Search String + Web Edit Text + Signed Number + Decimal Number + Phone Number + Datetime + Date + Time + + 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; + } + +} -- cgit v1.1