Merge "Compose: Make the EditTexts easy to focus on" into honeycomb

This commit is contained in:
Makoto Onuki 2011-01-19 13:44:03 -08:00 committed by Android (Google) Code Review
commit 4911af8879
2 changed files with 40 additions and 6 deletions

View File

@ -22,7 +22,7 @@
android:layout_width="match_parent"
>
<ScrollView
android:layout_height="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="16dip"
style="@style/message_compose_scroll"
@ -31,11 +31,12 @@
android:paddingLeft="32dip"
android:paddingRight="32dip"
android:background="#ffffffff"
android:fillViewport="true"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
>
<!-- headers + buttons -->
<LinearLayout
@ -69,6 +70,7 @@
style="@style/message_compose_header_field_container"
>
<TextView
android:id="@+id/to_label"
style="@style/message_compose_header_field_label"
android:text="@string/message_compose_to_label"
/>
@ -92,6 +94,7 @@
style="@style/message_compose_header_field_container"
>
<TextView
android:id="@+id/cc_label"
style="@style/message_compose_header_field_label"
android:text="@string/message_compose_cc_label"
/>
@ -108,6 +111,7 @@
style="@style/message_compose_header_field_container"
>
<TextView
android:id="@+id/bcc_label"
style="@style/message_compose_header_field_label"
android:text="@string/message_compose_bcc_label"
/>
@ -125,6 +129,7 @@
style="@style/message_compose_header_field_container"
>
<TextView
android:id="@+id/subject_label"
style="@style/message_compose_header_field_label"
android:text="@string/message_compose_subject_label"
/>
@ -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"
/>
<!-- quoted text bar -->
@ -283,6 +292,12 @@
android:layout_width="match_parent"
android:layout_marginTop="16dip"
/>
<View
android:id="@+id/tap_trap"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
/>
</LinearLayout>
</ScrollView>
</FrameLayout>

View File

@ -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);