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

Commit cbb774dc authored by Heemin Seog's avatar Heemin Seog
Browse files

Allow nav bar to consume touch events based on configuration

This is particularly useful for OEMs that want to ensure that OEMs can
override the touch behavior of the system bars without impacting the
notification panel touch behavior.

Bug: 150613278
Test: manual, atest CarNavigationBarViewTest
Change-Id: Icb5ae3388f4004b4f465e9a9e85e8d175bbe7d78
parent b402caad
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@
    <!-- Disable normal notification rendering; we handle that ourselves -->
    <bool name="config_renderNotifications">false</bool>

    <!-- Whether navigationBar touch events should be consumed before reaching the CarFacetButton \
         when the notification panel is open. -->
    <bool name="config_consumeNavigationBarTouchWhenNotificationPanelOpen">false</bool>

    <!-- Whether heads-up notifications should be shown when shade is open. -->
    <bool name="config_enableHeadsUpNotificationWhenNotificationShadeOpen">true</bool>
    <!-- Whether heads-up notifications should be shown on the bottom. If false, heads-up
+5 −0
Original line number Diff line number Diff line
@@ -599,6 +599,11 @@ public class NotificationPanelViewController extends OverlayViewController {
        }
    }

    /** Returns {@code true} if the notification panel is expanded. */
    public boolean isPanelExpanded() {
        return mPanelExpanded;
    }

    /** Sets the unseen count listener. */
    public void setOnUnseenCountUpdateListener(OnUnseenCountUpdateListener listener) {
        mUnseenCountUpdateListener = listener;
+11 −5
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.car.hardware.power.CarPowerManager;
import android.content.res.Configuration;

import com.android.systemui.car.CarDeviceProvisionedController;
import com.android.systemui.car.CarServiceProvider;
import com.android.systemui.navigationbar.car.CarNavigationBarController;
import com.android.systemui.statusbar.car.PowerManagerHelper;
import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -36,7 +35,6 @@ public class NotificationPanelViewMediator implements OverlayViewMediator,

    private final CarNavigationBarController mCarNavigationBarController;
    private final NotificationPanelViewController mNotificationPanelViewController;
    private final CarServiceProvider mCarServiceProvider;
    private final PowerManagerHelper mPowerManagerHelper;
    private final CarDeviceProvisionedController mCarDeviceProvisionedController;
    private final ConfigurationController mConfigurationController;
@@ -46,7 +44,6 @@ public class NotificationPanelViewMediator implements OverlayViewMediator,
            CarNavigationBarController carNavigationBarController,
            NotificationPanelViewController notificationPanelViewController,

            CarServiceProvider carServiceProvider,
            PowerManagerHelper powerManagerHelper,

            CarDeviceProvisionedController carDeviceProvisionedController,
@@ -54,7 +51,6 @@ public class NotificationPanelViewMediator implements OverlayViewMediator,
    ) {
        mCarNavigationBarController = carNavigationBarController;
        mNotificationPanelViewController = notificationPanelViewController;
        mCarServiceProvider = carServiceProvider;
        mPowerManagerHelper = powerManagerHelper;
        mCarDeviceProvisionedController = carDeviceProvisionedController;
        mConfigurationController = configurationController;
@@ -72,7 +68,17 @@ public class NotificationPanelViewMediator implements OverlayViewMediator,
                mNotificationPanelViewController.getNavBarNotificationTouchListener());

        mCarNavigationBarController.registerNotificationController(
                () -> mNotificationPanelViewController.toggle());
                new CarNavigationBarController.NotificationsShadeController() {
                    @Override
                    public void togglePanel() {
                        mNotificationPanelViewController.toggle();
                    }

                    @Override
                    public boolean isNotificationPanelOpen() {
                        return mNotificationPanelViewController.isPanelExpanded();
                    }
                });
    }

    @Override
+3 −0
Original line number Diff line number Diff line
@@ -314,6 +314,9 @@ public class CarNavigationBarController {
    public interface NotificationsShadeController {
        /** Toggles the visibility of the notifications shade. */
        void togglePanel();

        /** Returns {@code true} if the panel is open. */
        boolean isNotificationPanelOpen();
    }

    private void checkAllBars(boolean isSetUp) {
+11 −2
Original line number Diff line number Diff line
@@ -35,10 +35,11 @@ import com.android.systemui.statusbar.phone.StatusBarIconController;
 * in a linear layout.
 */
public class CarNavigationBarView extends LinearLayout {
    private final boolean mConsumeTouchWhenPanelOpen;

    private View mNavButtons;
    private CarNavigationButton mNotificationsButton;
    private NotificationsShadeController mNotificationsShadeController;
    private Context mContext;
    private View mLockScreenButtons;
    // used to wire in open/close gestures for notifications
    private OnTouchListener mStatusBarWindowTouchListener;
@@ -46,7 +47,8 @@ public class CarNavigationBarView extends LinearLayout {

    public CarNavigationBarView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
        mConsumeTouchWhenPanelOpen = getResources().getBoolean(
                R.bool.config_consumeNavigationBarTouchWhenNotificationPanelOpen);
    }

    @Override
@@ -77,9 +79,16 @@ public class CarNavigationBarView extends LinearLayout {
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (mStatusBarWindowTouchListener != null) {
            boolean shouldConsumeEvent = mNotificationsShadeController == null ? false
                    : mNotificationsShadeController.isNotificationPanelOpen();

            // Forward touch events to the status bar window so it can drag
            // windows if required (Notification shade)
            mStatusBarWindowTouchListener.onTouch(this, ev);

            if (mConsumeTouchWhenPanelOpen && shouldConsumeEvent) {
                return true;
            }
        }
        return super.onInterceptTouchEvent(ev);
    }
Loading