Merge "Move over updated widget background drawables from the jb-dev branch" into jb-ub-mail
diff --git a/src/com/android/mail/browse/SelectedConversationsActionMenu.java b/src/com/android/mail/browse/SelectedConversationsActionMenu.java
index 294418f..5d8891e 100644
--- a/src/com/android/mail/browse/SelectedConversationsActionMenu.java
+++ b/src/com/android/mail/browse/SelectedConversationsActionMenu.java
@@ -36,7 +36,6 @@
import com.android.mail.providers.UIProvider;
import com.android.mail.providers.UIProvider.ConversationColumns;
import com.android.mail.providers.UIProvider.FolderCapabilities;
-import com.android.mail.ui.AnimatedAdapter;
import com.android.mail.ui.ControllableActivity;
import com.android.mail.ui.ConversationSelectionSet;
import com.android.mail.ui.ConversationSetObserver;
@@ -75,14 +74,12 @@
private final Context mContext;
@VisibleForTesting
- ActionMode mActionMode;
+ private ActionMode mActionMode;
private boolean mActivated = false;
private Menu mMenu;
- private AnimatedAdapter mListAdapter;
-
/** Object that can update conversation state on our behalf. */
private final ConversationUpdater mUpdater;
@@ -93,11 +90,10 @@
private final SwipeableListView mListView;
public SelectedConversationsActionMenu(RestrictedActivity activity,
- ConversationSelectionSet selectionSet, AnimatedAdapter adapter, Account account,
+ ConversationSelectionSet selectionSet, Account account,
Folder folder, SwipeableListView list) {
mActivity = activity;
mSelectionSet = selectionSet;
- mListAdapter = adapter;
mAccount = account;
mFolder = folder;
mListView = list;
@@ -118,10 +114,10 @@
performDestructiveAction(R.id.archive);
break;
case R.id.mute:
- mListAdapter.delete(conversations, mUpdater.getBatchAction(R.id.mute));
+ mUpdater.delete(conversations, mUpdater.getBatchAction(R.id.mute));
break;
case R.id.report_spam:
- mListAdapter.delete(conversations, mUpdater.getBatchAction(R.id.report_spam));
+ mUpdater.delete(conversations, mUpdater.getBatchAction(R.id.report_spam));
break;
case R.id.read:
markConversationsRead(true);
@@ -196,7 +192,7 @@
* Update the underlying list adapter and redraw the menus if necessary.
*/
private void updateSelection() {
- mListAdapter.notifyDataSetChanged();
+ mUpdater.refreshConversationList();
if (mActionMode != null) {
// Calling mActivity.invalidateOptionsMenu doesn't have the correct behavior, since
// the action mode is not refreshed when activity's options menu is invalidated.
@@ -228,7 +224,6 @@
}
}
-
private void destroy(int id, final Collection<Conversation> conversations,
final DestructiveAction listener) {
if (id == R.id.archive) {
@@ -238,7 +233,7 @@
}
mListView.archiveItems(views, listener);
} else {
- mListAdapter.delete(conversations, listener);
+ mUpdater.delete(conversations, listener);
}
}
@@ -405,7 +400,7 @@
deactivate();
mSelectionSet.removeObserver(this);
clearSelection();
- mListAdapter.notifyDataSetChanged();
+ mUpdater.refreshConversationList();
}
/**
diff --git a/src/com/android/mail/ui/AbstractActivityController.java b/src/com/android/mail/ui/AbstractActivityController.java
index 0acbc0f..32a27a3 100644
--- a/src/com/android/mail/ui/AbstractActivityController.java
+++ b/src/com/android/mail/ui/AbstractActivityController.java
@@ -623,10 +623,10 @@
ConversationColumns.PRIORITY, UIProvider.ConversationPriority.LOW);
break;
case R.id.mute:
- requestDelete(target, getAction(R.id.mute, target));
+ delete(target, getAction(R.id.mute, target));
break;
case R.id.report_spam:
- requestDelete(target, getAction(R.id.report_spam, target));
+ delete(target, getAction(R.id.report_spam, target));
break;
case R.id.inside_conversation_unread:
// TODO(viki): This is strange, and potentially incorrect. READ is an int column
@@ -718,7 +718,7 @@
final AlertDialog.OnClickListener onClick = new AlertDialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- requestDelete(target, action);
+ delete(target, action);
}
};
final CharSequence message = Utils.formatPlural(mContext, confirmResource,
@@ -728,16 +728,12 @@
.setNegativeButton(R.string.cancel, null)
.create().show();
} else {
- requestDelete(target, action);
+ delete(target, action);
}
}
- /**
- * Requests the removal of the current conversation with the specified destructive action.
- * @param action
- */
- protected void requestDelete(final Collection<Conversation> target,
- final DestructiveAction action) {
+ @Override
+ public void delete(final Collection<Conversation> target, final DestructiveAction action) {
// The conversation list handles deletion if it exists.
final ConversationListFragment convList = getConversationListFragment();
if (convList != null) {
@@ -763,7 +759,7 @@
* @param target
* @param action
*/
- protected void requestUpdate(final Collection<Conversation> target,
+ private void requestUpdate(final Collection<Conversation> target,
final DestructiveAction action) {
action.performAction();
refreshConversationList();
@@ -1563,7 +1559,7 @@
// Update the UI elements depending no their visibility and availability
// TODO(viki): Consolidate this into a single method requestDelete.
if (isDestructive) {
- requestDelete(target, folderChange);
+ delete(target, folderChange);
} else {
requestUpdate(target, folderChange);
}
@@ -1681,8 +1677,7 @@
if (convList == null) {
return;
}
- mCabActionMenu = new SelectedConversationsActionMenu(mActivity, set,
- convList.getAnimatedAdapter(), mAccount, mFolder,
+ mCabActionMenu = new SelectedConversationsActionMenu(mActivity, set, mAccount, mFolder,
(SwipeableListView) convList.getListView());
enableCabMode();
}
@@ -1765,7 +1760,7 @@
final Collection<Folder> dropTarget = Folder.listOf(folder);
// Drag and drop is destructive: we remove conversations from the current folder.
final DestructiveAction action = getFolderChange(conversations, dropTarget, true, true);
- requestDelete(conversations, action);
+ delete(conversations, action);
}
@Override
@@ -1976,10 +1971,8 @@
return da;
}
- /**
- * Safely refresh the conversation list if it exists.
- */
- protected final void refreshConversationList() {
+ @Override
+ public final void refreshConversationList() {
final ConversationListFragment convList = getConversationListFragment();
if (convList == null) {
return;
diff --git a/src/com/android/mail/ui/ConversationUpdater.java b/src/com/android/mail/ui/ConversationUpdater.java
index 60cb4ee..45dbf91 100644
--- a/src/com/android/mail/ui/ConversationUpdater.java
+++ b/src/com/android/mail/ui/ConversationUpdater.java
@@ -58,6 +58,13 @@
void updateConversation(Collection <Conversation> target, String columnName, boolean value);
/**
+ * Requests the removal of the current conversation with the specified destructive action.
+ * @param target the conversations to act upon.
+ * @param action to perform after the UI has been updated to remove the conversations
+ */
+ void delete(final Collection<Conversation> target, final DestructiveAction action);
+
+ /**
* Get a destructive action for selected conversations. The action corresponds to Menu item
* identifiers, for example R.id.unread, or R.id.delete.
* @param action
@@ -74,4 +81,9 @@
*/
public void assignFolder(
Collection<Folder> folders, Collection<Conversation> target, boolean batch);
+
+ /**
+ * Refreshes the conversation list, if one exists.
+ */
+ void refreshConversationList();
}