Revise remove view target positioning.

- Move placement from dialtacts activity layout to the lists fragment,
so that it can be positioned over the tab bar.
- Relocate references to RemoveView/RemoveViewContainer to the lists
fragment from the activity class.
- Set colors using tints, remove old highlight state asset.
- Fade out search bar and recent card when dragging.

Bug: 15434489
Change-Id: I49205c79aeb008a30efc3c2ea417b8836444e203
diff --git a/res/drawable-hdpi/ic_remove_highlight.png b/res/drawable-hdpi/ic_remove_highlight.png
deleted file mode 100644
index 435ee36..0000000
--- a/res/drawable-hdpi/ic_remove_highlight.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_remove_highlight.png b/res/drawable-mdpi/ic_remove_highlight.png
deleted file mode 100644
index 6a961cb..0000000
--- a/res/drawable-mdpi/ic_remove_highlight.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_remove_highlight.png b/res/drawable-xhdpi/ic_remove_highlight.png
deleted file mode 100644
index 57949e3..0000000
--- a/res/drawable-xhdpi/ic_remove_highlight.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_remove_highlight.png b/res/drawable-xxhdpi/ic_remove_highlight.png
deleted file mode 100644
index 23ee8f6..0000000
--- a/res/drawable-xxhdpi/ic_remove_highlight.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/dialtacts_activity.xml b/res/layout/dialtacts_activity.xml
index c7a788d..71e58cb 100644
--- a/res/layout/dialtacts_activity.xml
+++ b/res/layout/dialtacts_activity.xml
@@ -35,49 +35,8 @@
             android:layout_height="match_parent"
             android:layout_width="match_parent"
             android:id="@+id/dialtacts_frame"
-            android:clipChildren="false"
-            >
-        </FrameLayout>
-        <!-- Search entry box and remove view -->
-        <FrameLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_alignParentTop="true"
-            android:id="@+id/search_and_remove_view_container"
-            android:visibility="gone"
-            >
-        </FrameLayout>
+            android:clipChildren="false" />
     </RelativeLayout>
-    <com.android.dialer.list.RemoveView
-        android:layout_width="match_parent"
-        android:layout_height="56dp"
-        android:id="@+id/remove_view"
-        android:layout_alignParentTop="true"
-        >
-        <LinearLayout
-            android:id="@+id/remove_view_container"
-            android:layout_height="match_parent"
-            android:layout_width="match_parent"
-            android:gravity="center"
-            android:orientation="horizontal"
-            android:visibility="gone" >
-            <ImageView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:id="@+id/remove_view_icon"
-                android:src="@drawable/ic_remove"
-                android:contentDescription="@string/remove_contact"
-                />
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:id="@+id/remove_view_text"
-                android:textSize="@dimen/remove_text_size"
-                android:textColor="@color/remove_text_color"
-                android:text="@string/remove_contact"
-                />
-        </LinearLayout>
-    </com.android.dialer.list.RemoveView >
     <FrameLayout
         android:id="@+id/floating_action_button_container"
         android:layout_width="@dimen/floating_action_button_width"
diff --git a/res/layout/lists_fragment.xml b/res/layout/lists_fragment.xml
index 02dcbe3..1de8364 100644
--- a/res/layout/lists_fragment.xml
+++ b/res/layout/lists_fragment.xml
@@ -16,10 +16,11 @@
 
 <com.android.dialer.widget.OverlappingPaneLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/lists_frame"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:animateLayoutChanges="true"
-    android:id="@+id/lists_frame">
+    android:animateLayoutChanges="true" >
+
     <ListView
         android:id="@+id/shortcut_card_list"
         android:layout_width="match_parent"
@@ -29,24 +30,71 @@
         android:clipToPadding="false"
         android:fadingEdge="none"
         android:divider="@null" />
-    <LinearLayout
+
+    <FrameLayout
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
-        <com.android.dialer.list.ViewPagerTabs
-            android:id="@+id/lists_pager_header"
+        android:layout_height="match_parent">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical">
+
+            <com.android.dialer.list.ViewPagerTabs
+                android:id="@+id/lists_pager_header"
+                android:layout_width="match_parent"
+                android:layout_height="@dimen/tab_height"
+                android:textAllCaps="true"
+                android:orientation="horizontal"
+                android:layout_gravity="top"
+                android:elevation="@dimen/tab_elevation"
+                style="@style/DialtactsActionBarTabTextStyle" />
+
+            <android.support.v4.view.ViewPager
+                android:id="@+id/lists_pager"
+                android:layout_width="match_parent"
+                android:layout_height="0dp"
+                android:layout_weight="1" />
+
+        </LinearLayout>
+
+        <com.android.dialer.list.RemoveView
+            android:id="@+id/remove_view"
             android:layout_width="match_parent"
             android:layout_height="@dimen/tab_height"
-            android:textAllCaps="true"
-            android:orientation="horizontal"
-            android:layout_gravity="top"
-            android:elevation="@dimen/tab_elevation"
-            style="@style/DialtactsActionBarTabTextStyle" />
-        <android.support.v4.view.ViewPager
-            android:id="@+id/lists_pager"
-            android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:layout_weight="1">
-        </android.support.v4.view.ViewPager>
-    </LinearLayout>
+            android:layout_alignParentTop="true" >
+
+            <LinearLayout
+                android:id="@+id/remove_view_content"
+                android:layout_height="match_parent"
+                android:layout_width="match_parent"
+                android:background="@color/actionbar_background_color"
+                android:gravity="center"
+                android:orientation="horizontal"
+                android:visibility="gone" >
+
+                <ImageView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="8dp"
+                    android:layout_marginBottom="8dp"
+                    android:id="@+id/remove_view_icon"
+                    android:src="@drawable/ic_remove"
+                    android:contentDescription="@string/remove_contact"
+                    android:tint="@color/remove_text_color" />
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/remove_view_text"
+                    android:textSize="@dimen/remove_text_size"
+                    android:textColor="@color/remove_text_color"
+                    android:text="@string/remove_contact" />
+
+            </LinearLayout>
+
+        </com.android.dialer.list.RemoveView >
+
+    </FrameLayout>
+
 </com.android.dialer.widget.OverlappingPaneLayout>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index a5ad641..e4df4d0 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -72,8 +72,7 @@
     <!-- Text color for no favorites message -->
     <color name="nofavorite_text_color">#777777</color>
 
-    <!-- Text color for the "Remove" text in its regular state -->
-    <color name="remove_text_color">#555555</color>
+    <color name="remove_text_color">#ffffff</color>
 
     <!-- Text color for the "Remove" text when a contact is dragged on top of the remove view -->
     <color name="remove_highlighted_text_color">#FF3F3B</color>
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index fc63690..d4ba6a2 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -49,17 +49,12 @@
 import android.view.View;
 import android.view.View.OnDragListener;
 import android.view.View.OnTouchListener;
-import android.view.animation.AccelerateInterpolator;
 import android.view.animation.Animation;
-import android.view.animation.Animation.AnimationListener;
 import android.view.animation.AnimationUtils;
-import android.view.animation.DecelerateInterpolator;
-import android.view.animation.Interpolator;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.AbsListView.OnScrollListener;
 import android.widget.EditText;
 import android.widget.ImageButton;
-import android.widget.ImageView;
 import android.widget.PopupMenu;
 import android.widget.RelativeLayout;
 import android.widget.Toast;
@@ -84,7 +79,6 @@
 import com.android.dialer.list.SpeedDialFragment;
 import com.android.dialer.list.PhoneFavoriteSquareTileView;
 import com.android.dialer.list.RegularSearchFragment;
-import com.android.dialer.list.RemoveView;
 import com.android.dialer.list.SearchFragment;
 import com.android.dialer.list.SmartDialSearchFragment;
 import com.android.dialer.widget.ActionBarController;
@@ -197,13 +191,6 @@
     private EditText mSearchView;
     private View mVoiceSearchButton;
 
-    /**
-     * View that contains the "Remove" dialog that shows up when the user long presses a contact.
-     * If the user releases a contact when hovering on top of this, the contact is unfavorited and
-     * removed from the speed dial list.
-     */
-    private View mRemoveViewContainer;
-
     private String mSearchQuery;
 
     private DialerDatabaseHelper mDialerDatabaseHelper;
@@ -238,8 +225,7 @@
         @Override
         public boolean onDrag(View v, DragEvent event) {
             if (event.getAction() == DragEvent.ACTION_DRAG_LOCATION) {
-                mDragDropController.handleDragHovered(v, (int) event.getX(),
-                        (int) event.getY());
+                mDragDropController.handleDragHovered(v, (int) event.getX(), (int) event.getY());
             }
             return true;
         }
@@ -395,8 +381,6 @@
         mFloatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
         mFloatingActionButton.setOnClickListener(this);
 
-        mRemoveViewContainer = findViewById(R.id.remove_view_container);
-
         mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this);
         SmartDialPrefix.initializeNanpSettings(this);
     }
@@ -1006,9 +990,9 @@
     @Override
     public void onDragStarted(int x, int y, PhoneFavoriteSquareTileView view) {
         if (mListsFragment.isPaneOpen()) {
-            mActionBarController.slideActionBarUp(true);
+            mActionBarController.setAlpha(ListsFragment.REMOVE_VIEW_SHOWN_ALPHA);
         }
-        mRemoveViewContainer.setVisibility(View.VISIBLE);
+        mListsFragment.showRemoveView(true);
     }
 
     @Override
@@ -1021,9 +1005,9 @@
     @Override
     public void onDragFinished(int x, int y) {
         if (mListsFragment.isPaneOpen()) {
-            mActionBarController.slideActionBarDown(true);
+            mActionBarController.setAlpha(ListsFragment.REMOVE_VIEW_HIDDEN_ALPHA);
         }
-        mRemoveViewContainer.setVisibility(View.GONE);
+        mListsFragment.showRemoveView(false);
     }
 
     @Override
@@ -1036,8 +1020,7 @@
     @Override
     public void setDragDropController(DragDropController dragController) {
         mDragDropController = dragController;
-        ((RemoveView) findViewById(R.id.remove_view))
-                .setDragDropController(dragController);
+        mListsFragment.getRemoveView().setDragDropController(dragController);
     }
 
     @Override
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java
index ab790ed..bdd2d6c 100644
--- a/src/com/android/dialer/list/ListsFragment.java
+++ b/src/com/android/dialer/list/ListsFragment.java
@@ -68,6 +68,9 @@
     private static final String KEY_LAST_DISMISSED_CALL_SHORTCUT_DATE =
             "key_last_dismissed_call_shortcut_date";
 
+    public static final float REMOVE_VIEW_SHOWN_ALPHA = 0.5f;
+    public static final float REMOVE_VIEW_HIDDEN_ALPHA = 1;
+
     // Used with LoaderManager
     private static int MISSED_CALL_LOADER = 1;
 
@@ -81,6 +84,8 @@
     private ViewPagerTabs mViewPagerTabs;
     private ViewPagerAdapter mViewPagerAdapter;
     private ListView mShortcutCardsListView;
+    private RemoveView mRemoveView;
+    private View mRemoveViewContent;
     private SpeedDialFragment mSpeedDialFragment;
     private CallLogFragment mRecentsFragment;
     private AllContactsFragment mAllContactsFragment;
@@ -267,6 +272,9 @@
         mShortcutCardsListView = (ListView) parentView.findViewById(R.id.shortcut_card_list);
         mShortcutCardsListView.setAdapter(mMergedAdapter);
 
+        mRemoveView = (RemoveView) parentView.findViewById(R.id.remove_view);
+        mRemoveViewContent = parentView.findViewById(R.id.remove_view_content);
+
         setupPaneLayout((OverlappingPaneLayout) parentView);
 
         return parentView;
@@ -335,6 +343,19 @@
         }
     }
 
+    public void showRemoveView(boolean show) {
+        mRemoveViewContent.setVisibility(show ? View.VISIBLE : View.GONE);
+        mRemoveView.setAlpha(show ? 0 : 1);
+        mRemoveView.animate().alpha(show ? 1 : 0).start();
+
+        if (mShortcutCardsListView.getCount() > 0) {
+            View v = mShortcutCardsListView.getChildAt(0);
+            v.animate().withLayer()
+                    .alpha(show ? REMOVE_VIEW_SHOWN_ALPHA : REMOVE_VIEW_HIDDEN_ALPHA)
+                    .start();
+        }
+    }
+
     public boolean shouldShowActionBar() {
         return mIsPanelOpen && mActionBar != null;
     }
@@ -361,4 +382,8 @@
     public SpeedDialFragment getSpeedDialFragment() {
         return mSpeedDialFragment;
     }
+
+    public RemoveView getRemoveView() {
+        return mRemoveView;
+    }
 }
diff --git a/src/com/android/dialer/list/RemoveView.java b/src/com/android/dialer/list/RemoveView.java
index ae358fc..fdb08f6 100644
--- a/src/com/android/dialer/list/RemoveView.java
+++ b/src/com/android/dialer/list/RemoveView.java
@@ -21,7 +21,6 @@
     int mUnhighlightedColor;
     int mHighlightedColor;
     Drawable mRemoveDrawable;
-    Drawable mRemoveHighlightedDrawable;
 
     public RemoveView(Context context) {
       super(context);
@@ -43,7 +42,6 @@
         mUnhighlightedColor = r.getColor(R.color.remove_text_color);
         mHighlightedColor = r.getColor(R.color.remove_highlighted_text_color);
         mRemoveDrawable = r.getDrawable(R.drawable.ic_remove);
-        mRemoveHighlightedDrawable = r.getDrawable(R.drawable.ic_remove_highlight);
     }
 
     public void setDragDropController(DragDropController controller) {
@@ -79,13 +77,13 @@
 
     private void setAppearanceNormal() {
         mRemoveText.setTextColor(mUnhighlightedColor);
-        mRemoveIcon.setImageDrawable(mRemoveDrawable);
+        mRemoveIcon.setColorFilter(mUnhighlightedColor);
         invalidate();
     }
 
     private void setAppearanceHighlighted() {
         mRemoveText.setTextColor(mHighlightedColor);
-        mRemoveIcon.setImageDrawable(mRemoveHighlightedDrawable);
+        mRemoveIcon.setColorFilter(mHighlightedColor);
         invalidate();
     }
 }
diff --git a/src/com/android/dialer/widget/ActionBarController.java b/src/com/android/dialer/widget/ActionBarController.java
index 67037a2..0e94df4 100644
--- a/src/com/android/dialer/widget/ActionBarController.java
+++ b/src/com/android/dialer/widget/ActionBarController.java
@@ -187,6 +187,10 @@
         mIsActionBarSlidUp = false;
     }
 
+    public void setAlpha(float alphaValue) {
+        mSearchBox.animate().alpha(alphaValue).start();
+    }
+
     /**
      * Saves the current state of the action bar into a provided {@link Bundle}
      */