diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java index 16d46666732de..fe9197867484b 100644 --- a/core/java/android/view/NotificationHeaderView.java +++ b/core/java/android/view/NotificationHeaderView.java @@ -23,9 +23,7 @@ import android.graphics.Canvas; import android.graphics.Outline; import android.graphics.Rect; import android.graphics.drawable.Drawable; -import android.os.Bundle; import android.util.AttributeSet; -import android.view.accessibility.AccessibilityNodeInfo; import android.widget.ImageView; import android.widget.RemoteViews; @@ -67,33 +65,6 @@ public class NotificationHeaderView extends ViewGroup { } } }; - final AccessibilityDelegate mExpandDelegate = new AccessibilityDelegate() { - - @Override - public boolean performAccessibilityAction(View host, int action, Bundle args) { - if (super.performAccessibilityAction(host, action, args)) { - return true; - } - if (action == AccessibilityNodeInfo.ACTION_COLLAPSE - || action == AccessibilityNodeInfo.ACTION_EXPAND) { - mExpandClickListener.onClick(mExpandButton); - return true; - } - return false; - } - - @Override - public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfo(host, info); - // Avoid that the button description is also spoken - info.setClassName(getClass().getName()); - if (mExpanded) { - info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_COLLAPSE); - } else { - info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND); - } - } - }; private boolean mAcceptAllTouches; public NotificationHeaderView(Context context) { @@ -124,9 +95,6 @@ public class NotificationHeaderView extends ViewGroup { mAppName = findViewById(com.android.internal.R.id.app_name_text); mHeaderText = findViewById(com.android.internal.R.id.header_text); mExpandButton = (ImageView) findViewById(com.android.internal.R.id.expand_button); - if (mExpandButton != null) { - mExpandButton.setAccessibilityDelegate(mExpandDelegate); - } mIcon = (CachingIconView) findViewById(com.android.internal.R.id.icon); mProfileBadge = findViewById(com.android.internal.R.id.profile_badge); } @@ -295,13 +263,19 @@ public class NotificationHeaderView extends ViewGroup { private void updateExpandButton() { int drawableId; + int contentDescriptionId; if (mExpanded) { drawableId = com.android.internal.R.drawable.ic_collapse_notification; + contentDescriptionId + = com.android.internal.R.string.expand_button_content_description_expanded; } else { drawableId = com.android.internal.R.drawable.ic_expand_notification; + contentDescriptionId + = com.android.internal.R.string.expand_button_content_description_collapsed; } mExpandButton.setImageDrawable(getContext().getDrawable(drawableId)); mExpandButton.setColorFilter(mOriginalNotificationColor); + mExpandButton.setContentDescription(mContext.getText(contentDescriptionId)); } public void setShowWorkBadgeAtEnd(boolean showWorkBadgeAtEnd) { @@ -391,7 +365,7 @@ public class NotificationHeaderView extends ViewGroup { break; case MotionEvent.ACTION_UP: if (mTrackGesture) { - mExpandClickListener.onClick(NotificationHeaderView.this); + mExpandButton.performClick(); } break; } diff --git a/core/java/com/android/internal/widget/NotificationExpandButton.java b/core/java/com/android/internal/widget/NotificationExpandButton.java index f4f49b1e4ffeb..c64ace403f769 100644 --- a/core/java/com/android/internal/widget/NotificationExpandButton.java +++ b/core/java/com/android/internal/widget/NotificationExpandButton.java @@ -20,6 +20,8 @@ import android.annotation.Nullable; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; +import android.view.accessibility.AccessibilityNodeInfo; +import android.widget.Button; import android.widget.ImageView; import android.widget.RemoteViews; @@ -59,4 +61,10 @@ public class NotificationExpandButton extends ImageView { rect.top = rect.centerY() - touchTargetSize / 2; rect.bottom = rect.top + touchTargetSize; } + + @Override + public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(info); + info.setClassName(Button.class.getName()); + } } diff --git a/core/res/res/layout/notification_template_header.xml b/core/res/res/layout/notification_template_header.xml index 0dfeb6286fb3f..448cd2e30ef48 100644 --- a/core/res/res/layout/notification_template_header.xml +++ b/core/res/res/layout/notification_template_header.xml @@ -97,7 +97,7 @@ android:layout_height="wrap_content" android:paddingTop="1dp" android:visibility="gone" - android:contentDescription="@string/expand_button_content_description" + android:contentDescription="@string/expand_button_content_description_collapsed" /> Work profile - - Expand button + + Expand + + + Collapse toggle expansion diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 31dcfc6d59221..32babab658bb7 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2888,6 +2888,9 @@ + + + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index 4f1dd5e5c0c90..fc3bb43e4fed1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -1715,6 +1715,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { @Override public boolean isContentExpandable() { + if (mIsSummaryWithChildren && !mShowingPublic) { + return true; + } NotificationContentView showingLayout = getShowingLayout(); return showingLayout.isContentExpandable(); } @@ -1982,6 +1985,26 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { if (canViewBeDismissed()) { info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS); } + boolean expandable = mShowingPublic; + boolean isExpanded = false; + if (!expandable) { + if (mIsSummaryWithChildren) { + expandable = true; + if (!mIsLowPriority || isExpanded()) { + isExpanded = isGroupExpanded(); + } + } else { + expandable = mPrivateLayout.isContentExpandable(); + isExpanded = isExpanded(); + } + } + if (expandable) { + if (isExpanded) { + info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_COLLAPSE); + } else { + info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND); + } + } } @Override @@ -1994,6 +2017,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { NotificationStackScrollLayout.performDismiss(this, mGroupManager, true /* fromAccessibility */); return true; + case AccessibilityNodeInfo.ACTION_COLLAPSE: + case AccessibilityNodeInfo.ACTION_EXPAND: + mExpandClickListener.onClick(this); + return true; } return false; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java index 74e65fbd24324..8f160dc0384ec 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java @@ -131,6 +131,7 @@ public class NotificationContentView extends FrameLayout { private boolean mIconsVisible; private int mClipBottomAmount; private boolean mIsLowPriority; + private boolean mIsContentExpandable; public NotificationContentView(Context context, AttributeSet attrs) { @@ -949,7 +950,7 @@ public class NotificationContentView extends FrameLayout { } public boolean isContentExpandable() { - return mExpandedChild != null; + return mIsContentExpandable; } public void setDark(boolean dark, boolean fade, long delay) { @@ -1198,10 +1199,10 @@ public class NotificationContentView extends FrameLayout { if (mExpandedChild != null && mExpandedChild.getHeight() != 0) { if ((!mIsHeadsUp && !mHeadsUpAnimatingAway) || mHeadsUpChild == null || mContainingNotification.isOnKeyguard()) { - if (mExpandedChild.getHeight() == mContractedChild.getHeight()) { + if (mExpandedChild.getHeight() <= mContractedChild.getHeight()) { expandable = false; } - } else if (mExpandedChild.getHeight() == mHeadsUpChild.getHeight()) { + } else if (mExpandedChild.getHeight() <= mHeadsUpChild.getHeight()) { expandable = false; } } @@ -1214,6 +1215,7 @@ public class NotificationContentView extends FrameLayout { if (mHeadsUpChild != null) { mHeadsUpWrapper.updateExpandability(expandable, mExpandClickListener); } + mIsContentExpandable = expandable; } public NotificationHeaderView getNotificationHeader() {