diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-01-22 00:13:42 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-01-22 00:13:42 -0800 |
commit | f1e484acb594a726fb57ad0ae4cfe902c7f35858 (patch) | |
tree | 99d2b34512f0dc2ae67666e756c1cfcd331e5fe3 /tests/ImfTest/src/com/android/imftest/samples | |
parent | 22f7dfd23490a3de2f21ff96949ba47003aac8f8 (diff) | |
download | frameworks_base-f1e484acb594a726fb57ad0ae4cfe902c7f35858.zip frameworks_base-f1e484acb594a726fb57ad0ae4cfe902c7f35858.tar.gz frameworks_base-f1e484acb594a726fb57ad0ae4cfe902c7f35858.tar.bz2 |
auto import from //branches/cupcake/...@127436
Diffstat (limited to 'tests/ImfTest/src/com/android/imftest/samples')
-rw-r--r-- | tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java | 52 | ||||
-rwxr-xr-x | tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java | 140 |
2 files changed, 192 insertions, 0 deletions
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; + } + +} |