Merge changes Iefcaf262,I9c397d83
* changes: Fixed a bug where the expand icon could show but nothing happens Improved expand accessibility experience
This commit is contained in:
committed by
Android (Google) Code Review
commit
7cae77b606
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user