1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 19:52:17 -05:00

Make the message item popup menu work

This commit is contained in:
Jesse Vincent 2012-09-12 20:58:44 -04:00
parent 7b40e5b14a
commit 1b7af9270e

View File

@ -48,7 +48,6 @@ import android.widget.Toast;
import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.internal.view.menu.MenuBuilder; import com.actionbarsherlock.internal.view.menu.MenuBuilder;
import com.actionbarsherlock.internal.view.menu.MenuPopupHelper;
import com.actionbarsherlock.view.ActionMode; import com.actionbarsherlock.view.ActionMode;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuInflater;
@ -67,6 +66,7 @@ import com.fsck.k9.activity.setup.FolderSettings;
import com.fsck.k9.activity.setup.Prefs; import com.fsck.k9.activity.setup.Prefs;
import com.fsck.k9.controller.MessagingController; import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.controller.MessagingListener; import com.fsck.k9.controller.MessagingListener;
import com.fsck.k9.helper.MenuPopup;
import com.fsck.k9.helper.MessageHelper; import com.fsck.k9.helper.MessageHelper;
import com.fsck.k9.helper.Utility; import com.fsck.k9.helper.Utility;
import com.fsck.k9.mail.Flag; import com.fsck.k9.mail.Flag;
@ -2045,6 +2045,8 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
} }
} }
private final OnClickListener flagClickListener = new OnClickListener() { private final OnClickListener flagClickListener = new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -2058,14 +2060,76 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// Perform action on clicks // Perform action on clicks
// setAllSelected(false); final MessageInfoHolder message = (MessageInfoHolder) getItem((Integer)v.getTag());
// openContextMenu(v); final MenuBuilder menu = new MenuBuilder(MessageList.this);
MenuBuilder menu = new MenuBuilder(MessageList.this); getSupportMenuInflater().inflate(R.menu.message_list_item_context, menu);
menu.add("something"); MenuPopup popup = new MenuPopup(MessageList.this, menu, v);
new MenuPopupHelper(MessageList.this, menu, v).show(); popup.setOnMenuItemClickListener( new MenuPopup.OnMenuItemClickListener() {
@Override
public void onMenuItemClick(int itemId){
MenuItem item = menu.getItem(itemId);
final List<MessageInfoHolder> selection = getSelectionFromMessage(message);
switch (item.getItemId()) {
case R.id.reply: {
onReply(message);
break;
}
case R.id.reply_all: {
onReplyAll(message);
break;
}
case R.id.forward: {
onForward(message);
break;
}
case R.id.send_again: {
onResendMessage(message);
mSelectedCount = 0;
break;
}
case R.id.same_sender: {
MessageList.actionHandle(MessageList.this, "From " + message.sender,
message.senderAddress, false, null, null);
break;
}
case R.id.delete: {
onDelete(selection);
break;
}
case R.id.read_toggle: {
onToggleRead(selection);
break;
}
case R.id.flag_toggle: {
onToggleFlag(selection);
break;
}
// only if the account supports this
case R.id.archive: {
onArchive(selection);
break;
}
case R.id.spam: {
onSpam(selection);
break;
}
case R.id.move: {
onMove(selection);
break;
}
case R.id.copy: {
onCopy(selection);
break;
}
}
} } );
popup.show();
} }
}; };
@Override @Override
public int getCount() { public int getCount() {
return mMessages.size(); return mMessages.size();
@ -2208,6 +2272,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
// XXX TODO there has to be some way to walk our view hierarchy and get this // XXX TODO there has to be some way to walk our view hierarchy and get this
holder.flagged.setTag(position); holder.flagged.setTag(position);
holder.itemMenu.setTag(position);
holder.flagged.setChecked(message.flagged); holder.flagged.setChecked(message.flagged);
// So that the mSelectedCount is only incremented/decremented // So that the mSelectedCount is only incremented/decremented
@ -2906,3 +2971,4 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
} }
}; };
} }