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

Commit fb2409f7 authored by Priyank Singh's avatar Priyank Singh
Browse files

Disable the support to close the notification shade on long press for navigation bar buttons.

Also, the long intent will only be fired for eng and debug builds.

Bug: 137095329
Bug: 136283489
Test: Manual

Change-Id: I0999185e6c59e5a9d14bfc87ba338c609ffa7b20
parent d0d7e620
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.os.Build;
import android.os.UserHandle;
import android.util.AttributeSet;
import android.view.Display;
@@ -122,7 +123,7 @@ public class CarFacetButton extends LinearLayout {
                        new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS), UserHandle.CURRENT);
            });

            if (longPressIntentString != null) {
            if (longPressIntentString != null && (Build.IS_ENG || Build.IS_USERDEBUG)) {
                final Intent longPressIntent = Intent.parseUri(longPressIntentString,
                        Intent.URI_INTENT_SCHEME);
                setOnLongClickListener(v -> {
+0 −28
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.car;

import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@@ -75,40 +74,13 @@ class CarNavigationBarView extends LinearLayout {
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (mStatusBarWindowTouchListener != null) {
            boolean shouldConsumeEvent = shouldConsumeNotificationButtonEvent(ev);
            // Forward touch events to the status bar window so it can drag
            // windows if required (Notification shade)
            mStatusBarWindowTouchListener.onTouch(this, ev);
            // return true if child views should not receive this event.
            if (shouldConsumeEvent) {
                return true;
            }
        }
        return super.onInterceptTouchEvent(ev);
    }

    /**
     * If the motion event is over top of the notification button while the notification
     * panel is open, we need the statusbar touch listeners handle the event instead of the button.
     * Since the statusbar listener will trigger a close of the notification panel before the
     * any button click events are fired this will prevent reopening the panel.
     *
     * Note: we can't use requestDisallowInterceptTouchEvent because the gesture detector will
     * always receive the ACTION_DOWN and thus think a longpress happened if no other events are
     * received
     *
     * @return true if the notification button should not receive the event
     */
    private boolean shouldConsumeNotificationButtonEvent(MotionEvent ev) {
        if (mNotificationsButton == null || !mCarStatusBar.isNotificationPanelOpen()) {
            return false;
        }
        Rect notificationButtonLocation = new Rect();
        mNotificationsButton.getHitRect(notificationButtonLocation);
        return notificationButtonLocation.contains((int) ev.getX(), (int) ev.getY());
    }


    void setStatusBar(CarStatusBar carStatusBar) {
        mCarStatusBar = carStatusBar;
    }
+2 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.os.Build;
import android.os.UserHandle;
import android.util.AttributeSet;
import android.util.Log;
@@ -114,7 +115,7 @@ public class CarNavigationButton extends com.android.keyguard.AlphaOptimizedImag
        }

        try {
            if (mLongIntent != null) {
            if (mLongIntent != null && (Build.IS_ENG || Build.IS_USERDEBUG)) {
                final Intent intent = Intent.parseUri(mLongIntent, Intent.URI_INTENT_SCHEME);
                setOnLongClickListener(v -> {
                    try {
+0 −7
Original line number Diff line number Diff line
@@ -1232,13 +1232,6 @@ public class CarStatusBar extends StatusBar implements
            setNotificationViewClipBounds((int) event2.getRawY());
            return true;
        }

        @Override
        public void onLongPress(MotionEvent e) {
            mClosingVelocity = DEFAULT_FLING_VELOCITY;
            close();
            super.onLongPress(e);
        }
    }

    /**