Implement custom EditText to correctly suppress IME
Also use stateAlwaysHidden to ask the Activity itself to
show up IME on the first boot.
Bug: 5032146
Bug: 5171943
Change-Id: Ie763cca52ca6a4d0db48ab240a39cb8f03ebbc03
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index aeec2b2..e255fd2 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -117,7 +117,9 @@
</intent-filter>
</activity>
- <!-- Tab container for all tabs -->
+ <!-- The entrance point for Phone UI.
+ stateAlwaysHidden is set to suppress keyboard show up on
+ dialpad screen. -->
<activity android:name=".activities.DialtactsActivity"
android:label="@string/launcherDialer"
android:theme="@style/DialtactsTheme"
@@ -128,7 +130,7 @@
android:screenOrientation="nosensor"
android:enabled="@*android:bool/config_voice_capable"
android:taskAffinity="android.task.contacts.phone"
- >
+ android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/res/layout/dialpad_fragment.xml b/res/layout/dialpad_fragment.xml
index 90d2593..9c5099f 100644
--- a/res/layout/dialpad_fragment.xml
+++ b/res/layout/dialpad_fragment.xml
@@ -35,7 +35,8 @@
in the java code.
Background drawable can be controlled programatically. -->
- <EditText android:id="@+id/digits"
+ <com.android.contacts.dialpad.DigitsEditText
+ android:id="@+id/digits"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
diff --git a/src/com/android/contacts/dialpad/DialpadFragment.java b/src/com/android/contacts/dialpad/DialpadFragment.java
index 93bd3e9..188c546 100644
--- a/src/com/android/contacts/dialpad/DialpadFragment.java
+++ b/src/com/android/contacts/dialpad/DialpadFragment.java
@@ -33,7 +33,6 @@
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.media.ToneGenerator;
import android.net.Uri;
@@ -298,12 +297,10 @@
mDialpad = fragmentView.findViewById(R.id.dialpad); // This is null in landscape mode.
// In landscape we put the keyboard in phone mode.
- // In portrait we prevent the soft keyboard to show since the
- // dialpad acts as one already.
if (null == mDialpad) {
mDigits.setInputType(android.text.InputType.TYPE_CLASS_PHONE);
} else {
- mDigits.setInputType(android.text.InputType.TYPE_NULL);
+ mDigits.setCursorVisible(false);
}
// Set up the "dialpad chooser" UI; see showDialpadChooser().
diff --git a/src/com/android/contacts/dialpad/DigitsEditText.java b/src/com/android/contacts/dialpad/DigitsEditText.java
new file mode 100644
index 0000000..930717a
--- /dev/null
+++ b/src/com/android/contacts/dialpad/DigitsEditText.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 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.contacts.dialpad;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+
+/**
+ * EditText which suppresses IME show up.
+ */
+public class DigitsEditText extends EditText {
+ public DigitsEditText(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setSuggestionsEnabled(false);
+ }
+
+ @Override
+ protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
+ super.onFocusChanged(focused, direction, previouslyFocusedRect);
+ final InputMethodManager imm = ((InputMethodManager) getContext()
+ .getSystemService(Context.INPUT_METHOD_SERVICE));
+ if (imm != null && imm.isActive(this)) {
+ imm.hideSoftInputFromWindow(getApplicationWindowToken(), 0);
+ }
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ final boolean ret = super.onTouchEvent(event);
+ // Must be done after super.onTouchEvent()
+ final InputMethodManager imm = ((InputMethodManager) getContext()
+ .getSystemService(Context.INPUT_METHOD_SERVICE));
+ if (imm != null && imm.isActive(this)) {
+ imm.hideSoftInputFromWindow(getApplicationWindowToken(), 0);
+ }
+ return ret;
+ }
+}
\ No newline at end of file