OSDN Git Service

Fixed a bug where the shelf was clickable outside of keyguard
authorSelim Cinek <cinek@google.com>
Thu, 15 Dec 2016 01:29:23 +0000 (17:29 -0800)
committerSelim Cinek <cinek@google.com>
Tue, 20 Dec 2016 12:19:34 +0000 (13:19 +0100)
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

packages/SystemUI/res/layout/status_bar_notification_shelf.xml
packages/SystemUI/res/values/strings.xml
packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

index 7bfbd3c..6db16fe 100644 (file)
@@ -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"
     >
index c8b3b69..bbcf684 100644 (file)
     <!-- Content description of the button for showing a notifications panel in the notification panel for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
     <string name="accessibility_notifications_button">Notifications.</string>
 
+    <!-- Content description of overflow icon container of the notifications for accessibility (not shown on the screen)[CHAR LIMIT=NONE] -->
+    <string name="notification_shelf_content_description">Notification overflow container</string>
+
     <!-- Content description of the button for removing a notification in the notification panel for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
     <string name="accessibility_remove_notification">Clear notification.</string>
 
index e054bbe..0a138b8 100644 (file)
@@ -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;
index ae9d068..31daaea 100644 (file)
@@ -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<ExpandableNotificationRow, List<ExpandableNotificationRow>> 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