From 810bcde1821b1e53adea645958dbc9fccf498a75 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Wed, 14 Dec 2016 17:29:23 -0800 Subject: [PATCH] Fixed a bug where the shelf was clickable outside of keyguard This lead to an issue where notifications on the very bottom weren't clickable. Test: add single notification on the bottom, click it Change-Id: I444a8de60bec6dda2227a2df4d78c2564c59aa2b Fixes: 33643806 --- .../layout/status_bar_notification_shelf.xml | 1 + packages/SystemUI/res/values/strings.xml | 3 +++ .../systemui/statusbar/NotificationShelf.java | 21 ++++++++++++++++++- .../statusbar/phone/PhoneStatusBar.java | 13 ++++++------ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/res/layout/status_bar_notification_shelf.xml b/packages/SystemUI/res/layout/status_bar_notification_shelf.xml index 7bfbd3c542e1c..6db16fec54289 100644 --- a/packages/SystemUI/res/layout/status_bar_notification_shelf.xml +++ b/packages/SystemUI/res/layout/status_bar_notification_shelf.xml @@ -19,6 +19,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="@dimen/notification_shelf_height" + android:contentDescription="@string/notification_shelf_content_description" android:focusable="true" android:clickable="true" > diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index c8b3b69dce374..bbcf684f0e449 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -408,6 +408,9 @@ Notifications. + + Notification overflow container + Clear notification. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index e054bbe672af4..0a138b8f7bf5c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -62,6 +62,7 @@ public class NotificationShelf extends ActivatableNotificationView { private boolean mHasItemsInStableShelf; private NotificationIconContainer mCollapsedIcons; private int mScrollFastThreshold; + private int mStatusBarState; public NotificationShelf(Context context, AttributeSet attrs) { super(context, attrs); @@ -523,7 +524,10 @@ public class NotificationShelf extends ActivatableNotificationView { } private void setHasItemsInStableShelf(boolean hasItemsInStableShelf) { - mHasItemsInStableShelf = hasItemsInStableShelf; + if (mHasItemsInStableShelf != hasItemsInStableShelf) { + mHasItemsInStableShelf = hasItemsInStableShelf; + updateInteractiveness(); + } } /** @@ -538,6 +542,21 @@ public class NotificationShelf extends ActivatableNotificationView { mCollapsedIcons = collapsedIcons; } + public void setStatusBarState(int statusBarState) { + if (mStatusBarState != statusBarState) { + mStatusBarState = statusBarState; + updateInteractiveness(); + } + } + + private void updateInteractiveness() { + boolean interactive = mStatusBarState == StatusBarState.KEYGUARD && mHasItemsInStableShelf; + setClickable(interactive); + setFocusable(interactive); + setImportantForAccessibility(interactive ? View.IMPORTANT_FOR_ACCESSIBILITY_YES + : View.IMPORTANT_FOR_ACCESSIBILITY_NO); + } + private class ShelfState extends ExpandableViewState { private float openedAmount; private boolean hasItemsInStableShelf; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index ae9d06888432b..31daaeafb22ee 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -663,12 +663,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, array.clear(); } - private final View.OnClickListener mShelfClickListener = new View.OnClickListener() { - @Override - public void onClick(View v) { - if (mState == StatusBarState.KEYGUARD) { - goToLockedShade(null); - } + private final View.OnClickListener mGoToLockedShadeListener = v -> { + if (mState == StatusBarState.KEYGUARD) { + goToLockedShade(null); } }; private HashMap> mTmpChildOrderMap @@ -1061,8 +1058,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, (NotificationShelf) LayoutInflater.from(mContext).inflate( R.layout.status_bar_notification_shelf, mStackScroller, false); mNotificationShelf.setOnActivatedListener(this); - mNotificationShelf.setOnClickListener(mShelfClickListener); mStackScroller.setShelf(mNotificationShelf); + mNotificationShelf.setOnClickListener(mGoToLockedShadeListener); + mNotificationShelf.setStatusBarState(mState); } @Override @@ -4598,6 +4596,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mStackScroller.setStatusBarState(state); updateReportRejectedTouchVisibility(); updateDozing(); + mNotificationShelf.setStatusBarState(state); } @Override