Delay showing undo bar for a bit after the destructive animations complete.

Allows the user to visually process what just happened.
Fixes b/7022263 Cab mode should exit on taking action not after action complete

Bug name is wrong; read details to see what we decided on

Change-Id: Ia7eb81053adb22e5003ae85fc719ea9a69883ef3
diff --git a/res/values/constants.xml b/res/values/constants.xml
index d4d1038..0904f6c 100644
--- a/res/values/constants.xml
+++ b/res/values/constants.xml
@@ -48,6 +48,8 @@
     <!-- We don't want the unread count to flicker too much in the action bar, when a lot of
     activity.  Throttle loader updates. -->
     <integer name="folder_item_refresh_delay_ms">500</integer>
+    <!-- Delay showing undo bar after a destructive action long enough for the user to process the animations for what just happened -->
+    <integer name="show_undo_bar_delay_ms">500</integer>
     <integer name="conversation_desired_font_size_px">14</integer>
     <!-- matches 'font-size' style in template_conversation_upper.html -->
     <integer name="conversation_unstyled_font_size_px">13</integer>
diff --git a/src/com/android/mail/ui/AbstractActivityController.java b/src/com/android/mail/ui/AbstractActivityController.java
index 30a29b5..9211f80 100644
--- a/src/com/android/mail/ui/AbstractActivityController.java
+++ b/src/com/android/mail/ui/AbstractActivityController.java
@@ -252,6 +252,7 @@
     private AsyncTask<String, Void, Void> mEnableShareIntents;
     private Folder mFolderListFolder;
     private boolean mIsDragHappening;
+    private int mShowUndoBarDelay;
     public static final String SYNC_ERROR_DIALOG_FRAGMENT_TAG = "SyncErrorDialogFragment";
 
     public AbstractActivityController(MailActivity activity, ViewMode viewMode) {
@@ -267,6 +268,8 @@
 
         mFolderItemUpdateDelayMs =
                 mContext.getResources().getInteger(R.integer.folder_item_refresh_delay_ms);
+        mShowUndoBarDelay =
+                mContext.getResources().getInteger(R.integer.show_undo_bar_delay_ms);
     }
 
     @Override
@@ -1868,8 +1871,13 @@
                     break;
             }
             if (undoEnabled) {
-                onUndoAvailable(new ToastBarOperation(mTarget.size(), mAction,
-                        ToastBarOperation.UNDO));
+                mHandler.postDelayed(new Runnable() {
+                    @Override
+                    public void run() {
+                        onUndoAvailable(new ToastBarOperation(mTarget.size(), mAction,
+                                ToastBarOperation.UNDO));
+                    }
+                }, mShowUndoBarDelay);
             }
             refreshConversationList();
             if (mIsSelectedSet) {