Merge changes from topic "bubblebar-a11y" into main
* changes: Move bubble bar strings Add content description to bubble bar and bubbles
This commit is contained in:
commit
765cc415a3
5 files changed
+70
-5
No files matched your search
@@ -623,6 +623,8 @@ public class BubbleBarView extends FrameLayout {
|
||||
}
|
||||
super.addView(child, index, params);
|
||||
updateWidth();
|
||||
updateBubbleAccessibilityStates();
|
||||
updateContentDescription();
|
||||
}
|
||||
|
||||
// TODO: (b/283309949) animate it
|
||||
@@ -634,6 +636,8 @@ public class BubbleBarView extends FrameLayout {
|
||||
mBubbleBarBackground.showArrow(false);
|
||||
}
|
||||
updateWidth();
|
||||
updateBubbleAccessibilityStates();
|
||||
updateContentDescription();
|
||||
}
|
||||
|
||||
private void updateWidth() {
|
||||
@@ -799,6 +803,7 @@ public class BubbleBarView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
updateChildrenRenderNodeProperties(mBubbleBarLocation);
|
||||
updateContentDescription();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -927,6 +932,7 @@ public class BubbleBarView extends FrameLayout {
|
||||
} else {
|
||||
mWidthAnimator.reverse();
|
||||
}
|
||||
updateBubbleAccessibilityStates();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -998,6 +1004,47 @@ public class BubbleBarView extends FrameLayout {
|
||||
return mIsAnimatingNewBubble;
|
||||
}
|
||||
|
||||
private boolean hasOverview() {
|
||||
// Overview is always the last bubble
|
||||
View lastChild = getChildAt(getChildCount() - 1);
|
||||
if (lastChild instanceof BubbleView bubbleView) {
|
||||
return bubbleView.getBubble() instanceof BubbleBarOverflow;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateBubbleAccessibilityStates() {
|
||||
final int childA11y;
|
||||
if (mIsBarExpanded) {
|
||||
// Bar is expanded, focus on the bubbles
|
||||
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||
childA11y = View.IMPORTANT_FOR_ACCESSIBILITY_YES;
|
||||
} else {
|
||||
// Bar is collapsed, only focus on the bar
|
||||
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
|
||||
childA11y = View.IMPORTANT_FOR_ACCESSIBILITY_NO;
|
||||
}
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
getChildAt(i).setImportantForAccessibility(childA11y);
|
||||
// Only allowing focusing on bubbles when bar is expanded. Otherwise, in talkback mode,
|
||||
// bubbles can be navigates to in collapsed mode.
|
||||
getChildAt(i).setFocusable(mIsBarExpanded);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateContentDescription() {
|
||||
View firstChild = getChildAt(0);
|
||||
CharSequence contentDesc = firstChild != null ? firstChild.getContentDescription() : "";
|
||||
|
||||
// Don't count overflow if it exists
|
||||
int bubbleCount = getChildCount() - (hasOverview() ? 1 : 0);
|
||||
if (bubbleCount > 1) {
|
||||
contentDesc = getResources().getString(R.string.bubble_bar_description_multiple_bubbles,
|
||||
contentDesc, bubbleCount - 1);
|
||||
}
|
||||
setContentDescription(contentDesc);
|
||||
}
|
||||
|
||||
/** Interface for BubbleBarView to communicate with its controller. */
|
||||
interface Controller {
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.Rect;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -187,6 +188,16 @@ public class BubbleView extends ConstraintLayout {
|
||||
mAppIcon.setImageBitmap(bubble.getBadge());
|
||||
mDotColor = bubble.getDotColor();
|
||||
mDotRenderer = new DotRenderer(mBubbleSize, bubble.getDotPath(), DEFAULT_PATH_SIZE);
|
||||
String contentDesc = bubble.getInfo().getTitle();
|
||||
if (TextUtils.isEmpty(contentDesc)) {
|
||||
contentDesc = getResources().getString(R.string.bubble_bar_bubble_fallback_description);
|
||||
}
|
||||
String appName = bubble.getInfo().getAppName();
|
||||
if (!TextUtils.isEmpty(appName)) {
|
||||
contentDesc = getResources().getString(R.string.bubble_bar_bubble_description,
|
||||
contentDesc, appName);
|
||||
}
|
||||
setContentDescription(contentDesc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user