mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-02 00:25:10 -04:00
Have a dynamic context actionbar filled with options that are supported by the current selection of mails. Also works for unified inbox.
This commit is contained in:
parent
35e8937b8a
commit
a730e67514
@ -2336,6 +2336,11 @@ public class MessageList extends K9ListActivity implements
|
||||
}
|
||||
mAdapter.notifyDataSetChanged();
|
||||
mActionMode.setTitle(mSelectedCount+" "+getString(R.string.actionbar_selected));
|
||||
|
||||
if (mQueryString != null) {
|
||||
// we might have to disable some options
|
||||
mActionMode.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2678,8 +2683,28 @@ public class MessageList extends K9ListActivity implements
|
||||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
if (mQueryString != null) {
|
||||
// show all
|
||||
menu.findItem(R.id.move).setVisible(true);
|
||||
menu.findItem(R.id.archive).setVisible(true);
|
||||
menu.findItem(R.id.spam).setVisible(true);
|
||||
menu.findItem(R.id.copy).setVisible(true);
|
||||
|
||||
// hide uncapable
|
||||
/*
|
||||
* TODO think of a better way then looping over all
|
||||
* messages.
|
||||
*/
|
||||
final List<MessageInfoHolder> selection = getSelectionFromCheckboxes();
|
||||
Account account;
|
||||
|
||||
for (MessageInfoHolder holder : selection) {
|
||||
account = holder.message.getFolder().getAccount();
|
||||
setContextCapabilities(account, menu);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2692,9 +2717,36 @@ public class MessageList extends K9ListActivity implements
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
MenuInflater inflater = mode.getMenuInflater();
|
||||
inflater.inflate(R.menu.message_list_context, menu);
|
||||
|
||||
// check capabilities
|
||||
if (mQueryString == null) {
|
||||
setContextCapabilities(mAccount, menu);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setContextCapabilities(Account mAccount, Menu menu) {
|
||||
// hide unsupported
|
||||
if (!mController.isCopyCapable(mAccount)) {
|
||||
menu.findItem(R.id.copy).setVisible(false);
|
||||
}
|
||||
|
||||
if (!mController.isMoveCapable(mAccount)) {
|
||||
menu.findItem(R.id.move).setVisible(false);
|
||||
menu.findItem(R.id.archive).setVisible(false);
|
||||
menu.findItem(R.id.spam).setVisible(false);
|
||||
}
|
||||
|
||||
if (!mAccount.hasArchiveFolder()) {
|
||||
menu.findItem(R.id.archive).setVisible(false);
|
||||
}
|
||||
|
||||
if (!mAccount.hasSpamFolder()) {
|
||||
menu.findItem(R.id.spam).setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
final List<MessageInfoHolder> selection = getSelectionFromCheckboxes();
|
||||
|
Loading…
Reference in New Issue
Block a user