1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-15 22:15:15 -05:00

Update action mode title when necessary

This commit is contained in:
cketti 2012-09-13 06:41:04 +02:00
parent d9fad383eb
commit 997943a521

View File

@ -722,9 +722,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
mSelectedCount = getSelectionFromCheckboxes().size(); mSelectedCount = getSelectionFromCheckboxes().size();
if (mSelectedCount > 0) { if (mSelectedCount > 0) {
mActionMode = MessageList.this.startActionMode(mActionModeCallback); mActionMode = MessageList.this.startActionMode(mActionModeCallback);
mActionMode.setTitle(String.format( updateActionModeTitle();
getString(R.string.actionbar_selected),
mSelectedCount));
} }
} }
@ -2457,8 +2455,12 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
} }
mAdapter.notifyDataSetChanged(); mAdapter.notifyDataSetChanged();
if (isSelected) {
updateActionModeTitle();
computeSelectAllVisibility(); computeSelectAllVisibility();
} }
}
/** /**
* Toggle all selected message states. Sort of. If anything selected, unselect everything. If nothing is * Toggle all selected message states. Sort of. If anything selected, unselect everything. If nothing is
@ -2477,7 +2479,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
if (newState) { if (newState) {
mSelectedCount = mAdapter.getCount(); mSelectedCount = mAdapter.getCount();
mActionMode = MessageList.this.startActionMode(mActionModeCallback); mActionMode = MessageList.this.startActionMode(mActionModeCallback);
mActionMode.setTitle(String.format(getString(R.string.actionbar_selected), mSelectedCount)); updateActionModeTitle();
computeSelectAllVisibility(); computeSelectAllVisibility();
} else { } else {
mSelectedCount = 0; mSelectedCount = 0;
@ -2493,6 +2495,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
} }
} }
mAdapter.notifyDataSetChanged(); mAdapter.notifyDataSetChanged();
updateActionModeTitle();
computeSelectAllVisibility(); computeSelectAllVisibility();
} }
@ -2514,7 +2517,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
mSelectedCount += 1; mSelectedCount += 1;
} }
mAdapter.notifyDataSetChanged(); mAdapter.notifyDataSetChanged();
mActionMode.setTitle(String.format(getString(R.string.actionbar_selected), mSelectedCount)); updateActionModeTitle();
// make sure the onPrepareActionMode is called // make sure the onPrepareActionMode is called
mActionMode.invalidate(); mActionMode.invalidate();
@ -2522,6 +2525,10 @@ public class MessageList extends K9ListActivity implements OnItemClickListener {
computeSelectAllVisibility(); computeSelectAllVisibility();
} }
private void updateActionModeTitle() {
mActionMode.setTitle(String.format(getString(R.string.actionbar_selected), mSelectedCount));
}
private void computeSelectAllVisibility() { private void computeSelectAllVisibility() {
mActionModeCallback.showSelectAll(mSelectedCount != mAdapter.getCount()); mActionModeCallback.showSelectAll(mSelectedCount != mAdapter.getCount());
} }