summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTony Mak <tonymak@google.com>2018-02-06 14:15:11 +0000
committerTony Mak <tonymak@google.com>2018-02-06 17:25:01 +0000
commita5e70402191bcf497b946033a9b258ec1f563893 (patch)
tree6e5e1713ea50e9df4d6c3b3dbc6ef07dbce3d2a9 /src
parentbd0beb993315ec35b954b1801756634be6b1adfa (diff)
downloadandroid_packages_apps_Trebuchet-a5e70402191bcf497b946033a9b258ec1f563893.tar.gz
android_packages_apps_Trebuchet-a5e70402191bcf497b946033a9b258ec1f563893.tar.bz2
android_packages_apps_Trebuchet-a5e70402191bcf497b946033a9b258ec1f563893.zip
Add a close button at the top right hand corner of the blue card
FIX: 72804302 Change-Id: Iac7c369ead27c211c046f318c3b9588d73a594d4
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/views/BottomUserEducationView.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/com/android/launcher3/views/BottomUserEducationView.java b/src/com/android/launcher3/views/BottomUserEducationView.java
index d79d0cefa..ba78cf684 100644
--- a/src/com/android/launcher3/views/BottomUserEducationView.java
+++ b/src/com/android/launcher3/views/BottomUserEducationView.java
@@ -20,7 +20,8 @@ import android.content.Context;
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 @@ public class BottomUserEducationView extends AbstractSlideInView implements Inse
private final Rect mInsets = new Rect();
+ private View mCloseButton;
+
public BottomUserEducationView(Context context, AttributeSet attr) {
this(context, attr, 0);
}
@@ -45,9 +48,17 @@ public class BottomUserEducationView extends AbstractSlideInView implements Inse
}
@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 @@ public class BottomUserEducationView extends AbstractSlideInView implements Inse
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));
+ }
}