Clean up MessageCompose for phone

- +cc/bcc and "add attachment" are now menu options.
- layout clean up
- switch to getView()

Change-Id: I5efb6d0fd7b6d1265fed0173463adce2c6d652ba
This commit is contained in:
Makoto Onuki 2011-04-01 15:25:36 -07:00
parent a10c709873
commit 2d380e4504
4 changed files with 84 additions and 51 deletions

View File

@ -15,7 +15,6 @@
-->
<!-- small -->
<!-- TODO Simplify this. This layout is way too deep. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent" android:layout_width="match_parent"
@ -85,7 +84,7 @@
android:layout_marginRight="6dip"
android:hint="@string/message_compose_subject_hint"
android:inputType
="textEmailSubject|textAutoCorrect|textCapSentences|textImeMultiLine"
="textEmailSubject|textAutoCorrect|textCapSentences|textMultiLine"
android:imeOptions="actionNext"
/>
<!--
@ -158,27 +157,4 @@
/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dip"
android:paddingLeft="4dip"
android:paddingRight="4dip"
android:paddingBottom="1dip"
android:background="@android:drawable/bottom_bar" >
<Button
android:id="@+id/add_cc_bcc"
android:text="@string/add_cc_bcc_action"
android:layout_height="match_parent"
android:layout_width="0dip"
android:layout_weight="1" />
<Button
android:id="@+id/add_attachment"
android:text="@string/add_attachment_action"
android:layout_height="match_parent"
android:layout_width="0dip"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 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.
-->
<!-- xlarge -->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/send"
android:title="@string/send_action"
android:showAsAction="always|withText"
android:icon="@drawable/ic_menu_send_holo_light"
android:alphabeticShortcut="s"
/>
<item
android:id="@+id/save"
android:title="@string/save_draft_action"
android:showAsAction="always"
android:alphabeticShortcut="d"
/>
<item
android:id="@+id/discard"
android:title="@string/discard_action"
android:showAsAction="always"
android:icon="@drawable/ic_menu_trash_holo_light"
android:alphabeticShortcut="q"
/>
</menu>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
<!-- 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.
@ -14,25 +14,36 @@
limitations under the License.
-->
<!-- small -->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/send"
android:title="@string/send_action"
android:showAsAction="always|withText"
android:showAsAction="ifRoom|withText"
android:icon="@drawable/ic_menu_send_holo_light"
android:alphabeticShortcut="s"
/>
<!-- "Save draft" should only be text -->
<item
android:id="@+id/save"
android:title="@string/save_draft_action"
android:showAsAction="always"
android:showAsAction="ifRoom"
android:alphabeticShortcut="d"
/>
<item
android:id="@+id/add_cc_bcc"
android:title="@string/add_cc_bcc_action"
android:showAsAction="ifRoom"
/>
<item
android:id="@+id/add_attachment"
android:icon="@drawable/ic_attachment_holo_light"
android:showAsAction="ifRoom"
/>
<item
android:id="@+id/discard"
android:title="@string/discard_action"
android:showAsAction="always"
android:showAsAction="ifRoom"
android:icon="@drawable/ic_menu_trash_holo_light"
android:alphabeticShortcut="q"
/>

View File

@ -453,31 +453,31 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
}
public void setFocusShifter(int fromViewId, final int targetViewId) {
View label = findViewById(fromViewId);
// Labels don't exist on the phone UI, so null check.
View label = findViewById(fromViewId); // xlarge only
if (label != null) {
final View target = UiUtilities.getView(this, targetViewId);
label.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
findViewById(targetViewId).requestFocus();
target.requestFocus();
}
});
}
}
private void initViews() {
mFromView = (TextView)findViewById(R.id.from);
mToView = (MultiAutoCompleteTextView)findViewById(R.id.to);
mCcView = (MultiAutoCompleteTextView)findViewById(R.id.cc);
mBccView = (MultiAutoCompleteTextView)findViewById(R.id.bcc);
mCcBccContainer = findViewById(R.id.cc_bcc_container);
mSubjectView = (EditText)findViewById(R.id.subject);
mMessageContentView = (EditText)findViewById(R.id.message_content);
mAttachments = (LinearLayout)findViewById(R.id.attachments);
mAttachmentContainer = findViewById(R.id.attachment_container);
mQuotedTextBar = findViewById(R.id.quoted_text_bar);
mIncludeQuotedTextCheckBox = (CheckBox) findViewById(R.id.include_quoted_text);
mQuotedText = (WebView)findViewById(R.id.quoted_text);
mFromView = (TextView) UiUtilities.getView(this, R.id.from);
mToView = (MultiAutoCompleteTextView) UiUtilities.getView(this, R.id.to);
mCcView = (MultiAutoCompleteTextView) UiUtilities.getView(this, R.id.cc);
mBccView = (MultiAutoCompleteTextView) UiUtilities.getView(this, R.id.bcc);
mCcBccContainer = UiUtilities.getView(this, R.id.cc_bcc_container);
mSubjectView = (EditText) UiUtilities.getView(this, R.id.subject);
mMessageContentView = (EditText) UiUtilities.getView(this, R.id.message_content);
mAttachments = (LinearLayout) UiUtilities.getView(this, R.id.attachments);
mAttachmentContainer = UiUtilities.getView(this, R.id.attachment_container);
mQuotedTextBar = UiUtilities.getView(this, R.id.quoted_text_bar);
mIncludeQuotedTextCheckBox = (CheckBox) UiUtilities.getView(this, R.id.include_quoted_text);
mQuotedText = (WebView) UiUtilities.getView(this, R.id.quoted_text);
TextWatcher watcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start,
@ -579,8 +579,14 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
mBccView.setTokenizer(new Rfc822Tokenizer());
mBccView.setValidator(addressValidator);
findViewById(R.id.add_cc_bcc).setOnClickListener(this);
findViewById(R.id.add_attachment).setOnClickListener(this);
final View addCcBccView = findViewById(R.id.add_cc_bcc); // xlarge only
if (addCcBccView != null) {
addCcBccView.setOnClickListener(this);
}
final View addAttachmentView = findViewById(R.id.add_attachment); // xlarge only
if (addAttachmentView != null) {
addAttachmentView.setOnClickListener(this);
}
setFocusShifter(R.id.to_label, R.id.to);
setFocusShifter(R.id.cc_label, R.id.cc);
@ -1093,7 +1099,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
private void showCcBccFields() {
mCcBccContainer.setVisibility(View.VISIBLE);
findViewById(R.id.add_cc_bcc).setVisibility(View.INVISIBLE);
UiUtilities.setVisibilitySafe(this, R.id.add_cc_bcc, View.INVISIBLE);
}
/**
@ -1164,9 +1170,9 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
View view = getLayoutInflater().inflate(R.layout.message_compose_attachment,
mAttachments, false);
TextView nameView = (TextView)view.findViewById(R.id.attachment_name);
ImageButton delete = (ImageButton)view.findViewById(R.id.attachment_delete);
TextView sizeView = (TextView)view.findViewById(R.id.attachment_size);
TextView nameView = (TextView) UiUtilities.getView(view, R.id.attachment_name);
ImageButton delete = (ImageButton) UiUtilities.getView(view, R.id.attachment_delete);
TextView sizeView = (TextView) UiUtilities.getView(view, R.id.attachment_size);
nameView.setText(attachment.mFileName);
sizeView.setText(UiUtilities.formatSize(this, attachment.mSize));