From 8ac207f2987e50622b7c89b875db56e089c1a05b Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Wed, 19 Jan 2011 13:36:21 -0800 Subject: [PATCH] Compose: Make the EditTexts easy to focus on - Now tapping these To/Cc/Bcc/Subject labels moves the focus to the corresponding edittext. - Tapping the bottom part of the screen moves the focus to the main EditText. - Also use paddings instead of margins for the main EditText, to expand the hitarea. Bug 3366831 Bug 3367100 Change-Id: I9b5d18dcc9d7802bfcbd0160befcb008c784d9f7 --- res/layout-xlarge/message_compose.xml | 27 ++++++++++++++----- .../email/activity/MessageCompose.java | 19 +++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/res/layout-xlarge/message_compose.xml b/res/layout-xlarge/message_compose.xml index a4ce1c860..e6cfe0463 100644 --- a/res/layout-xlarge/message_compose.xml +++ b/res/layout-xlarge/message_compose.xml @@ -22,7 +22,7 @@ android:layout_width="match_parent" > @@ -92,6 +94,7 @@ style="@style/message_compose_header_field_container" > @@ -108,6 +111,7 @@ style="@style/message_compose_header_field_container" > @@ -125,6 +129,7 @@ style="@style/message_compose_header_field_container" > @@ -214,16 +219,20 @@ android:id="@+id/message_content" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="32dip" - android:layout_marginBottom="32dip" - android:layout_marginLeft="16dip" - android:layout_marginRight="16dip" + android:layout_marginTop="0dip" + android:layout_marginBottom="0dip" + android:layout_marginLeft="0dip" + android:layout_marginRight="0dip" android:gravity="left|top" android:minLines="3" android:hint="@string/message_compose_body_hint" android:inputType="textLongMessage|textMultiLine|textAutoCorrect|textCapSentences" android:imeOptions="actionDone|flagNoEnterAction" style="@style/PlainEditText" + android:paddingTop="32dip" + android:paddingBottom="32dip" + android:paddingLeft="16dip" + android:paddingRight="16dip" /> @@ -283,6 +292,12 @@ android:layout_width="match_parent" android:layout_marginTop="16dip" /> + diff --git a/src/com/android/email/activity/MessageCompose.java b/src/com/android/email/activity/MessageCompose.java index 7787b3efb..e738b708b 100644 --- a/src/com/android/email/activity/MessageCompose.java +++ b/src/com/android/email/activity/MessageCompose.java @@ -447,6 +447,19 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus invalidateOptionsMenu(); } + public void setFocusShifter(int fromViewId, final int targetViewId) { + View label = findViewById(fromViewId); + // Labels don't exist on the phone UI, so null check. + if (label != null) { + label.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + findViewById(targetViewId).requestFocus(); + } + }); + } + } + private void initViews() { mActionBar = getActionBar(); mFromView = (TextView)findViewById(R.id.from); @@ -565,6 +578,12 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus findViewById(R.id.add_cc_bcc).setOnClickListener(this); findViewById(R.id.add_attachment).setOnClickListener(this); + setFocusShifter(R.id.to_label, R.id.to); + setFocusShifter(R.id.cc_label, R.id.cc); + setFocusShifter(R.id.bcc_label, R.id.bcc); + setFocusShifter(R.id.subject_label, R.id.subject); + setFocusShifter(R.id.tap_trap, R.id.message_content); + mSubjectView.setOnFocusChangeListener(this); mMessageContentView.setOnFocusChangeListener(this);