Subject should only show 1 line and then scroll the content; enter goes to body
Fixes b/7054260 compose subject should be 1 line; enter goes to compose
Change-Id: I55bde575c584766042cabdaf5018912039ffeb27
diff --git a/res/layout-sw600dp/compose.xml b/res/layout-sw600dp/compose.xml
index ff0d51c..d725750 100644
--- a/res/layout-sw600dp/compose.xml
+++ b/res/layout-sw600dp/compose.xml
@@ -113,11 +113,7 @@
android:layout_width="0dip">
<!-- Subject: localization cannot control what field pressing tab will bring the user to. This is controlled at runtime. -->
<EditText android:id="@+id/subject"
- android:inputType="textEmailSubject|textAutoCorrect|textCapSentences|textImeMultiLine|textMultiLine"
- android:hint="@string/subject_hint"
- android:textColorHint="@color/compose_label_text"
- android:imeOptions="actionDone|flagNoExtractUi"
- style="@style/ComposeEditTextView" />
+ style="@style/ComposeSubjectView" />
</RelativeLayout>
<ImageView android:id="@+id/add_photo_attachment"
android:text="@string/add_file_attachment"
@@ -195,4 +191,4 @@
</TableLayout>
</ScrollView>
-</FrameLayout>
\ No newline at end of file
+</FrameLayout>
diff --git a/res/layout/compose_subject.xml b/res/layout/compose_subject.xml
index 6ceaf0b..5a9834e 100644
--- a/res/layout/compose_subject.xml
+++ b/res/layout/compose_subject.xml
@@ -24,5 +24,5 @@
android:hint="@string/subject_hint"
android:textColorHint="@color/compose_label_text"
android:imeOptions="actionDone|flagNoExtractUi"
- style="@style/ComposeEditTextView" />
+ style="@style/ComposeSubjectView" />
</RelativeLayout>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 82e27b0..25617e8 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -30,6 +30,15 @@
<item name="android:background">@null</item>
</style>
+ <style name="ComposeSubjectView" parent="@style/ComposeEditTextView">
+ <item name="android:maxLines">1</item>
+ <item name="android:inputType">textEmailSubject|textAutoCorrect|textCapSentences|textImeMultiLine|textMultiLine</item>
+ <item name="android:hint">@string/subject_hint</item>
+ <item name="android:textColorHint">@color/compose_label_text</item>
+ <item name="android:imeOptions">actionDone|flagNoExtractUi</item>
+ <item name="android:maxLines">1</item>
+ </style>
+
<style name="RecipientComposeFieldSpacer">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">4dip</item>
diff --git a/src/com/android/mail/compose/ComposeActivity.java b/src/com/android/mail/compose/ComposeActivity.java
index 2e66d07..c0c1f7e 100644
--- a/src/com/android/mail/compose/ComposeActivity.java
+++ b/src/com/android/mail/compose/ComposeActivity.java
@@ -50,6 +50,7 @@
import android.text.util.Rfc822Token;
import android.text.util.Rfc822Tokenizer;
import android.view.Gravity;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -58,6 +59,7 @@
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.inputmethod.BaseInputConnection;
+import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
@@ -110,7 +112,8 @@
public class ComposeActivity extends Activity implements OnClickListener, OnNavigationListener,
RespondInlineListener, DialogInterface.OnClickListener, TextWatcher,
- AttachmentDeletedListener, OnAccountChangedListener, LoaderManager.LoaderCallbacks<Cursor> {
+ AttachmentDeletedListener, OnAccountChangedListener, LoaderManager.LoaderCallbacks<Cursor>,
+ TextView.OnEditorActionListener {
// Identifiers for which type of composition this is
static final int COMPOSE = -1;
static final int REPLY = 0;
@@ -880,6 +883,7 @@
// TODO: add special chips text change watchers before adding
// this as a text changed watcher to the to, cc, bcc fields.
mSubject = (TextView) findViewById(R.id.subject);
+ mSubject.setOnEditorActionListener(this);
mQuotedTextView = (QuotedTextView) findViewById(R.id.quoted_text_view);
mQuotedTextView.setRespondInlineListener(this);
mBodyView = (EditText) findViewById(R.id.body);
@@ -889,6 +893,15 @@
mFromSpinner = (FromAddressSpinner) findViewById(R.id.from_picker);
}
+ @Override
+ public boolean onEditorAction(TextView view, int action, KeyEvent keyEvent) {
+ if (action == EditorInfo.IME_ACTION_DONE) {
+ focusBody();
+ return true;
+ }
+ return false;
+ }
+
protected TextView getBody() {
return mBodyView;
}