Show sending status only in outbox; don't allow outbox messages to be moved
This commit is contained in:
@@ -26,16 +26,18 @@ public class EmailListAdapter extends ArrayAdapter<Email> {
|
||||
private final LayoutInflater mInflater;
|
||||
private SparseBooleanArray mSelectedEmails;
|
||||
private EmailSelector mSelector;
|
||||
private boolean mIsOutbox;
|
||||
|
||||
public interface EmailSelector {
|
||||
public void select(int position);
|
||||
}
|
||||
|
||||
public EmailListAdapter(Context context, EmailSelector selector) {
|
||||
public EmailListAdapter(Context context, EmailSelector selector, boolean isOutbox) {
|
||||
super(context, android.R.layout.simple_list_item_2);
|
||||
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mSelectedEmails = new SparseBooleanArray();
|
||||
mSelector = selector;
|
||||
mIsOutbox = isOutbox;
|
||||
}
|
||||
|
||||
public void setData(List<Email> emails) {
|
||||
@@ -95,9 +97,14 @@ public class EmailListAdapter extends ArrayAdapter<Email> {
|
||||
from.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
}
|
||||
|
||||
// Set email status if we sent it
|
||||
if (BoteHelper.isSentEmail(email)) {
|
||||
TextView emailStatus = (TextView) v.findViewById(R.id.email_status);
|
||||
TextView emailStatus = (TextView) v.findViewById(R.id.email_status);
|
||||
// Set email sending status if this is the outbox,
|
||||
// or set email delivery status if we sent it.
|
||||
if (mIsOutbox) {
|
||||
emailStatus.setText(BoteHelper.getEmailStatusText(
|
||||
getContext(), email, false));
|
||||
emailStatus.setVisibility(View.VISIBLE);
|
||||
} else if (BoteHelper.isSentEmail(email)) {
|
||||
if (email.isDelivered())
|
||||
emailStatus.setCompoundDrawablesWithIntrinsicBounds(
|
||||
getContext().getResources().getDrawable(
|
||||
@@ -105,9 +112,6 @@ public class EmailListAdapter extends ArrayAdapter<Email> {
|
||||
null, null, null);
|
||||
else if (email.getDeliveryPercentage() > 0)
|
||||
emailStatus.setText(email.getDeliveryPercentage() + "%");
|
||||
else
|
||||
emailStatus.setText(BoteHelper.getEmailStatusText(
|
||||
getContext(), email, false));
|
||||
emailStatus.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} catch (MessagingException e) {
|
||||
|
||||
@@ -93,9 +93,10 @@ public class EmailListFragment extends ListFragment implements
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mAdapter = new EmailListAdapter(getActivity(), this);
|
||||
String folderName = getArguments().getString(FOLDER_NAME);
|
||||
mFolder = BoteHelper.getMailFolder(folderName);
|
||||
mAdapter = new EmailListAdapter(getActivity(), this,
|
||||
BoteHelper.isOutbox(mFolder));
|
||||
|
||||
setListAdapter(mAdapter);
|
||||
|
||||
@@ -317,6 +318,8 @@ public class EmailListFragment extends ListFragment implements
|
||||
// Inflate the menu for the CAB
|
||||
MenuInflater inflater = mode.getMenuInflater();
|
||||
inflater.inflate(R.menu.email_list_context, menu);
|
||||
if (BoteHelper.isOutbox(mFolder))
|
||||
menu.findItem(R.id.action_move_to).setVisible(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -198,4 +198,8 @@ public class BoteHelper extends GeneralHelper {
|
||||
return res.getString(R.string.error);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isOutbox(EmailFolder folder) {
|
||||
return "Outbox".equalsIgnoreCase(folder.getName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user