Add a close button at the top right hand corner of the blue card

FIX: 72804302

Change-Id: Iac7c369ead27c211c046f318c3b9588d73a594d4
diff --git a/res/drawable/ic_close.xml b/res/drawable/ic_close.xml
new file mode 100644
index 0000000..fc9ed49
--- /dev/null
+++ b/res/drawable/ic_close.xml
@@ -0,0 +1,23 @@
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportHeight="24.0"
+    android:viewportWidth="24.0">
+  <path
+      android:fillColor="@android:color/white"
+      android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
+</vector>
\ No newline at end of file
diff --git a/res/layout/work_tab_bottom_user_education_view.xml b/res/layout/work_tab_bottom_user_education_view.xml
index 2a4ba5d..dc6854e 100644
--- a/res/layout/work_tab_bottom_user_education_view.xml
+++ b/res/layout/work_tab_bottom_user_education_view.xml
@@ -20,38 +20,48 @@
     android:layout_gravity="bottom"
     android:background="?android:attr/colorAccent"
     android:elevation="2dp"
-    android:orientation="horizontal"
-    android:paddingLeft="20dp"
-    android:paddingRight="20dp">
+    android:orientation="horizontal">
+
+  <ImageView
+      android:layout_width="134dp"
+      android:layout_height="134dp"
+      android:layout_marginTop="28dp"
+      android:layout_marginLeft="20dp"
+      android:src="@drawable/work_tab_user_education"/>
+
+  <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:layout_marginStart="24dp"
+      android:orientation="vertical">
 
     <ImageView
-        android:layout_width="134dp"
-        android:layout_height="134dp"
-        android:layout_gravity="center_vertical"
-        android:src="@drawable/work_tab_user_education"/>
+        android:id="@+id/close_bottom_user_tip"
+        android:layout_width="24dp"
+        android:layout_height="24dp"
+        android:layout_marginTop="12dp"
+        android:layout_marginEnd="12dp"
+        android:layout_gravity="right"
+        android:src="@drawable/ic_close"/>
 
-    <LinearLayout
-        android:layout_width="match_parent"
+    <TextView
+        android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:orientation="vertical"
-        android:paddingBottom="12dp"
-        android:paddingStart="24dp"
-        android:paddingTop="12dp">
+        android:layout_marginTop="4dp"
+        android:layout_marginEnd="24dp"
+        android:fontFamily="roboto-medium"
+        android:text="@string/bottom_work_tab_user_education_title"
+        android:textColor="@android:color/white"
+        android:textSize="20sp"/>
 
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:fontFamily="roboto-medium"
-            android:text="@string/bottom_work_tab_user_education_title"
-            android:textColor="@android:color/white"
-            android:textSize="20sp"/>
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginEnd="24dp"
+        android:text="@string/bottom_work_tab_user_education_body"
+        android:textColor="@android:color/white"
+        android:textSize="14sp"/>
 
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/bottom_work_tab_user_education_body"
-            android:textColor="@android:color/white"
-            android:textSize="14sp"/>
-    </LinearLayout>
+  </LinearLayout>
 
 </com.android.launcher3.views.BottomUserEducationView>
\ No newline at end of file
diff --git a/src/com/android/launcher3/views/BottomUserEducationView.java b/src/com/android/launcher3/views/BottomUserEducationView.java
index d79d0ce..ba78cf6 100644
--- a/src/com/android/launcher3/views/BottomUserEducationView.java
+++ b/src/com/android/launcher3/views/BottomUserEducationView.java
@@ -20,7 +20,8 @@
 import android.graphics.Rect;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
-
+import android.view.TouchDelegate;
+import android.view.View;
 import com.android.launcher3.Insettable;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.R;
@@ -34,6 +35,8 @@
 
     private final Rect mInsets = new Rect();
 
+    private View mCloseButton;
+
     public BottomUserEducationView(Context context, AttributeSet attr) {
         this(context, attr, 0);
     }
@@ -45,9 +48,17 @@
     }
 
     @Override
+    protected void onFinishInflate() {
+        super.onFinishInflate();
+        mCloseButton = findViewById(R.id.close_bottom_user_tip);
+        mCloseButton.setOnClickListener(view -> handleClose(true));
+    }
+
+    @Override
     protected void onLayout(boolean changed, int l, int t, int r, int b) {
         super.onLayout(changed, l, t, r, b);
         setTranslationShift(mTranslationShift);
+        expandTouchAreaOfCloseButton();
     }
 
     @Override
@@ -110,4 +121,15 @@
         launcher.getDragLayer().addView(bottomUserEducationView);
         bottomUserEducationView.open(true);
     }
+
+    private void expandTouchAreaOfCloseButton() {
+        Rect hitRect = new Rect();
+        mCloseButton.getHitRect(hitRect);
+        hitRect.left -= mCloseButton.getWidth();
+        hitRect.top -= mCloseButton.getHeight();
+        hitRect.right += mCloseButton.getWidth();
+        hitRect.bottom += mCloseButton.getHeight();
+        View parent = (View) mCloseButton.getParent();
+        parent.setTouchDelegate(new TouchDelegate(hitRect, mCloseButton));
+    }
 }