summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Selim Cinek <cinek@google.com> 2016-05-20 12:44:30 -0700
committer Selim Cinek <cinek@google.com> 2016-05-23 16:51:16 -0700
commitc22fff6cf6cc030838b6c0435c5a2bc011653291 (patch)
tree9342555d3c8e040a240821484dd8cbea13b2c640
parent954cc230ed827d5b0a22fce2775cff4db2375d78 (diff)
Added accessibility action for scrolling the notifications
Also made the stackscroller focusable if and only if it is scrollable. This will allow it to be important for accessibility again. Change-Id: I7773ed3a19d23f6bc62a1b9a23464cfbecd0ec03 Fixes: 25673942
-rw-r--r--packages/SystemUI/res/layout/status_bar_expanded.xml3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java76
2 files changed, 76 insertions, 3 deletions
diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml
index 658571e8674d..2c8a55955b4b 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded.xml
@@ -53,8 +53,7 @@
android:layout_width="@dimen/notification_panel_width"
android:layout_height="match_parent"
android:layout_gravity="@integer/notification_panel_layout_gravity"
- android:layout_marginBottom="@dimen/close_handle_underlap"
- android:importantForAccessibility="no" />
+ android:layout_marginBottom="@dimen/close_handle_underlap" />
<ViewStub
android:id="@+id/keyguard_user_switcher"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index 7a5b242f70db..439a6308a761 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -34,6 +34,7 @@ import android.graphics.PointF;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
+import android.os.Bundle;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.FloatProperty;
@@ -47,6 +48,8 @@ import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.widget.OverScroller;
@@ -336,6 +339,7 @@ public class NotificationStackScrollLayout extends ViewGroup
private boolean mFadingOut;
private boolean mParentFadingOut;
private boolean mGroupExpandedForMeasure;
+ private boolean mScrollable;
private View mForcedScroll;
private float mBackgroundFadeAmount = 1.0f;
private static final Property<NotificationStackScrollLayout, Float> BACKGROUND_FADE =
@@ -443,7 +447,6 @@ public class NotificationStackScrollLayout extends ViewGroup
private void initView(Context context) {
mScroller = new OverScroller(getContext());
- setFocusable(true);
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
setClipChildren(false);
final ViewConfiguration configuration = ViewConfiguration.get(context);
@@ -1728,6 +1731,15 @@ public class NotificationStackScrollLayout extends ViewGroup
}
}
mContentHeight = height + mTopPadding;
+ updateScrollability();
+ }
+
+ private void updateScrollability() {
+ boolean scrollable = getScrollRange() > 0;
+ if (scrollable != mScrollable) {
+ mScrollable = scrollable;
+ setFocusable(scrollable);
+ }
}
private void updateBackground() {
@@ -3534,6 +3546,68 @@ public class NotificationStackScrollLayout extends ViewGroup
mPhoneStatusBar.requestNotificationUpdate();
}
+ /** @hide */
+ @Override
+ public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) {
+ super.onInitializeAccessibilityEventInternal(event);
+ event.setScrollable(mScrollable);
+ event.setScrollX(mScrollX);
+ event.setScrollY(mOwnScrollY);
+ event.setMaxScrollX(mScrollX);
+ event.setMaxScrollY(getScrollRange());
+ }
+
+ @Override
+ public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfoInternal(info);
+ final int scrollRange = getScrollRange();
+ if (scrollRange > 0) {
+ info.setScrollable(true);
+ if (mScrollY > 0) {
+ info.addAction(
+ AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_BACKWARD);
+ info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_UP);
+ }
+ if (mScrollY < scrollRange) {
+ info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_FORWARD);
+ info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SCROLL_DOWN);
+ }
+ }
+ }
+
+ /** @hide */
+ @Override
+ public boolean performAccessibilityActionInternal(int action, Bundle arguments) {
+ if (super.performAccessibilityActionInternal(action, arguments)) {
+ return true;
+ }
+ if (!isEnabled()) {
+ return false;
+ }
+ int direction = -1;
+ switch (action) {
+ case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD:
+ // fall through
+ case android.R.id.accessibilityActionScrollDown:
+ direction = 1;
+ // fall through
+ case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD:
+ // fall through
+ case android.R.id.accessibilityActionScrollUp:
+ final int viewportHeight = getHeight() - mPaddingBottom - mTopPadding - mPaddingTop
+ - mBottomStackPeekSize - mBottomStackSlowDownHeight;
+ final int targetScrollY = Math.max(0,
+ Math.min(mOwnScrollY + direction * viewportHeight, getScrollRange()));
+ if (targetScrollY != mOwnScrollY) {
+ mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScrollY - mOwnScrollY);
+ postInvalidateOnAnimation();
+ return true;
+ }
+ break;
+ }
+ return false;
+ }
+
@Override
public void onGroupsChanged() {
mPhoneStatusBar.requestNotificationUpdate();