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:
parent
bf678771b7
commit
138abe82e6
@ -32,28 +32,12 @@
|
|||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
/>
|
/>
|
||||||
<LinearLayout
|
<FrameLayout
|
||||||
android:id="@+id/list_panel"
|
android:id="@+id/list_panel"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="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" />
|
<include layout="@android:layout/list_content" />
|
||||||
</LinearLayout>
|
</FrameLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
25
res/menu/message_list_fragment_option.xml
Normal file
25
res/menu/message_list_fragment_option.xml
Normal 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>
|
@ -15,19 +15,25 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<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:alphabeticShortcut="c"
|
||||||
android:title="@string/compose_action"
|
android:title="@string/compose_action"
|
||||||
android:icon="@drawable/ic_menu_compose"
|
android:icon="@drawable/ic_menu_compose"
|
||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
/>
|
/>
|
||||||
<item android:id="@+id/refresh"
|
<item
|
||||||
|
android:id="@+id/refresh"
|
||||||
|
android:orderInCategory="200"
|
||||||
android:alphabeticShortcut="r"
|
android:alphabeticShortcut="r"
|
||||||
android:title="@string/refresh_action"
|
android:title="@string/refresh_action"
|
||||||
android:icon="@drawable/ic_menu_refresh"
|
android:icon="@drawable/ic_menu_refresh"
|
||||||
android:showAsAction="ifRoom"
|
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:title="@string/account_settings_action"
|
||||||
android:icon="@android:drawable/ic_menu_preferences"
|
android:icon="@android:drawable/ic_menu_preferences"
|
||||||
/>
|
/>
|
||||||
|
@ -33,9 +33,8 @@
|
|||||||
<!-- STOPSHIP Remove them if they're not used after all -->
|
<!-- STOPSHIP Remove them if they're not used after all -->
|
||||||
<!-- Appears in message list view of outbox while messages are being sent -->
|
<!-- Appears in message list view of outbox while messages are being sent -->
|
||||||
<string name="status_sending_messages">Sending messages\u2026</string>
|
<string name="status_sending_messages">Sending messages\u2026</string>
|
||||||
<!-- Appears at the bottom of list of messages of outbox;
|
<!-- Command shown on Outbox to send all pending messages [CHAR_LIMIT=15] -->
|
||||||
user selects to send pending messages. -->
|
<string name="message_list_send_pending_messages_action">Send all</string>
|
||||||
<string name="message_list_send_pending_messages_action">Send outgoing messages</string>
|
|
||||||
<!-- Toast while fetching attachment -->
|
<!-- Toast while fetching attachment -->
|
||||||
<string name="message_view_fetching_attachment_toast">Fetching attachment.</string>
|
<string name="message_view_fetching_attachment_toast">Fetching attachment.</string>
|
||||||
<!-- Appears progress dialog for fetching attachment -->
|
<!-- Appears progress dialog for fetching attachment -->
|
||||||
|
@ -45,12 +45,10 @@ import android.view.Menu;
|
|||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.AdapterView.OnItemLongClickListener;
|
import android.widget.AdapterView.OnItemLongClickListener;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -77,7 +75,7 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class MessageListFragment extends ListFragment
|
public class MessageListFragment extends ListFragment
|
||||||
implements OnItemClickListener, OnItemLongClickListener, MessagesAdapter.Callback,
|
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_LIST_STATE = "MessageListFragment.state.listState";
|
||||||
private static final String BUNDLE_KEY_SELECTED_MESSAGE_ID
|
private static final String BUNDLE_KEY_SELECTED_MESSAGE_ID
|
||||||
= "messageListFragment.state.listState.selected_message_id";
|
= "messageListFragment.state.listState.selected_message_id";
|
||||||
@ -93,7 +91,6 @@ public class MessageListFragment extends ListFragment
|
|||||||
private View mListFooterView;
|
private View mListFooterView;
|
||||||
private TextView mListFooterText;
|
private TextView mListFooterText;
|
||||||
private View mListFooterProgress;
|
private View mListFooterProgress;
|
||||||
private View mSendPanel;
|
|
||||||
private View mListPanel;
|
private View mListPanel;
|
||||||
private View mNoMessagesPanel;
|
private View mNoMessagesPanel;
|
||||||
|
|
||||||
@ -130,6 +127,9 @@ public class MessageListFragment extends ListFragment
|
|||||||
*/
|
*/
|
||||||
private ActionMode mSelectionMode;
|
private ActionMode mSelectionMode;
|
||||||
|
|
||||||
|
/** Whether "Send all messages" should be shown. */
|
||||||
|
private boolean mShowSendCommand;
|
||||||
|
|
||||||
private Utility.ListStateSaver mSavedListState;
|
private Utility.ListStateSaver mSavedListState;
|
||||||
|
|
||||||
private MessageOpenTask mMessageOpenTask;
|
private MessageOpenTask mMessageOpenTask;
|
||||||
@ -191,6 +191,7 @@ public class MessageListFragment extends ListFragment
|
|||||||
}
|
}
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mActivity = getActivity();
|
mActivity = getActivity();
|
||||||
|
setHasOptionsMenu(true);
|
||||||
mController = Controller.getInstance(mActivity);
|
mController = Controller.getInstance(mActivity);
|
||||||
mRefreshManager = RefreshManager.getInstance(mActivity);
|
mRefreshManager = RefreshManager.getInstance(mActivity);
|
||||||
mRefreshManager.registerListener(mRefreshListener);
|
mRefreshManager.registerListener(mRefreshListener);
|
||||||
@ -201,10 +202,8 @@ public class MessageListFragment extends ListFragment
|
|||||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
// Use a custom layout, which includes the original layout with "send messages" panel.
|
// Use a custom layout, which includes the original layout with "send messages" panel.
|
||||||
View root = inflater.inflate(R.layout.message_list_fragment,null);
|
View root = inflater.inflate(R.layout.message_list_fragment,null);
|
||||||
mSendPanel = root.findViewById(R.id.send_panel);
|
|
||||||
mListPanel = root.findViewById(R.id.list_panel);
|
mListPanel = root.findViewById(R.id.list_panel);
|
||||||
mNoMessagesPanel = root.findViewById(R.id.no_messages_panel);
|
mNoMessagesPanel = root.findViewById(R.id.no_messages_panel);
|
||||||
((Button) mSendPanel.findViewById(R.id.send_messages)).setOnClickListener(this);
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,6 +301,27 @@ public class MessageListFragment extends ListFragment
|
|||||||
mSelectedMessageId = savedInstanceState.getLong(BUNDLE_KEY_SELECTED_MESSAGE_ID);
|
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) {
|
public void setCallback(Callback callback) {
|
||||||
mCallback = (callback != null) ? callback : EmptyCallback.INSTANCE;
|
mCallback = (callback != null) ? callback : EmptyCallback.INSTANCE;
|
||||||
}
|
}
|
||||||
@ -393,15 +413,6 @@ public class MessageListFragment extends ListFragment
|
|||||||
return mSelectionMode != null;
|
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.
|
* Called when a message is clicked.
|
||||||
*/
|
*/
|
||||||
@ -834,16 +845,13 @@ public class MessageListFragment extends ListFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideSendPanel() {
|
private void showSendCommand(boolean show) {
|
||||||
mSendPanel.setVisibility(View.GONE);
|
mShowSendCommand = show;
|
||||||
|
mActivity.invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSendPanelIfNecessary() {
|
private void showSendCommandIfNecessary() {
|
||||||
final boolean show =
|
showSendCommand(isOutbox() && (mListAdapter != null) && (mListAdapter.getCount() > 0));
|
||||||
isOutbox()
|
|
||||||
&& (mListAdapter != null)
|
|
||||||
&& (mListAdapter.getCount() > 0);
|
|
||||||
mSendPanel.setVisibility(show ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showNoMessageText(boolean visible) {
|
private void showNoMessageText(boolean visible) {
|
||||||
@ -866,7 +874,7 @@ public class MessageListFragment extends ListFragment
|
|||||||
// Clear the list. (ListFragment will show the "Loading" animation)
|
// Clear the list. (ListFragment will show the "Loading" animation)
|
||||||
showNoMessageText(false);
|
showNoMessageText(false);
|
||||||
setListShown(false);
|
setListShown(false);
|
||||||
hideSendPanel();
|
showSendCommand(false);
|
||||||
|
|
||||||
// Start loading...
|
// Start loading...
|
||||||
final LoaderManager lm = getLoaderManager();
|
final LoaderManager lm = getLoaderManager();
|
||||||
@ -988,7 +996,7 @@ public class MessageListFragment extends ListFragment
|
|||||||
autoRefreshStaleMailbox();
|
autoRefreshStaleMailbox();
|
||||||
addFooterView();
|
addFooterView();
|
||||||
updateSelectionMode();
|
updateSelectionMode();
|
||||||
showSendPanelIfNecessary();
|
showSendCommandIfNecessary();
|
||||||
showNoMessageTextIfNecessary();
|
showNoMessageTextIfNecessary();
|
||||||
|
|
||||||
// We want to make selection visible only when the loader was explicitly started.
|
// We want to make selection visible only when the loader was explicitly started.
|
||||||
|
Loading…
Reference in New Issue
Block a user