Don't show the action as we are swiping, just on the leavebehind.

Fixes part of b/6926116 need visual design for swipe

Change-Id: I2f53e5b652ee687f7046306064917e55b7ea005e
diff --git a/res/layout/background.xml b/res/layout/background.xml
index fc067ec..84b03a5 100644
--- a/res/layout/background.xml
+++ b/res/layout/background.xml
@@ -15,15 +15,11 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+<View xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/background"
         android:layout_width="match_parent"
         android:minHeight="@dimen/conversation_item_height"
         android:ellipsize="end"
         android:gravity="center_vertical"
         android:paddingLeft="16dip"
-        android:singleLine="true"
-        android:text="@string/no_conversations"
-        android:textColor="@android:color/white"
-        android:background="@color/leaveBehindBackground"
-        android:textSize="16sp" />
\ No newline at end of file
+        android:background="@color/leaveBehindBackground" />
\ No newline at end of file
diff --git a/res/values/animation_constants.xml b/res/values/animation_constants.xml
index 977f942..0bcdf25 100644
--- a/res/values/animation_constants.xml
+++ b/res/values/animation_constants.xml
@@ -26,6 +26,7 @@
     <integer name="dialog_animationShortDur">150</integer>
     <integer name="shrink_animation_duration">350</integer>
     <integer name="slide_animation_duration">350</integer>
+    <integer name="fade_in_animation_duration">350</integer>
 
     <!-- Swipe constants -->
     <integer name="swipe_escape_velocity">100</integer>
diff --git a/src/com/android/mail/browse/SwipeableConversationItemView.java b/src/com/android/mail/browse/SwipeableConversationItemView.java
index 6e736e7..a8c8625 100644
--- a/src/com/android/mail/browse/SwipeableConversationItemView.java
+++ b/src/com/android/mail/browse/SwipeableConversationItemView.java
@@ -23,7 +23,6 @@
 import android.view.View;
 import android.widget.FrameLayout;
 import android.widget.ListView;
-import android.widget.TextView;
 
 import com.android.mail.R;
 import com.android.mail.providers.Conversation;
