Hide bottom buttons when message list enters selection mode
Hide the command buttons at the bottom of the message view when the message list enters the selection mode. Change-Id: Id825bb5183673e9def055b6480fa180beab51178
This commit is contained in:
parent
c8fb75035f
commit
2dbb510657
|
@ -285,6 +285,10 @@ public class MessageList extends Activity implements OnClickListener,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnterSelectionMode(boolean enter) {
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btn_read_unread:
|
||||
|
|
|
@ -159,6 +159,12 @@ public class MessageListFragment extends ListFragment
|
|||
*/
|
||||
public void onMessageOpen(long messageId, long messageMailboxId, long listMailboxId,
|
||||
int type);
|
||||
|
||||
/**
|
||||
* Called when entering/leaving selection mode.
|
||||
* @param enter true if entering, false if leaving
|
||||
*/
|
||||
public void onEnterSelectionMode(boolean enter);
|
||||
}
|
||||
|
||||
private static final class EmptyCallback implements Callback {
|
||||
|
@ -171,6 +177,9 @@ public class MessageListFragment extends ListFragment
|
|||
public void onMessageOpen(
|
||||
long messageId, long messageMailboxId, long listMailboxId, int type) {
|
||||
}
|
||||
@Override
|
||||
public void onEnterSelectionMode(boolean enter) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -363,7 +372,7 @@ public class MessageListFragment extends ListFragment
|
|||
/**
|
||||
* @return true if the list is in the "selection" mode.
|
||||
*/
|
||||
private boolean isInSelectionMode() {
|
||||
public boolean isInSelectionMode() {
|
||||
return mSelectionMode != null;
|
||||
}
|
||||
|
||||
|
@ -1001,6 +1010,8 @@ public class MessageListFragment extends ListFragment
|
|||
mMarkUnread = menu.findItem(R.id.mark_unread);
|
||||
mAddStar = menu.findItem(R.id.add_star);
|
||||
mRemoveStar = menu.findItem(R.id.remove_star);
|
||||
|
||||
mCallback.onEnterSelectionMode(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1044,6 +1055,7 @@ public class MessageListFragment extends ListFragment
|
|||
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
mCallback.onEnterSelectionMode(false);
|
||||
onDeselectAll();
|
||||
mSelectionMode = null;
|
||||
}
|
||||
|
|
|
@ -366,6 +366,14 @@ public class MessageListXL extends Activity implements
|
|||
public void onMailboxNotFound() {
|
||||
// TODO: What to do??
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnterSelectionMode(boolean enter) {
|
||||
MessageViewFragment f = mFragmentManager.getMessageViewFragment();
|
||||
if (f != null) {
|
||||
f.showCommandbuttons(!enter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MessageViewFragmentCallback implements MessageViewFragment.Callback {
|
||||
|
@ -458,6 +466,15 @@ public class MessageListXL extends Activity implements
|
|||
public void onReplyAll() {
|
||||
MessageCompose.actionReply(MessageListXL.this, mFragmentManager.getMessageId(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldShowCommandButtons() {
|
||||
MessageListFragment f = mFragmentManager.getMessageListFragment();
|
||||
if (f == null) {
|
||||
return true;
|
||||
}
|
||||
return !f.isInSelectionMode();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -94,9 +94,6 @@ public class MessageView extends MessageViewBase implements View.OnClickListener
|
|||
findViewById(R.id.reply_all).setOnClickListener(this);
|
||||
findViewById(R.id.delete).setOnClickListener(this);
|
||||
|
||||
// For now, we don't use the buttons in the fragment, so let's hide them manually...
|
||||
mFragment.hideCommandButtons();
|
||||
|
||||
initFromIntent();
|
||||
if (icicle != null) {
|
||||
mMessageId = icicle.getLong(STATE_MESSAGE_ID, mMessageId);
|
||||
|
@ -366,4 +363,9 @@ public class MessageView extends MessageViewBase implements View.OnClickListener
|
|||
public void onMoveMessage() {
|
||||
// TODO Implement this
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldShowCommandButtons() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,6 +112,12 @@ public class MessageViewFragment extends MessageViewFragmentBase {
|
|||
public void onReply();
|
||||
/** Called when the reply-all button is pressed. */
|
||||
public void onReplyAll();
|
||||
|
||||
/**
|
||||
* The fragment call it to see if the command buttons should be shown.
|
||||
* (We want to hide them if the message list is in the selection mode.)
|
||||
*/
|
||||
public boolean shouldShowCommandButtons();
|
||||
}
|
||||
|
||||
public static final class EmptyCallback extends MessageViewFragmentBase.EmptyCallback
|
||||
|
@ -128,6 +134,7 @@ public class MessageViewFragment extends MessageViewFragmentBase {
|
|||
@Override public void onForward() { }
|
||||
@Override public void onReply() { }
|
||||
@Override public void onReplyAll() { }
|
||||
@Override public boolean shouldShowCommandButtons() { return true; }
|
||||
}
|
||||
|
||||
private Callback mCallback = EmptyCallback.INSTANCE;
|
||||
|
@ -167,16 +174,26 @@ public class MessageViewFragment extends MessageViewFragmentBase {
|
|||
return view;
|
||||
}
|
||||
|
||||
public void setCallback(Callback callback) {
|
||||
mCallback = (callback == null) ? EmptyCallback.INSTANCE : callback;
|
||||
super.setCallback(mCallback);
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
initCommandButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated TODO Remove this call from MessageView
|
||||
* Initialize command buttons
|
||||
* - Hide the panel if not necessary
|
||||
* - Disable the buttons that can be disabled (to avoid flicker)
|
||||
*/
|
||||
public void hideCommandButtons() {
|
||||
mCommandButtons.setVisibility(View.GONE);
|
||||
private void initCommandButtons() {
|
||||
showCommandbuttons(mCallback.shouldShowCommandButtons());
|
||||
mCommandButtons.enableNavigationButons(false, false);
|
||||
mCommandButtons.enableReplyForwardButtons(false);
|
||||
}
|
||||
|
||||
public void setCallback(Callback callback) {
|
||||
mCallback = (callback == null) ? EmptyCallback.INSTANCE : callback;
|
||||
super.setCallback(mCallback);
|
||||
}
|
||||
|
||||
/** Called by activities to set an id of a message to open. */
|
||||
|
@ -215,6 +232,10 @@ public class MessageViewFragment extends MessageViewFragmentBase {
|
|||
&& (mailboxType != Mailbox.TYPE_TRASH));
|
||||
}
|
||||
|
||||
public void showCommandbuttons(boolean show) {
|
||||
mCommandButtons.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
public void enableNavigationButons(boolean enableMoveToNewer, boolean enableMoveToOlder) {
|
||||
mCommandButtons.enableNavigationButons(enableMoveToNewer, enableMoveToOlder);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue