Fix regression: recents did not dismiss after launching apps (5252649)

also:
- when using menu to "remove from list" in landscape, animate items upward (5149577)
- dismiss recents when tapping on whitespace regions (5115883)

Change-Id: I0f38c7567281583898a49f572cf92d6c59464649
diff --git a/packages/SystemUI/res/layout-land/status_bar_recent_item.xml b/packages/SystemUI/res/layout-land/status_bar_recent_item.xml
index e99888c..0d17b55 100644
--- a/packages/SystemUI/res/layout-land/status_bar_recent_item.xml
+++ b/packages/SystemUI/res/layout-land/status_bar_recent_item.xml
@@ -37,7 +37,6 @@
             android:layout_alignParentTop="true"
             android:layout_marginLeft="@dimen/status_bar_recents_thumbnail_left_margin"
             android:scaleType="center"
-            android:clickable="true"
             android:background="@drawable/recents_thumbnail_overlay">
             <ImageView android:id="@+id/app_thumbnail_image"
                 android:layout_width="match_parent"
diff --git a/packages/SystemUI/res/layout-port/status_bar_recent_item.xml b/packages/SystemUI/res/layout-port/status_bar_recent_item.xml
index 73ca335..84c89f7 100644
--- a/packages/SystemUI/res/layout-port/status_bar_recent_item.xml
+++ b/packages/SystemUI/res/layout-port/status_bar_recent_item.xml
@@ -33,7 +33,6 @@
             android:layout_height="wrap_content"
             android:layout_alignParentLeft="true"
             android:layout_alignParentTop="true"
-            android:clickable="true"
             android:layout_marginLeft="@dimen/status_bar_recents_thumbnail_left_margin"
             android:scaleType="center"
             android:background="@drawable/recents_thumbnail_overlay">
diff --git a/packages/SystemUI/res/layout-port/status_bar_recent_panel.xml b/packages/SystemUI/res/layout-port/status_bar_recent_panel.xml
index dd25cf9..ed9ea7a 100644
--- a/packages/SystemUI/res/layout-port/status_bar_recent_panel.xml
+++ b/packages/SystemUI/res/layout-port/status_bar_recent_panel.xml
@@ -38,6 +38,7 @@
             android:orientation="horizontal"
             android:clipChildren="false"
             android:layout_marginTop="@*android:dimen/status_bar_height">
+
             <com.android.systemui.recent.RecentsVerticalScrollView
                 android:id="@+id/recents_container"
                 android:layout_width="match_parent"
@@ -62,7 +63,6 @@
 
             </com.android.systemui.recent.RecentsVerticalScrollView>
 
-
         </LinearLayout>
 
     </FrameLayout>
diff --git a/packages/SystemUI/res/layout-sw600dp/status_bar_recent_item.xml b/packages/SystemUI/res/layout-sw600dp/status_bar_recent_item.xml
index cab90fd..9dc6378 100644
--- a/packages/SystemUI/res/layout-sw600dp/status_bar_recent_item.xml
+++ b/packages/SystemUI/res/layout-sw600dp/status_bar_recent_item.xml
@@ -29,7 +29,6 @@
         android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
-        android:clickable="true"
         android:layout_marginLeft="@dimen/status_bar_recents_thumbnail_left_margin"
         android:scaleType="center"
         android:background="@drawable/recents_thumbnail_overlay">
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 14743f4..1ebdfa1 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -196,7 +196,11 @@
         final View animView = mCallback.getChildContentView(view);
         final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(view);
         float newPos;
-        if (velocity < 0 || (velocity == 0 && getTranslation(animView) < 0)) {
+
+        if (velocity < 0
+                || (velocity == 0 && getTranslation(animView) < 0)
+                // if we use the Menu to dismiss an item in landscape, animate up
+                || (velocity == 0 && getTranslation(animView) == 0 && mSwipeDirection == Y)) {
             newPos = -getSize(animView);
         } else {
             newPos = getSize(animView);
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsCallback.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsCallback.java
index 2de4185..e3c4eb7 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsCallback.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsCallback.java
@@ -28,6 +28,7 @@
     void handleSwipe(View selectedView);
     void handleLongPress(View selectedView, View anchorView);
     void handleShowBackground(boolean show);
+    void dismiss();
 
     // TODO: find another way to get this info from RecentsPanelView
     boolean isRecentsVisible();
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
index e59c109..d7bb3c4 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
@@ -243,8 +243,11 @@
         }
     }
 
+    public void dismiss() {
+        hide(true);
+    }
+
     public void hide(boolean animate) {
-        mShowing = false;
         if (!animate) {
             setVisibility(View.GONE);
         }
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
index 3acef08..1978d69 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
@@ -84,15 +84,26 @@
             if (old == null) {
                 view.setClickable(true);
                 view.setOnLongClickListener(mOnLongClick);
-
-                final View thumbnail = view.findViewById(R.id.app_thumbnail);
-                // thumbnail is set to clickable in the layout file
-                thumbnail.setOnClickListener(new OnClickListener() {
+                view.setOnClickListener(new OnClickListener() {
                     public void onClick(View v) {
-                        mCallback.handleOnClick(view);
+                        mCallback.dismiss();
                     }
                 });
 
+                OnClickListener launchAppListener = new OnClickListener() {
+                    public void onClick(View v) {
+                        mCallback.handleOnClick(view);
+                    }
+                };
+                final View thumbnail = view.findViewById(R.id.app_thumbnail);
+                thumbnail.setClickable(true);
+                thumbnail.setOnClickListener(launchAppListener);
+                final View appTitle = view.findViewById(R.id.app_label);
+                appTitle.setClickable(true);
+                appTitle.setOnClickListener(launchAppListener);
+                final View calloutLine = view.findViewById(R.id.recents_callout_line);
+                calloutLine.setClickable(true);
+                calloutLine.setOnClickListener(launchAppListener);
                 mLinearLayout.addView(view);
             }
         }