Focus on name field and show keyboard when inserting contact
Request name field focus when it's an insert.
Test: Manually verified:
* Inserting new contact with fab has keyboard and focus on name
field
* Inserting new contact from messenger app has keyboard and
focus on name field with phone number filled in
* Editing a contact has nothing focused
* Editing a read-only contact has the name field focused but no
keyboard
Bug: 31158231
Change-Id: Iff7e0df5059f5efa038d5f794065f76e38a21288
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 25aa0d9..0c15a55 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -382,8 +382,7 @@
<!-- Edit or create a contact with only the most important fields displayed initially. -->
<activity
android:name=".activities.ContactEditorActivity"
- android:theme="@style/EditorActivityTheme"
- android:windowSoftInputMode="stateHidden|adjustResize">
+ android:theme="@style/EditorActivityTheme">
<intent-filter>
<action android:name="android.intent.action.INSERT"/>
diff --git a/src/com/android/contacts/editor/RawContactEditorView.java b/src/com/android/contacts/editor/RawContactEditorView.java
index 6d1f794..0c6e029 100644
--- a/src/com/android/contacts/editor/RawContactEditorView.java
+++ b/src/com/android/contacts/editor/RawContactEditorView.java
@@ -497,6 +497,14 @@
addReadOnlyRawContactEditorViews();
} else {
setupEditorNormally();
+ // If we're inserting a new contact, request focus to bring up the keyboard for the
+ // name field.
+ if (mHasNewContact) {
+ final StructuredNameEditorView name = getNameEditorView();
+ if (name != null) {
+ name.requestFocusForFirstEditField();
+ }
+ }
}
if (mListener != null) mListener.onEditorsBound();
}