From ee451e5882b9b8bbbd4110c2ad02216f4f9ae230 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Fri, 20 Nov 2020 14:30:39 -0500 Subject: Allow tapping notification icon to expand/contract. Bug: 163626038 Test: manual Change-Id: Ie8bf816b0acfc3f078dd1d0583d325de4b625764 --- core/java/android/view/NotificationHeaderView.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'core/java/android/view/NotificationHeaderView.java') diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java index f7fbb1ce0ab9..673ed0d8b95d 100644 --- a/core/java/android/view/NotificationHeaderView.java +++ b/core/java/android/view/NotificationHeaderView.java @@ -43,12 +43,13 @@ import java.util.ArrayList; */ @RemoteViews.RemoteView public class NotificationHeaderView extends FrameLayout { - private final int mContentEndMargin; private final int mHeadingEndMargin; + private final int mTouchableHeight; private OnClickListener mExpandClickListener; private HeaderTouchListener mTouchListener = new HeaderTouchListener(); private NotificationTopLineView mTopLineView; private NotificationExpandButton mExpandButton; + private View mAltExpandTarget; private CachingIconView mIcon; private Drawable mBackground; private boolean mEntireHeaderClickable; @@ -82,8 +83,8 @@ public class NotificationHeaderView extends FrameLayout { int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); Resources res = getResources(); - mContentEndMargin = res.getDimensionPixelSize(R.dimen.notification_content_margin_end); mHeadingEndMargin = res.getDimensionPixelSize(R.dimen.notification_heading_margin_end); + mTouchableHeight = res.getDimensionPixelSize(R.dimen.notification_header_touchable_height); mEntireHeaderClickable = res.getBoolean(R.bool.config_notificationHeaderClickableForExpand); } @@ -93,6 +94,7 @@ public class NotificationHeaderView extends FrameLayout { mIcon = findViewById(R.id.icon); mTopLineView = findViewById(R.id.notification_top_line); mExpandButton = findViewById(R.id.expand_button); + mAltExpandTarget = findViewById(R.id.alternate_expand_target); setClipToPadding(false); } @@ -146,6 +148,7 @@ public class NotificationHeaderView extends FrameLayout { public void setOnClickListener(@Nullable OnClickListener l) { mExpandClickListener = l; mExpandButton.setOnClickListener(mExpandClickListener); + mAltExpandTarget.setOnClickListener(mExpandClickListener); updateTouchListener(); } @@ -187,6 +190,7 @@ public class NotificationHeaderView extends FrameLayout { private final ArrayList mTouchRects = new ArrayList<>(); private Rect mExpandButtonRect; + private Rect mAltExpandTargetRect; private int mTouchSlop; private boolean mTrackGesture; private float mDownX; @@ -199,6 +203,7 @@ public class NotificationHeaderView extends FrameLayout { mTouchRects.clear(); addRectAroundView(mIcon); mExpandButtonRect = addRectAroundView(mExpandButton); + mAltExpandTargetRect = addRectAroundView(mAltExpandTarget); addWidthRect(); mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); } @@ -206,7 +211,7 @@ public class NotificationHeaderView extends FrameLayout { private void addWidthRect() { Rect r = new Rect(); r.top = 0; - r.bottom = (int) (32 * getResources().getDisplayMetrics().density); + r.bottom = mTouchableHeight; r.left = 0; r.right = getWidth(); mTouchRects.add(r); @@ -277,7 +282,8 @@ public class NotificationHeaderView extends FrameLayout { return true; } if (mExpandOnlyOnButton) { - return mExpandButtonRect.contains((int) x, (int) y); + return mExpandButtonRect.contains((int) x, (int) y) + || mAltExpandTargetRect.contains((int) x, (int) y); } for (int i = 0; i < mTouchRects.size(); i++) { Rect r = mTouchRects.get(i); -- cgit v1.2.3