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:
parent
a10c709873
commit
2d380e4504
|
@ -15,7 +15,6 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- small -->
|
<!-- small -->
|
||||||
<!-- TODO Simplify this. This layout is way too deep. -->
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="match_parent" android:layout_width="match_parent"
|
android:layout_height="match_parent" android:layout_width="match_parent"
|
||||||
|
@ -85,7 +84,7 @@
|
||||||
android:layout_marginRight="6dip"
|
android:layout_marginRight="6dip"
|
||||||
android:hint="@string/message_compose_subject_hint"
|
android:hint="@string/message_compose_subject_hint"
|
||||||
android:inputType
|
android:inputType
|
||||||
="textEmailSubject|textAutoCorrect|textCapSentences|textImeMultiLine"
|
="textEmailSubject|textAutoCorrect|textCapSentences|textMultiLine"
|
||||||
android:imeOptions="actionNext"
|
android:imeOptions="actionNext"
|
||||||
/>
|
/>
|
||||||
<!--
|
<!--
|
||||||
|
@ -158,27 +157,4 @@
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</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>
|
</LinearLayout>
|
||||||
|
|
|
@ -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>
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -14,25 +14,36 @@
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<!-- small -->
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/send"
|
android:id="@+id/send"
|
||||||
android:title="@string/send_action"
|
android:title="@string/send_action"
|
||||||
android:showAsAction="always|withText"
|
android:showAsAction="ifRoom|withText"
|
||||||
android:icon="@drawable/ic_menu_send_holo_light"
|
android:icon="@drawable/ic_menu_send_holo_light"
|
||||||
android:alphabeticShortcut="s"
|
android:alphabeticShortcut="s"
|
||||||
/>
|
/>
|
||||||
<!-- "Save draft" should only be text -->
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/save"
|
android:id="@+id/save"
|
||||||
android:title="@string/save_draft_action"
|
android:title="@string/save_draft_action"
|
||||||
android:showAsAction="always"
|
android:showAsAction="ifRoom"
|
||||||
android:alphabeticShortcut="d"
|
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
|
<item
|
||||||
android:id="@+id/discard"
|
android:id="@+id/discard"
|
||||||
android:title="@string/discard_action"
|
android:title="@string/discard_action"
|
||||||
android:showAsAction="always"
|
android:showAsAction="ifRoom"
|
||||||
android:icon="@drawable/ic_menu_trash_holo_light"
|
android:icon="@drawable/ic_menu_trash_holo_light"
|
||||||
android:alphabeticShortcut="q"
|
android:alphabeticShortcut="q"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -453,31 +453,31 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFocusShifter(int fromViewId, final int targetViewId) {
|
public void setFocusShifter(int fromViewId, final int targetViewId) {
|
||||||
View label = findViewById(fromViewId);
|
View label = findViewById(fromViewId); // xlarge only
|
||||||
// Labels don't exist on the phone UI, so null check.
|
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
|
final View target = UiUtilities.getView(this, targetViewId);
|
||||||
label.setOnClickListener(new View.OnClickListener() {
|
label.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
findViewById(targetViewId).requestFocus();
|
target.requestFocus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViews() {
|
private void initViews() {
|
||||||
mFromView = (TextView)findViewById(R.id.from);
|
mFromView = (TextView) UiUtilities.getView(this, R.id.from);
|
||||||
mToView = (MultiAutoCompleteTextView)findViewById(R.id.to);
|
mToView = (MultiAutoCompleteTextView) UiUtilities.getView(this, R.id.to);
|
||||||
mCcView = (MultiAutoCompleteTextView)findViewById(R.id.cc);
|
mCcView = (MultiAutoCompleteTextView) UiUtilities.getView(this, R.id.cc);
|
||||||
mBccView = (MultiAutoCompleteTextView)findViewById(R.id.bcc);
|
mBccView = (MultiAutoCompleteTextView) UiUtilities.getView(this, R.id.bcc);
|
||||||
mCcBccContainer = findViewById(R.id.cc_bcc_container);
|
mCcBccContainer = UiUtilities.getView(this, R.id.cc_bcc_container);
|
||||||
mSubjectView = (EditText)findViewById(R.id.subject);
|
mSubjectView = (EditText) UiUtilities.getView(this, R.id.subject);
|
||||||
mMessageContentView = (EditText)findViewById(R.id.message_content);
|
mMessageContentView = (EditText) UiUtilities.getView(this, R.id.message_content);
|
||||||
mAttachments = (LinearLayout)findViewById(R.id.attachments);
|
mAttachments = (LinearLayout) UiUtilities.getView(this, R.id.attachments);
|
||||||
mAttachmentContainer = findViewById(R.id.attachment_container);
|
mAttachmentContainer = UiUtilities.getView(this, R.id.attachment_container);
|
||||||
mQuotedTextBar = findViewById(R.id.quoted_text_bar);
|
mQuotedTextBar = UiUtilities.getView(this, R.id.quoted_text_bar);
|
||||||
mIncludeQuotedTextCheckBox = (CheckBox) findViewById(R.id.include_quoted_text);
|
mIncludeQuotedTextCheckBox = (CheckBox) UiUtilities.getView(this, R.id.include_quoted_text);
|
||||||
mQuotedText = (WebView)findViewById(R.id.quoted_text);
|
mQuotedText = (WebView) UiUtilities.getView(this, R.id.quoted_text);
|
||||||
|
|
||||||
TextWatcher watcher = new TextWatcher() {
|
TextWatcher watcher = new TextWatcher() {
|
||||||
public void beforeTextChanged(CharSequence s, int start,
|
public void beforeTextChanged(CharSequence s, int start,
|
||||||
|
@ -579,8 +579,14 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||||
mBccView.setTokenizer(new Rfc822Tokenizer());
|
mBccView.setTokenizer(new Rfc822Tokenizer());
|
||||||
mBccView.setValidator(addressValidator);
|
mBccView.setValidator(addressValidator);
|
||||||
|
|
||||||
findViewById(R.id.add_cc_bcc).setOnClickListener(this);
|
final View addCcBccView = findViewById(R.id.add_cc_bcc); // xlarge only
|
||||||
findViewById(R.id.add_attachment).setOnClickListener(this);
|
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.to_label, R.id.to);
|
||||||
setFocusShifter(R.id.cc_label, R.id.cc);
|
setFocusShifter(R.id.cc_label, R.id.cc);
|
||||||
|
@ -1093,7 +1099,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
||||||
|
|
||||||
private void showCcBccFields() {
|
private void showCcBccFields() {
|
||||||
mCcBccContainer.setVisibility(View.VISIBLE);
|
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,
|
View view = getLayoutInflater().inflate(R.layout.message_compose_attachment,
|
||||||
mAttachments, false);
|
mAttachments, false);
|
||||||
TextView nameView = (TextView)view.findViewById(R.id.attachment_name);
|
TextView nameView = (TextView) UiUtilities.getView(view, R.id.attachment_name);
|
||||||
ImageButton delete = (ImageButton)view.findViewById(R.id.attachment_delete);
|
ImageButton delete = (ImageButton) UiUtilities.getView(view, R.id.attachment_delete);
|
||||||
TextView sizeView = (TextView)view.findViewById(R.id.attachment_size);
|
TextView sizeView = (TextView) UiUtilities.getView(view, R.id.attachment_size);
|
||||||
|
|
||||||
nameView.setText(attachment.mFileName);
|
nameView.setText(attachment.mFileName);
|
||||||
sizeView.setText(UiUtilities.formatSize(this, attachment.mSize));
|
sizeView.setText(UiUtilities.formatSize(this, attachment.mSize));
|
||||||
|
|
Loading…
Reference in New Issue