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

Commit 44d3907b authored by Brad Stenning's avatar Brad Stenning
Browse files

Change CarSystemUI notification button from launching Car Notification Center...

Change CarSystemUI notification button from launching Car Notification Center to opening the panel instead.

Bug: 130664005
Test: Manual
Change-Id: Ia32142c588d9afd42964182d2488f9b1133a5eb9
(cherry picked from commit 5b3dbcef9480ee6bedb554b48f433b18b63d6493)
parent 89566466
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -108,12 +108,13 @@
            android:layout_height="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"/>
            android:layout_weight="1"/>


        <com.android.systemui.statusbar.car.CarFacetButton
        <!-- Click handling will be initialized in CarNavigationBarView because its
            android:id="@+id/note"
             id = notifications which is treated special for the opening of the notification panel
         -->
        <com.android.systemui.statusbar.car.CarNavigationButton
            android:id="@+id/notifications"
            style="@style/NavigationBarButton"
            style="@style/NavigationBarButton"
            systemui:icon="@drawable/car_ic_notification"
            android:src="@drawable/car_ic_notification"
            systemui:intent="intent:#Intent;component=com.android.car.notification/.CarNotificationCenterActivity;launchFlags=0x14000000;end"
            systemui:packages="com.android.car.notification"
            systemui:selectedIcon="@drawable/car_ic_notification_selected"
            systemui:selectedIcon="@drawable/car_ic_notification_selected"
            systemui:useMoreIcon="false"
            systemui:useMoreIcon="false"
        />
        />
+29 −2
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.car;
package com.android.systemui.statusbar.car;


import android.content.Context;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View;
@@ -34,7 +35,7 @@ import com.android.systemui.statusbar.phone.StatusBarIconController;
 */
 */
class CarNavigationBarView extends LinearLayout {
class CarNavigationBarView extends LinearLayout {
    private View mNavButtons;
    private View mNavButtons;
    private CarFacetButton mNotificationsButton;
    private View mNotificationsButton;
    private CarStatusBar mCarStatusBar;
    private CarStatusBar mCarStatusBar;
    private Context mContext;
    private Context mContext;
    private View mLockScreenButtons;
    private View mLockScreenButtons;
@@ -74,13 +75,39 @@ class CarNavigationBarView extends LinearLayout {
    @Override
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (mStatusBarWindowTouchListener != null) {
        if (mStatusBarWindowTouchListener != null) {
            // forward touch events to the status bar window so it can add a drag down
            boolean shouldConsumeEvent = shouldConsumeNotificationButtonEvent(ev);
            // Forward touch events to the status bar window so it can drag
            // windows if required (Notification shade)
            // windows if required (Notification shade)
            mStatusBarWindowTouchListener.onTouch(this, ev);
            mStatusBarWindowTouchListener.onTouch(this, ev);
            // return true if child views should not receive this event.
            if (shouldConsumeEvent) {
                return true;
            }
        }
        }
        return super.onInterceptTouchEvent(ev);
        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) {
    void setStatusBar(CarStatusBar carStatusBar) {
        mCarStatusBar = carStatusBar;
        mCarStatusBar = carStatusBar;
+13 −2
Original line number Original line Diff line number Diff line
@@ -347,16 +347,20 @@ public class CarStatusBar extends StatusBar implements
                new CloseNotificationGestureListener() {
                new CloseNotificationGestureListener() {
                    @Override
                    @Override
                    protected void close() {
                    protected void close() {
                        if (mPanelExpanded) {
                            animateCollapsePanels();
                            animateCollapsePanels();
                        }
                        }
                    }
                });
                });
        // Attached to the NavBars to close the notification shade
        // Attached to the NavBars to close the notification shade
        GestureDetector navBarCloseNotificationGestureDetector = new GestureDetector(mContext,
        GestureDetector navBarCloseNotificationGestureDetector = new GestureDetector(mContext,
                new NavBarCloseNotificationGestureListener() {
                new NavBarCloseNotificationGestureListener() {
                    @Override
                    @Override
                    protected void close() {
                    protected void close() {
                        if (mPanelExpanded) {
                            animateCollapsePanels();
                            animateCollapsePanels();
                        }
                        }
                    }
                });
                });
        mNavBarNotificationTouchListener =
        mNavBarNotificationTouchListener =
                (v, event) -> {
                (v, event) -> {
@@ -514,6 +518,13 @@ public class CarStatusBar extends StatusBar implements
        mNotificationViewController.enable();
        mNotificationViewController.enable();
    }
    }


    /**
     * @return true if the notification panel is currently visible
     */
    boolean isNotificationPanelOpen() {
        return mPanelExpanded;
    }

    @Override
    @Override
    public void animateExpandNotificationsPanel() {
    public void animateExpandNotificationsPanel() {
        if (!mCommandQueue.panelsEnabled() || !mUserSetup) {
        if (!mCommandQueue.panelsEnabled() || !mUserSetup) {