diff options
| author | 2019-04-24 20:15:26 +0000 | |
|---|---|---|
| committer | 2019-04-24 20:15:26 +0000 | |
| commit | def2bc1aef5f30fc250b4e74fe81b3d3b21b2224 (patch) | |
| tree | 327845e61b13ecb76bd05c210324bedb89f2f90a | |
| parent | c74d6b563b4bc053733860ca4070c112919499d1 (diff) | |
| parent | 44d3907b370983aaa6a88f1f8957d57f6a9c945c (diff) | |
Merge "Change CarSystemUI notification button from launching Car Notification Center to opening the panel instead." into qt-dev
3 files changed, 48 insertions, 9 deletions
diff --git a/packages/CarSystemUI/res/layout/car_navigation_bar.xml b/packages/CarSystemUI/res/layout/car_navigation_bar.xml index 34fd70332cd0..49d78b6d5871 100644 --- a/packages/CarSystemUI/res/layout/car_navigation_bar.xml +++ b/packages/CarSystemUI/res/layout/car_navigation_bar.xml @@ -108,12 +108,13 @@ android:layout_height="match_parent" android:layout_weight="1"/> - <com.android.systemui.statusbar.car.CarFacetButton - android:id="@+id/note" + <!-- Click handling will be initialized in CarNavigationBarView because its + 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" - systemui:icon="@drawable/car_ic_notification" - systemui:intent="intent:#Intent;component=com.android.car.notification/.CarNotificationCenterActivity;launchFlags=0x14000000;end" - systemui:packages="com.android.car.notification" + android:src="@drawable/car_ic_notification" systemui:selectedIcon="@drawable/car_ic_notification_selected" systemui:useMoreIcon="false" /> diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java index a0f2367c65a4..6e7be060a2cb 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarNavigationBarView.java @@ -17,6 +17,7 @@ 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; @@ -34,7 +35,7 @@ import com.android.systemui.statusbar.phone.StatusBarIconController; */ class CarNavigationBarView extends LinearLayout { private View mNavButtons; - private CarFacetButton mNotificationsButton; + private View mNotificationsButton; private CarStatusBar mCarStatusBar; private Context mContext; private View mLockScreenButtons; @@ -74,13 +75,39 @@ class CarNavigationBarView extends LinearLayout { @Override public boolean onInterceptTouchEvent(MotionEvent ev) { 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) 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; diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java index db383de1dd3c..ea29ebb88846 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java @@ -349,7 +349,9 @@ public class CarStatusBar extends StatusBar implements new CloseNotificationGestureListener() { @Override protected void close() { - animateCollapsePanels(); + if (mPanelExpanded) { + animateCollapsePanels(); + } } }); // Attached to the NavBars to close the notification shade @@ -357,7 +359,9 @@ public class CarStatusBar extends StatusBar implements new NavBarCloseNotificationGestureListener() { @Override protected void close() { - animateCollapsePanels(); + if (mPanelExpanded) { + animateCollapsePanels(); + } } }); mNavBarNotificationTouchListener = @@ -520,6 +524,13 @@ public class CarStatusBar extends StatusBar implements mNotificationViewController.enable(); } + /** + * @return true if the notification panel is currently visible + */ + boolean isNotificationPanelOpen() { + return mPanelExpanded; + } + @Override public void animateExpandNotificationsPanel() { if (!mCommandQueue.panelsEnabled() || !mUserSetup) { |