Merge changes I7773ed3a,I73d97d9a into nyc-dev

* changes:
  Added accessibility action for scrolling the notifications
  Fixed a bug where the text directionality was inconsistent
This commit is contained in:
Selim Cinek
2016-05-24 20:01:22 +00:00
committed by Android (Google) Code Review
3 changed files with 81 additions and 4 deletions

View File

@@ -58,6 +58,7 @@ import android.util.SparseArray;
import android.view.Gravity;
import android.view.NotificationHeaderView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.RemoteViews;
@@ -3202,11 +3203,14 @@ public class Notification implements Parcelable
bindNotificationHeader(contentView);
bindLargeIcon(contentView);
boolean showProgress = handleProgressBar(hasProgress, contentView, ex);
if (title != null) {
contentView.setViewVisibility(R.id.title, View.VISIBLE);
contentView.setTextViewText(R.id.title, title);
contentView.setViewLayoutWidth(R.id.title, showProgress
? ViewGroup.LayoutParams.WRAP_CONTENT
: ViewGroup.LayoutParams.MATCH_PARENT);
}
boolean showProgress = handleProgressBar(hasProgress, contentView, ex);
if (text != null) {
int textId = showProgress ? com.android.internal.R.id.text_line_1
: com.android.internal.R.id.text;

View File

@@ -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"

View File

@@ -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() {
@@ -3520,6 +3532,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();