@@ -36,7 +35,7 @@
 public class SwipeableConversationItemView extends FrameLayout {
 
     private ConversationItemView mConversationItemView;
-    private TextView mBackground;
+    private View mBackground;
 
     public SwipeableConversationItemView(Context context, String account) {
         super(context);
@@ -44,14 +43,12 @@
         addView(mConversationItemView);
     }
 
-    public void addBackground(Context context, String text) {
-        mBackground = (TextView) findViewById(R.id.background);
+    public void addBackground(Context context) {
+        mBackground = findViewById(R.id.background);
         if (mBackground == null) {
-            mBackground = (TextView) LayoutInflater.from(context).inflate(R.layout.background,
-                    null, true);
+            mBackground = LayoutInflater.from(context).inflate(R.layout.background, null, true);
             addView(mBackground, 0);
         }
-        mBackground.setText(text);
     }
 
     public void setBackgroundVisibility(int visibility) {
@@ -87,10 +84,9 @@
                 priorityArrowsEnabled, animatedAdapter);
     }
 
-    public void startUndoAnimation(String actionText, ViewMode viewMode, AnimatedAdapter listener,
-            boolean swipe) {
+    public void startUndoAnimation(ViewMode viewMode, AnimatedAdapter listener, boolean swipe) {
         if (swipe) {
-            addBackground(getContext(), actionText);
+            addBackground(getContext());
             setBackgroundVisibility(View.VISIBLE);
             mConversationItemView.startSwipeUndoAnimation(viewMode, listener);
         } else {
diff --git a/src/com/android/mail/ui/AnimatedAdapter.java b/src/com/android/mail/ui/AnimatedAdapter.java
index fb16677..8d46ac9 100644
--- a/src/com/android/mail/ui/AnimatedAdapter.java
+++ b/src/com/android/mail/ui/AnimatedAdapter.java
@@ -297,7 +297,9 @@
         if (hasLeaveBehinds()) {
             Conversation conv = new Conversation((ConversationCursor) getItem(position));
             if(isPositionLeaveBehind(conv)) {
-                return getLeaveBehindItem(conv);
+                LeaveBehindItem fadeIn = getLeaveBehindItem(conv);
+                fadeIn.startFadeInAnimation();
+                return fadeIn;
             }
         }
         if (convertView != null && !(convertView instanceof SwipeableConversationItemView)) {
@@ -396,8 +398,7 @@
             // The undo animation consists of fading in the conversation that
             // had been destroyed.
             undoView = newConversationItemView(position, parent, conversation);
-            undoView.startUndoAnimation(mListView.getSwipeActionText(), mActivity.getViewMode(),
-                    this, swipe);
+            undoView.startUndoAnimation(mActivity.getViewMode(), this, swipe);
         }
         return undoView;
     }
diff --git a/src/com/android/mail/ui/LeaveBehindItem.java b/src/com/android/mail/ui/LeaveBehindItem.java
index f37f200..8e29e53 100644
--- a/src/com/android/mail/ui/LeaveBehindItem.java
+++ b/src/com/android/mail/ui/LeaveBehindItem.java
@@ -45,7 +45,9 @@
     private Account mAccount;
     private AnimatedAdapter mAdapter;
     private ConversationCursor mConversationCursor;
+    private TextView mText;
     private static int sShrinkAnimationDuration = -1;
+    private static int sFadeInAnimationDuration = -1;
 
     public LeaveBehindItem(Context context) {
         this(context, null);
@@ -60,6 +62,8 @@
         if (sShrinkAnimationDuration == -1) {
             sShrinkAnimationDuration = context.getResources().getInteger(
                     R.integer.shrink_animation_duration);
+            sFadeInAnimationDuration = context.getResources().getInteger(
+                    R.integer.fade_in_animation_duration);
         }
     }
 
@@ -89,7 +93,8 @@
         mAdapter = adapter;
         mConversationCursor = (ConversationCursor) adapter.getCursor();
         setData(target);
-        ((TextView) findViewById(R.id.undo_descriptionview)).setText(Html.fromHtml(mUndoOp
+        mText = ((TextView) findViewById(R.id.undo_descriptionview));
+        mText.setText(Html.fromHtml(mUndoOp
                 .getSingularDescription(getContext(), folder)));
         findViewById(R.id.undo_text).setOnClickListener(this);
         findViewById(R.id.undo_icon).setOnClickListener(this);
@@ -170,6 +175,7 @@
     private int mAnimatedHeight = -1;
     private int mWidth;
     private boolean mAnimating;
+    private boolean mFadingInText;
 
     /**
      * Start the animation on an animating view.
@@ -195,6 +201,19 @@
         }
     }
 
+
+    public void startFadeInAnimation() {
+        if (!mFadingInText) {
+            mFadingInText = true;
+            final float start = 0;
+            final float end = 1.0f;
+            ObjectAnimator fadeIn = ObjectAnimator.ofFloat(mText, "alpha", start, end);
+            fadeIn.setInterpolator(new DecelerateInterpolator(2.0f));
+            fadeIn.setDuration(sFadeInAnimationDuration);
+            fadeIn.start();
+        }
+    }
+
     public void setData(Conversation conversation) {
         mData = conversation;
     }
diff --git a/src/com/android/mail/ui/SwipeableListView.java b/src/com/android/mail/ui/SwipeableListView.java
index 16792e6..4841242 100644
--- a/src/com/android/mail/ui/SwipeableListView.java
+++ b/src/com/android/mail/ui/SwipeableListView.java
@@ -222,7 +222,7 @@
             view = (SwipeableConversationItemView) v.getParent();
         }
         if (view != null) {
-            view.addBackground(getContext(), getSwipeActionText());
+            view.addBackground(getContext());
             view.setBackgroundVisibility(View.VISIBLE);
         }
     }
@@ -306,15 +306,4 @@
         commitDestructiveActions();
         return handled;
     }
-
-    /**
-     * Get the text resource corresponding to the result of a swipe.
-     */
-    public String getSwipeActionText() {
-        Resources res = getContext().getResources();
-        if (mSwipeAction == R.id.remove_folder) {
-            return res.getString(R.string.remove_folder, mFolder.name);
-        }
-        return res.getString(mSwipeAction == R.id.archive ? R.string.archive : R.string.delete);
-    }
 }