Add API for setting a content description for BigPictureStyle's picture
BigPictureStyle allows devs to attach a big picture image to their notifications. Since images can have content descriptions, allow devs to add content descriptions to the big picture image for a11y Bug: b/147295675 Test: atest NotificationManagerTest; created a notification and tested with TalkBack Change-Id: Ibdf9d67a7d9a8c3a60b2560c3be6dde93247b7ac
This commit is contained in:
@@ -5528,6 +5528,7 @@ package android.app {
|
||||
field @Deprecated public static final String EXTRA_PEOPLE = "android.people";
|
||||
field public static final String EXTRA_PEOPLE_LIST = "android.people.list";
|
||||
field public static final String EXTRA_PICTURE = "android.picture";
|
||||
field public static final String EXTRA_PICTURE_CONTENT_DESCRIPTION = "android.pictureContentDescription";
|
||||
field public static final String EXTRA_PROGRESS = "android.progress";
|
||||
field public static final String EXTRA_PROGRESS_INDETERMINATE = "android.progressIndeterminate";
|
||||
field public static final String EXTRA_PROGRESS_MAX = "android.progressMax";
|
||||
@@ -5673,6 +5674,7 @@ package android.app {
|
||||
method public android.app.Notification.BigPictureStyle bigLargeIcon(android.graphics.Bitmap);
|
||||
method public android.app.Notification.BigPictureStyle bigLargeIcon(android.graphics.drawable.Icon);
|
||||
method public android.app.Notification.BigPictureStyle bigPicture(android.graphics.Bitmap);
|
||||
method @NonNull public android.app.Notification.BigPictureStyle bigPictureContentDescription(@Nullable CharSequence);
|
||||
method public android.app.Notification.BigPictureStyle setBigContentTitle(CharSequence);
|
||||
method public android.app.Notification.BigPictureStyle setSummaryText(CharSequence);
|
||||
}
|
||||
|
||||
@@ -5528,6 +5528,7 @@ package android.app {
|
||||
field @Deprecated public static final String EXTRA_PEOPLE = "android.people";
|
||||
field public static final String EXTRA_PEOPLE_LIST = "android.people.list";
|
||||
field public static final String EXTRA_PICTURE = "android.picture";
|
||||
field public static final String EXTRA_PICTURE_CONTENT_DESCRIPTION = "android.pictureContentDescription";
|
||||
field public static final String EXTRA_PROGRESS = "android.progress";
|
||||
field public static final String EXTRA_PROGRESS_INDETERMINATE = "android.progressIndeterminate";
|
||||
field public static final String EXTRA_PROGRESS_MAX = "android.progressMax";
|
||||
@@ -5673,6 +5674,7 @@ package android.app {
|
||||
method public android.app.Notification.BigPictureStyle bigLargeIcon(android.graphics.Bitmap);
|
||||
method public android.app.Notification.BigPictureStyle bigLargeIcon(android.graphics.drawable.Icon);
|
||||
method public android.app.Notification.BigPictureStyle bigPicture(android.graphics.Bitmap);
|
||||
method @NonNull public android.app.Notification.BigPictureStyle bigPictureContentDescription(@Nullable CharSequence);
|
||||
method public android.app.Notification.BigPictureStyle setBigContentTitle(CharSequence);
|
||||
method public android.app.Notification.BigPictureStyle setSummaryText(CharSequence);
|
||||
}
|
||||
|
||||
@@ -1146,6 +1146,14 @@ public class Notification implements Parcelable
|
||||
*/
|
||||
public static final String EXTRA_PICTURE = "android.picture";
|
||||
|
||||
/**
|
||||
* {@link #extras} key: this is a content description of the big picture supplied from
|
||||
* {@link BigPictureStyle#bigPicture(Bitmap)}, supplied to
|
||||
* {@link BigPictureStyle#bigPictureContentDescription(CharSequence)}.
|
||||
*/
|
||||
public static final String EXTRA_PICTURE_CONTENT_DESCRIPTION =
|
||||
"android.pictureContentDescription";
|
||||
|
||||
/**
|
||||
* {@link #extras} key: An array of CharSequences to show in {@link InboxStyle} expanded
|
||||
* notifications, each of which was supplied to {@link InboxStyle#addLine(CharSequence)}.
|
||||
@@ -6728,6 +6736,7 @@ public class Notification implements Parcelable
|
||||
private Bitmap mPicture;
|
||||
private Icon mBigLargeIcon;
|
||||
private boolean mBigLargeIconSet = false;
|
||||
private CharSequence mPictureContentDescription;
|
||||
|
||||
public BigPictureStyle() {
|
||||
}
|
||||
@@ -6757,6 +6766,16 @@ public class Notification implements Parcelable
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content description of the big picture.
|
||||
*/
|
||||
@NonNull
|
||||
public BigPictureStyle bigPictureContentDescription(
|
||||
@Nullable CharSequence contentDescription) {
|
||||
mPictureContentDescription = contentDescription;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@@ -6870,6 +6889,11 @@ public class Notification implements Parcelable
|
||||
}
|
||||
|
||||
contentView.setImageViewBitmap(R.id.big_picture, mPicture);
|
||||
|
||||
if (mPictureContentDescription != null) {
|
||||
contentView.setContentDescription(R.id.big_picture, mPictureContentDescription);
|
||||
}
|
||||
|
||||
return contentView;
|
||||
}
|
||||
|
||||
@@ -6882,6 +6906,10 @@ public class Notification implements Parcelable
|
||||
if (mBigLargeIconSet) {
|
||||
extras.putParcelable(EXTRA_LARGE_ICON_BIG, mBigLargeIcon);
|
||||
}
|
||||
if (mPictureContentDescription != null) {
|
||||
extras.putCharSequence(EXTRA_PICTURE_CONTENT_DESCRIPTION,
|
||||
mPictureContentDescription);
|
||||
}
|
||||
extras.putParcelable(EXTRA_PICTURE, mPicture);
|
||||
}
|
||||
|
||||
@@ -6896,6 +6924,12 @@ public class Notification implements Parcelable
|
||||
mBigLargeIconSet = true;
|
||||
mBigLargeIcon = extras.getParcelable(EXTRA_LARGE_ICON_BIG);
|
||||
}
|
||||
|
||||
if (extras.containsKey(EXTRA_PICTURE_CONTENT_DESCRIPTION)) {
|
||||
mPictureContentDescription =
|
||||
extras.getCharSequence(EXTRA_PICTURE_CONTENT_DESCRIPTION);
|
||||
}
|
||||
|
||||
mPicture = extras.getParcelable(EXTRA_PICTURE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user