Make "Send all messages" a menu option

- Now it's a menu command rather than a button.
- Also string changed from "Send outgoing messages".

Bug 3166218

Change-Id: I82f6188365f9f6bc5a6d40fb23d774eebe181445
This commit is contained in:
Makoto Onuki 2010-11-04 16:02:28 -07:00
parent bf678771b7
commit 138abe82e6
5 changed files with 71 additions and 49 deletions

View File

@ -32,28 +32,12 @@
android:textAppearance="?android:attr/textAppearanceLarge"
android:visibility="gone"
/>
<LinearLayout
<FrameLayout
android:id="@+id/list_panel"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:id="@+id/send_panel"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
>
<Button
android:id="@+id/send_messages"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/message_list_send_pending_messages_action" />
</LinearLayout>
<include layout="@android:layout/list_content" />
</LinearLayout>
</FrameLayout>
</FrameLayout>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 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.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<!-- STOPSHIP Need icon -->
<item
android:id="@+id/send"
android:orderInCategory="50"
android:title="@string/message_list_send_pending_messages_action"
android:showAsAction="ifRoom"
/>
</menu>

View File

@ -15,19 +15,25 @@
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/compose"
<item
android:id="@+id/compose"
android:orderInCategory="100"
android:alphabeticShortcut="c"
android:title="@string/compose_action"
android:icon="@drawable/ic_menu_compose"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/refresh"
<item
android:id="@+id/refresh"
android:orderInCategory="200"
android:alphabeticShortcut="r"
android:title="@string/refresh_action"
android:icon="@drawable/ic_menu_refresh"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/account_settings"
<item
android:id="@+id/account_settings"
android:orderInCategory="300"
android:title="@string/account_settings_action"
android:icon="@android:drawable/ic_menu_preferences"
/>

View File

@ -33,9 +33,8 @@
<!-- STOPSHIP Remove them if they're not used after all -->
<!-- Appears in message list view of outbox while messages are being sent -->
<string name="status_sending_messages">Sending messages\u2026</string>
<!-- Appears at the bottom of list of messages of outbox;
user selects to send pending messages. -->
<string name="message_list_send_pending_messages_action">Send outgoing messages</string>
<!-- Command shown on Outbox to send all pending messages [CHAR_LIMIT=15] -->
<string name="message_list_send_pending_messages_action">Send all</string>
<!-- Toast while fetching attachment -->
<string name="message_view_fetching_attachment_toast">Fetching attachment.</string>
<!-- Appears progress dialog for fetching attachment -->

View File

@ -45,12 +45,10 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
@ -77,7 +75,7 @@ import java.util.Set;
*/
public class MessageListFragment extends ListFragment
implements OnItemClickListener, OnItemLongClickListener, MessagesAdapter.Callback,
OnClickListener, MoveMessageToDialog.Callback {
MoveMessageToDialog.Callback {
private static final String BUNDLE_LIST_STATE = "MessageListFragment.state.listState";
private static final String BUNDLE_KEY_SELECTED_MESSAGE_ID
= "messageListFragment.state.listState.selected_message_id";
@ -93,7 +91,6 @@ public class MessageListFragment extends ListFragment
private View mListFooterView;
private TextView mListFooterText;
private View mListFooterProgress;
private View mSendPanel;
private View mListPanel;
private View mNoMessagesPanel;
@ -130,6 +127,9 @@ public class MessageListFragment extends ListFragment
*/
private ActionMode mSelectionMode;
/** Whether "Send all messages" should be shown. */
private boolean mShowSendCommand;
private Utility.ListStateSaver mSavedListState;
private MessageOpenTask mMessageOpenTask;
@ -191,6 +191,7 @@ public class MessageListFragment extends ListFragment
}
super.onCreate(savedInstanceState);
mActivity = getActivity();
setHasOptionsMenu(true);
mController = Controller.getInstance(mActivity);
mRefreshManager = RefreshManager.getInstance(mActivity);
mRefreshManager.registerListener(mRefreshListener);
@ -201,10 +202,8 @@ public class MessageListFragment extends ListFragment
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Use a custom layout, which includes the original layout with "send messages" panel.
View root = inflater.inflate(R.layout.message_list_fragment,null);
mSendPanel = root.findViewById(R.id.send_panel);
mListPanel = root.findViewById(R.id.list_panel);
mNoMessagesPanel = root.findViewById(R.id.no_messages_panel);
((Button) mSendPanel.findViewById(R.id.send_messages)).setOnClickListener(this);
return root;
}
@ -302,6 +301,27 @@ public class MessageListFragment extends ListFragment
mSelectedMessageId = savedInstanceState.getLong(BUNDLE_KEY_SELECTED_MESSAGE_ID);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.message_list_fragment_option, menu);
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.send).setVisible(mShowSendCommand);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.send:
onSendPendingMessages();
return true;
}
return false;
}
public void setCallback(Callback callback) {
mCallback = (callback != null) ? callback : EmptyCallback.INSTANCE;
}
@ -393,15 +413,6 @@ public class MessageListFragment extends ListFragment
return mSelectionMode != null;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.send_messages:
onSendPendingMessages();
break;
}
}
/**
* Called when a message is clicked.
*/
@ -834,16 +845,13 @@ public class MessageListFragment extends ListFragment
}
}
private void hideSendPanel() {
mSendPanel.setVisibility(View.GONE);
private void showSendCommand(boolean show) {
mShowSendCommand = show;
mActivity.invalidateOptionsMenu();
}
private void showSendPanelIfNecessary() {
final boolean show =
isOutbox()
&& (mListAdapter != null)
&& (mListAdapter.getCount() > 0);
mSendPanel.setVisibility(show ? View.VISIBLE : View.GONE);
private void showSendCommandIfNecessary() {
showSendCommand(isOutbox() && (mListAdapter != null) && (mListAdapter.getCount() > 0));
}
private void showNoMessageText(boolean visible) {
@ -866,7 +874,7 @@ public class MessageListFragment extends ListFragment
// Clear the list. (ListFragment will show the "Loading" animation)
showNoMessageText(false);
setListShown(false);
hideSendPanel();
showSendCommand(false);
// Start loading...
final LoaderManager lm = getLoaderManager();
@ -988,7 +996,7 @@ public class MessageListFragment extends ListFragment
autoRefreshStaleMailbox();
addFooterView();
updateSelectionMode();
showSendPanelIfNecessary();
showSendCommandIfNecessary();
showNoMessageTextIfNecessary();
// We want to make selection visible only when the loader was explicitly started.