Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee451e58 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Allow tapping notification icon to expand/contract.

Bug: 163626038
Test: manual
Change-Id: Ie8bf816b0acfc3f078dd1d0583d325de4b625764
parent fbc84308
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -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<Rect> 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);
+8 −0
Original line number Diff line number Diff line
@@ -54,6 +54,14 @@

    </NotificationTopLineView>

    <FrameLayout
        android:id="@+id/alternate_expand_target"
        android:layout_width="@dimen/notification_content_margin_start"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:importantForAccessibility="no"
        />

    <com.android.internal.widget.NotificationExpandButton
        android:id="@+id/expand_button"
        android:layout_width="@dimen/notification_header_expand_icon_size"
+8 −0
Original line number Diff line number Diff line
@@ -143,6 +143,14 @@
        android:scaleType="centerCrop"
        />

    <FrameLayout
        android:id="@+id/alternate_expand_target"
        android:layout_width="@dimen/notification_content_margin_start"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:importantForAccessibility="no"
        />

    <FrameLayout
        android:id="@+id/expand_button_touch_container"
        android:layout_width="wrap_content"
+3 −0
Original line number Diff line number Diff line
@@ -259,6 +259,9 @@
    <!-- The height of the background for a notification header on a group -->
    <dimen name="notification_header_background_height">49.5dp</dimen>

    <!-- The height of the full-width touch rectangle for the notification header -->
    <dimen name="notification_header_touchable_height">36dp</dimen>

    <!-- The top padding for the notification header -->
    <dimen name="notification_header_padding_top">16dp</dimen>

+2 −0
Original line number Diff line number Diff line
@@ -2861,6 +2861,7 @@
  <java-symbol type="id" name="header_text" />
  <java-symbol type="id" name="header_text_secondary" />
  <java-symbol type="id" name="expand_button" />
  <java-symbol type="id" name="alternate_expand_target" />
  <java-symbol type="id" name="notification_header" />
  <java-symbol type="id" name="notification_top_line" />
  <java-symbol type="id" name="time_divider" />
@@ -2878,6 +2879,7 @@
  <java-symbol type="dimen" name="notification_content_margin_top" />
  <java-symbol type="dimen" name="notification_content_margin" />
  <java-symbol type="dimen" name="notification_header_background_height" />
  <java-symbol type="dimen" name="notification_header_touchable_height" />
  <java-symbol type="dimen" name="notification_header_expand_icon_size" />
  <java-symbol type="dimen" name="notification_expand_button_padding_top" />
  <java-symbol type="dimen" name="notification_header_icon_size" />
Loading