Update a11y content descriptions
Align DND layouts better with status/empty layouts. Fixes: 187384903, 182920218, 189896324, 189906264 Test: PeopleTileViewHelperTest Change-Id: Id806de7e2d8e4a55982b8cb2a48de53730bcc04a
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
android:id="@android:id/background"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:contentDescription="@string/status_before_loading"
|
||||
android:layout_gravity="top"
|
||||
android:paddingVertical="16dp"
|
||||
android:paddingHorizontal="16dp"
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
android:orientation="horizontal">
|
||||
<ImageView
|
||||
android:id="@+id/person_icon"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp" />
|
||||
android:layout_width="@dimen/avatar_size_for_medium_empty"
|
||||
android:layout_height="@dimen/avatar_size_for_medium_empty" />
|
||||
<ImageView
|
||||
android:id="@+id/availability"
|
||||
android:layout_width="10dp"
|
||||
@@ -46,8 +46,9 @@
|
||||
android:background="@drawable/availability_dot_10dp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/padding_before_availability"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingStart="@dimen/availability_dot_shown_padding"
|
||||
android:gravity="top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
android:tint="?android:attr/textColorSecondary"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="22dp" />
|
||||
android:layout_height="18dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/messages_count"
|
||||
|
||||
@@ -21,26 +21,27 @@
|
||||
android:id="@android:id/background"
|
||||
android:background="@drawable/people_tile_suppressed_background"
|
||||
android:clipToOutline="true"
|
||||
android:padding="8dp"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/person_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_width="@dimen/avatar_size_for_medium_empty"
|
||||
android:layout_height="@dimen/avatar_size_for_medium_empty"/>
|
||||
|
||||
<TextView
|
||||
android:gravity="start"
|
||||
android:id="@+id/text_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:singleLine="false"
|
||||
android:text="@string/empty_status"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/content_text_size_for_medium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/person_icon"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
|
||||
@@ -1462,6 +1462,7 @@
|
||||
<dimen name="required_height_for_large">168dp</dimen>
|
||||
<dimen name="default_width">146dp</dimen>
|
||||
<dimen name="default_height">92dp</dimen>
|
||||
<dimen name="avatar_size_for_medium_empty">64dp</dimen>
|
||||
<dimen name="avatar_size_for_medium">52dp</dimen>
|
||||
<dimen name="max_people_avatar_size_for_large_content">64dp</dimen>
|
||||
<dimen name="max_people_avatar_size">108dp</dimen>
|
||||
@@ -1481,7 +1482,10 @@
|
||||
<dimen name="largest_predefined_icon">32dp</dimen>
|
||||
<dimen name="availability_dot_status_padding">8dp</dimen>
|
||||
<dimen name="availability_dot_notification_padding">12dp</dimen>
|
||||
<dimen name="availability_dot_shown_padding">4dp</dimen>
|
||||
<dimen name="availability_dot_missing_padding">12dp</dimen>
|
||||
<dimen name="medium_content_padding_above_name">4dp</dimen>
|
||||
<dimen name="padding_above_predefined_icon_for_small">4dp</dimen>
|
||||
<dimen name="padding_between_suppressed_layout_items">8dp</dimen>
|
||||
|
||||
<!-- Accessibility floating menu -->
|
||||
|
||||
@@ -2951,9 +2951,11 @@
|
||||
<!-- Text when the Conversation widget when Do Not Disturb is suppressing the notification. [CHAR LIMIT=50] -->
|
||||
<string name="paused_by_dnd">Paused by Do Not Disturb</string>
|
||||
<!-- Content description text on the Conversation widget when a person has sent a new text message [CHAR LIMIT=150] -->
|
||||
<string name="new_notification_text_content_description"><xliff:g id="name" example="Anna">%1$s</xliff:g> sent a message</string>
|
||||
<string name="new_notification_text_content_description"><xliff:g id="name" example="Anna">%1$s</xliff:g> sent a message: <xliff:g id="notification" example="Hey! How is your day going">%2$s</xliff:g></string>
|
||||
<!-- Content description text on the Conversation widget when a person has sent a new image message [CHAR LIMIT=150] -->
|
||||
<string name="new_notification_image_content_description"><xliff:g id="name" example="Anna">%1$s</xliff:g> sent an image</string>
|
||||
<!-- Content description text on the Conversation widget when a person has a new status posted [CHAR LIMIT=150] -->
|
||||
<string name="new_status_content_description"><xliff:g id="name" example="Anna">%1$s</xliff:g> has a status update: <xliff:g id="status" example="Listening to music">%2$s</xliff:g></string>
|
||||
|
||||
<!-- Title to display in a notification when ACTION_BATTERY_CHANGED.EXTRA_PRESENT field is false
|
||||
[CHAR LIMIT=NONE] -->
|
||||
|
||||
@@ -130,6 +130,8 @@ public class PeopleTileViewHelper {
|
||||
private static final Pattern ANY_DOUBLE_MARK_PATTERN = Pattern.compile("[!?][!?]+");
|
||||
private static final Pattern MIXED_MARK_PATTERN = Pattern.compile("![?].*|.*[?]!");
|
||||
|
||||
static final String BRIEF_PAUSE_ON_TALKBACK = "\n\n";
|
||||
|
||||
// This regex can be used to match Unicode emoji characters and character sequences. It's from
|
||||
// the official Unicode site (https://unicode.org/reports/tr51/#EBNF_and_Regex) with minor
|
||||
// changes to fit our needs. It should be updated once new emoji categories are added.
|
||||
@@ -476,7 +478,7 @@ public class PeopleTileViewHelper {
|
||||
avatarSize = Math.min(avatarHeightSpace, avatarWidthSpace);
|
||||
}
|
||||
|
||||
if (isDndBlockingTileData(mTile)) {
|
||||
if (isDndBlockingTileData(mTile) && mLayoutSize != LAYOUT_SMALL) {
|
||||
avatarSize = createDndRemoteViews().mAvatarSize;
|
||||
}
|
||||
|
||||
@@ -493,14 +495,33 @@ public class PeopleTileViewHelper {
|
||||
boolean isAvailable =
|
||||
mTile.getStatuses() != null && mTile.getStatuses().stream().anyMatch(
|
||||
c -> c.getAvailability() == AVAILABILITY_AVAILABLE);
|
||||
|
||||
int startPadding;
|
||||
if (isAvailable) {
|
||||
views.setViewVisibility(R.id.availability, View.VISIBLE);
|
||||
startPadding = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.availability_dot_shown_padding);
|
||||
} else {
|
||||
views.setViewVisibility(R.id.availability, View.GONE);
|
||||
startPadding = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.availability_dot_missing_padding);
|
||||
}
|
||||
boolean isLeftToRight = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault())
|
||||
== View.LAYOUT_DIRECTION_LTR;
|
||||
views.setViewPadding(R.id.padding_before_availability,
|
||||
isLeftToRight ? startPadding : 0, 0, isLeftToRight ? 0 : startPadding,
|
||||
0);
|
||||
|
||||
boolean hasNewStory = getHasNewStory(mTile);
|
||||
views.setImageViewBitmap(R.id.person_icon,
|
||||
getPersonIconBitmap(mContext, mTile, maxAvatarSize));
|
||||
getPersonIconBitmap(mContext, mTile, maxAvatarSize, hasNewStory));
|
||||
if (hasNewStory) {
|
||||
views.setContentDescription(R.id.person_icon,
|
||||
mContext.getString(R.string.new_story_status_content_description,
|
||||
mTile.getUserName()));
|
||||
} else {
|
||||
views.setContentDescription(R.id.person_icon, null);
|
||||
}
|
||||
return views;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to set common fields: " + e);
|
||||
@@ -508,6 +529,11 @@ public class PeopleTileViewHelper {
|
||||
return views;
|
||||
}
|
||||
|
||||
private static boolean getHasNewStory(PeopleSpaceTile tile) {
|
||||
return tile.getStatuses() != null && tile.getStatuses().stream().anyMatch(
|
||||
c -> c.getActivity() == ACTIVITY_NEW_STORY);
|
||||
}
|
||||
|
||||
private RemoteViews setLaunchIntents(RemoteViews views) {
|
||||
if (!PeopleTileKey.isValid(mKey) || mTile == null) {
|
||||
if (DEBUG) Log.d(TAG, "Skipping launch intent, Null tile or invalid key: " + mKey);
|
||||
@@ -545,22 +571,9 @@ public class PeopleTileViewHelper {
|
||||
}
|
||||
|
||||
private RemoteViewsAndSizes createDndRemoteViews() {
|
||||
boolean isHorizontal = mLayoutSize == LAYOUT_MEDIUM;
|
||||
int layoutId = isHorizontal
|
||||
? R.layout.people_tile_with_suppression_detail_content_horizontal
|
||||
: R.layout.people_tile_with_suppression_detail_content_vertical;
|
||||
RemoteViews views = new RemoteViews(mContext.getPackageName(), layoutId);
|
||||
RemoteViews views = new RemoteViews(mContext.getPackageName(), getViewForDndRemoteViews());
|
||||
|
||||
int outerPadding = mLayoutSize == LAYOUT_LARGE ? 16 : 8;
|
||||
int outerPaddingPx = dpToPx(outerPadding);
|
||||
views.setViewPadding(
|
||||
android.R.id.background,
|
||||
outerPaddingPx,
|
||||
outerPaddingPx,
|
||||
outerPaddingPx,
|
||||
outerPaddingPx);
|
||||
|
||||
int mediumAvatarSize = getSizeInDp(R.dimen.avatar_size_for_medium);
|
||||
int mediumAvatarSize = getSizeInDp(R.dimen.avatar_size_for_medium_empty);
|
||||
int maxAvatarSize = getSizeInDp(R.dimen.max_people_avatar_size);
|
||||
|
||||
String text = mContext.getString(R.string.paused_by_dnd);
|
||||
@@ -575,11 +588,15 @@ public class PeopleTileViewHelper {
|
||||
int lineHeight = getLineHeightFromResource(textSizeResId);
|
||||
|
||||
int avatarSize;
|
||||
if (isHorizontal) {
|
||||
int maxTextHeight = mHeight - outerPadding;
|
||||
if (mLayoutSize == LAYOUT_MEDIUM) {
|
||||
int maxTextHeight = mHeight - 16;
|
||||
views.setInt(R.id.text_content, "setMaxLines", maxTextHeight / lineHeight);
|
||||
avatarSize = mediumAvatarSize;
|
||||
} else {
|
||||
int outerPadding = 16;
|
||||
int outerPaddingTop = outerPadding - 2;
|
||||
int outerPaddingPx = dpToPx(outerPadding);
|
||||
int outerPaddingTopPx = dpToPx(outerPaddingTop);
|
||||
int iconSize =
|
||||
getSizeInDp(
|
||||
mLayoutSize == LAYOUT_SMALL
|
||||
@@ -593,38 +610,47 @@ public class PeopleTileViewHelper {
|
||||
|
||||
int availableAvatarHeight;
|
||||
int textHeight = estimateTextHeight(text, textSizeResId, maxTextWidth);
|
||||
if (textHeight <= maxTextHeight) {
|
||||
if (textHeight <= maxTextHeight && mLayoutSize == LAYOUT_LARGE) {
|
||||
// If the text will fit, then display it and deduct its height from the space we
|
||||
// have for the avatar.
|
||||
availableAvatarHeight = heightWithoutIcon - textHeight - paddingBetweenElements * 2;
|
||||
views.setViewVisibility(R.id.text_content, View.VISIBLE);
|
||||
views.setInt(R.id.text_content, "setMaxLines", maxTextHeight / lineHeight);
|
||||
views.setContentDescription(R.id.predefined_icon, null);
|
||||
int availableAvatarWidth = mWidth - outerPadding * 2;
|
||||
avatarSize =
|
||||
MathUtils.clamp(
|
||||
/* value= */ Math.min(availableAvatarWidth, availableAvatarHeight),
|
||||
/* min= */ dpToPx(10),
|
||||
/* max= */ maxAvatarSize);
|
||||
views.setViewPadding(
|
||||
android.R.id.background,
|
||||
outerPaddingPx,
|
||||
outerPaddingTopPx,
|
||||
outerPaddingPx,
|
||||
outerPaddingPx);
|
||||
views.setViewLayoutWidth(R.id.predefined_icon, iconSize, COMPLEX_UNIT_DIP);
|
||||
views.setViewLayoutHeight(R.id.predefined_icon, iconSize, COMPLEX_UNIT_DIP);
|
||||
} else {
|
||||
// If the height doesn't fit, then hide it. The dnd icon will still show.
|
||||
availableAvatarHeight = heightWithoutIcon - paddingBetweenElements;
|
||||
views.setViewVisibility(R.id.text_content, View.GONE);
|
||||
// If expected to use LAYOUT_LARGE, but we found we do not have space for the
|
||||
// text as calculated above, re-assign the view to the small layout.
|
||||
if (mLayoutSize != LAYOUT_SMALL) {
|
||||
views = new RemoteViews(mContext.getPackageName(), R.layout.people_tile_small);
|
||||
}
|
||||
avatarSize = getMaxAvatarSize(views);
|
||||
views.setViewVisibility(R.id.messages_count, View.GONE);
|
||||
views.setViewVisibility(R.id.name, View.GONE);
|
||||
// If we don't show the dnd text, set it as the content description on the icon
|
||||
// for a11y.
|
||||
views.setContentDescription(R.id.predefined_icon, text);
|
||||
}
|
||||
|
||||
int availableAvatarWidth = mWidth - outerPadding * 2;
|
||||
avatarSize =
|
||||
MathUtils.clamp(
|
||||
/* value= */ Math.min(availableAvatarWidth, availableAvatarHeight),
|
||||
/* min= */ dpToPx(10),
|
||||
/* max= */ maxAvatarSize);
|
||||
|
||||
views.setViewLayoutWidth(R.id.predefined_icon, iconSize, COMPLEX_UNIT_DIP);
|
||||
views.setViewLayoutHeight(R.id.predefined_icon, iconSize, COMPLEX_UNIT_DIP);
|
||||
views.setViewVisibility(R.id.predefined_icon, View.VISIBLE);
|
||||
views.setImageViewResource(R.id.predefined_icon, R.drawable.ic_qs_dnd_on);
|
||||
}
|
||||
|
||||
return new RemoteViewsAndSizes(views, avatarSize);
|
||||
}
|
||||
|
||||
|
||||
private RemoteViews createMissedCallRemoteViews() {
|
||||
RemoteViews views = setViewForContentLayout(new RemoteViews(mContext.getPackageName(),
|
||||
getLayoutForContent()));
|
||||
@@ -632,7 +658,9 @@ public class PeopleTileViewHelper {
|
||||
views.setViewVisibility(R.id.text_content, View.VISIBLE);
|
||||
views.setViewVisibility(R.id.messages_count, View.GONE);
|
||||
setMaxLines(views, false);
|
||||
views.setTextViewText(R.id.text_content, mTile.getNotificationContent());
|
||||
CharSequence content = mTile.getNotificationContent();
|
||||
views.setTextViewText(R.id.text_content, content);
|
||||
setContentDescriptionForNotificationTextContent(views, content, mTile.getUserName());
|
||||
views.setColorAttr(R.id.text_content, "setTextColor", android.R.attr.colorError);
|
||||
views.setColorAttr(R.id.predefined_icon, "setColorFilter", android.R.attr.colorError);
|
||||
views.setImageViewResource(R.id.predefined_icon, R.drawable.ic_phone_missed);
|
||||
@@ -653,12 +681,16 @@ public class PeopleTileViewHelper {
|
||||
if (image != null) {
|
||||
// TODO: Use NotificationInlineImageCache
|
||||
views.setImageViewUri(R.id.image, image);
|
||||
String newImageDescription = mContext.getString(
|
||||
R.string.new_notification_image_content_description, mTile.getUserName());
|
||||
views.setContentDescription(R.id.image, newImageDescription);
|
||||
views.setViewVisibility(R.id.image, View.VISIBLE);
|
||||
views.setViewVisibility(R.id.text_content, View.GONE);
|
||||
views.setImageViewResource(R.id.predefined_icon, R.drawable.ic_photo_camera);
|
||||
} else {
|
||||
setMaxLines(views, !TextUtils.isEmpty(sender));
|
||||
CharSequence content = mTile.getNotificationContent();
|
||||
setContentDescriptionForNotificationTextContent(views, content,
|
||||
sender != null ? sender : mTile.getUserName());
|
||||
views = decorateBackground(views, content);
|
||||
views.setColorAttr(R.id.text_content, "setTextColor", android.R.attr.textColorPrimary);
|
||||
views.setTextViewText(R.id.text_content, mTile.getNotificationContent());
|
||||
@@ -688,6 +720,16 @@ public class PeopleTileViewHelper {
|
||||
return views;
|
||||
}
|
||||
|
||||
private void setContentDescriptionForNotificationTextContent(RemoteViews views,
|
||||
CharSequence content, CharSequence sender) {
|
||||
String newTextDescriptionWithNotificationContent = mContext.getString(
|
||||
R.string.new_notification_text_content_description, sender, content);
|
||||
int idForContentDescription =
|
||||
mLayoutSize == LAYOUT_SMALL ? R.id.predefined_icon : R.id.text_content;
|
||||
views.setContentDescription(idForContentDescription,
|
||||
newTextDescriptionWithNotificationContent);
|
||||
}
|
||||
|
||||
// Some messaging apps only include up to 6 messages in their notifications.
|
||||
private String getMessagesCountText(int count) {
|
||||
if (count >= MESSAGES_COUNT_OVERFLOW) {
|
||||
@@ -717,7 +759,7 @@ public class PeopleTileViewHelper {
|
||||
views.setTextViewText(R.id.text_content, statusText);
|
||||
|
||||
if (status.getActivity() == ACTIVITY_BIRTHDAY
|
||||
|| status.getActivity() == ACTIVITY_UPCOMING_BIRTHDAY) {
|
||||
|| status.getActivity() == ACTIVITY_UPCOMING_BIRTHDAY) {
|
||||
setEmojiBackground(views, EMOJI_CAKE);
|
||||
}
|
||||
|
||||
@@ -745,9 +787,56 @@ public class PeopleTileViewHelper {
|
||||
}
|
||||
setAvailabilityDotPadding(views, R.dimen.availability_dot_status_padding);
|
||||
views.setImageViewResource(R.id.predefined_icon, getDrawableForStatus(status));
|
||||
CharSequence descriptionForStatus =
|
||||
getContentDescriptionForStatus(status);
|
||||
CharSequence customContentDescriptionForStatus = mContext.getString(
|
||||
R.string.new_status_content_description, mTile.getUserName(), descriptionForStatus);
|
||||
switch (mLayoutSize) {
|
||||
case LAYOUT_LARGE:
|
||||
views.setContentDescription(R.id.text_content,
|
||||
customContentDescriptionForStatus);
|
||||
break;
|
||||
case LAYOUT_MEDIUM:
|
||||
views.setContentDescription(statusIcon == null ? R.id.text_content : R.id.name,
|
||||
customContentDescriptionForStatus);
|
||||
break;
|
||||
case LAYOUT_SMALL:
|
||||
views.setContentDescription(R.id.predefined_icon,
|
||||
customContentDescriptionForStatus);
|
||||
break;
|
||||
}
|
||||
return views;
|
||||
}
|
||||
|
||||
private CharSequence getContentDescriptionForStatus(ConversationStatus status) {
|
||||
CharSequence name = mTile.getUserName();
|
||||
if (!TextUtils.isEmpty(status.getDescription())) {
|
||||
return status.getDescription();
|
||||
}
|
||||
switch (status.getActivity()) {
|
||||
case ACTIVITY_NEW_STORY:
|
||||
return mContext.getString(R.string.new_story_status_content_description,
|
||||
name);
|
||||
case ACTIVITY_ANNIVERSARY:
|
||||
return mContext.getString(R.string.anniversary_status_content_description, name);
|
||||
case ACTIVITY_UPCOMING_BIRTHDAY:
|
||||
return mContext.getString(R.string.upcoming_birthday_status_content_description,
|
||||
name);
|
||||
case ACTIVITY_BIRTHDAY:
|
||||
return mContext.getString(R.string.birthday_status_content_description, name);
|
||||
case ACTIVITY_LOCATION:
|
||||
return mContext.getString(R.string.location_status_content_description, name);
|
||||
case ACTIVITY_GAME:
|
||||
return mContext.getString(R.string.game_status);
|
||||
case ACTIVITY_VIDEO:
|
||||
return mContext.getString(R.string.video_status);
|
||||
case ACTIVITY_AUDIO:
|
||||
return mContext.getString(R.string.audio_status);
|
||||
default:
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
}
|
||||
|
||||
private int getDrawableForStatus(ConversationStatus status) {
|
||||
switch (status.getActivity()) {
|
||||
case ACTIVITY_NEW_STORY:
|
||||
@@ -955,6 +1044,11 @@ public class PeopleTileViewHelper {
|
||||
|
||||
private RemoteViews setViewForContentLayout(RemoteViews views) {
|
||||
views = decorateBackground(views, "");
|
||||
views.setContentDescription(R.id.predefined_icon, null);
|
||||
views.setContentDescription(R.id.text_content, null);
|
||||
views.setContentDescription(R.id.name, null);
|
||||
views.setContentDescription(R.id.image, null);
|
||||
views.setAccessibilityTraversalAfter(R.id.text_content, R.id.name);
|
||||
if (mLayoutSize == LAYOUT_SMALL) {
|
||||
views.setViewVisibility(R.id.predefined_icon, View.VISIBLE);
|
||||
views.setViewVisibility(R.id.name, View.GONE);
|
||||
@@ -1069,6 +1163,18 @@ public class PeopleTileViewHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private int getViewForDndRemoteViews() {
|
||||
switch (mLayoutSize) {
|
||||
case LAYOUT_MEDIUM:
|
||||
return R.layout.people_tile_with_suppression_detail_content_horizontal;
|
||||
case LAYOUT_LARGE:
|
||||
return R.layout.people_tile_with_suppression_detail_content_vertical;
|
||||
case LAYOUT_SMALL:
|
||||
default:
|
||||
return getLayoutSmallByHeight();
|
||||
}
|
||||
}
|
||||
|
||||
private int getLayoutSmallByHeight() {
|
||||
if (mHeight >= getSizeInDp(R.dimen.required_height_for_medium)) {
|
||||
return R.layout.people_tile_small;
|
||||
@@ -1077,12 +1183,15 @@ public class PeopleTileViewHelper {
|
||||
}
|
||||
|
||||
/** Returns a bitmap with the user icon and package icon. */
|
||||
public static Bitmap getPersonIconBitmap(
|
||||
Context context, PeopleSpaceTile tile, int maxAvatarSize) {
|
||||
boolean hasNewStory =
|
||||
tile.getStatuses() != null && tile.getStatuses().stream().anyMatch(
|
||||
c -> c.getActivity() == ACTIVITY_NEW_STORY);
|
||||
public static Bitmap getPersonIconBitmap(Context context, PeopleSpaceTile tile,
|
||||
int maxAvatarSize) {
|
||||
boolean hasNewStory = getHasNewStory(tile);
|
||||
return getPersonIconBitmap(context, tile, maxAvatarSize, hasNewStory);
|
||||
}
|
||||
|
||||
/** Returns a bitmap with the user icon and package icon. */
|
||||
private static Bitmap getPersonIconBitmap(
|
||||
Context context, PeopleSpaceTile tile, int maxAvatarSize, boolean hasNewStory) {
|
||||
Icon icon = tile.getUserIcon();
|
||||
if (icon == null) {
|
||||
Drawable placeholder = context.getDrawable(R.drawable.ic_avatar_with_badge);
|
||||
|
||||
@@ -364,6 +364,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||
assertEquals(statusContent.getText(), mContext.getString(R.string.birthday_status));
|
||||
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
||||
assertThat(statusContent.getContentDescription().toString()).isEqualTo(
|
||||
mContext.getString(R.string.new_status_content_description, NAME,
|
||||
mContext.getString(R.string.birthday_status_content_description, NAME)));
|
||||
|
||||
mWidth = getSizeInDp(R.dimen.required_width_for_medium) - 1;
|
||||
RemoteViews smallView = getPeopleTileViewHelper(tileWithStatusTemplate).getViews();
|
||||
@@ -373,6 +376,10 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
assertEquals(View.GONE, smallResult.findViewById(R.id.name).getVisibility());
|
||||
assertEquals(View.VISIBLE,
|
||||
smallResult.findViewById(R.id.predefined_icon).getVisibility());
|
||||
assertThat(smallResult.findViewById(
|
||||
R.id.predefined_icon).getContentDescription().toString()).isEqualTo(
|
||||
mContext.getString(R.string.new_status_content_description, NAME,
|
||||
mContext.getString(R.string.birthday_status_content_description, NAME)));
|
||||
// Has person icon.
|
||||
assertEquals(View.VISIBLE,
|
||||
smallResult.findViewById(R.id.person_icon).getVisibility());
|
||||
@@ -414,6 +421,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||
assertEquals(statusContent.getText(), mContext.getString(R.string.birthday_status));
|
||||
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
||||
assertThat(statusContent.getContentDescription().toString()).isEqualTo(
|
||||
mContext.getString(R.string.new_status_content_description, NAME,
|
||||
mContext.getString(R.string.birthday_status_content_description, NAME)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -439,6 +449,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
TextView statusContent = (TextView) result.findViewById(R.id.text_content);
|
||||
assertEquals(statusContent.getText(), GAME_DESCRIPTION);
|
||||
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
||||
assertThat(statusContent.getContentDescription().toString()).isEqualTo(
|
||||
mContext.getString(R.string.new_status_content_description, NAME,
|
||||
GAME_DESCRIPTION));
|
||||
|
||||
mWidth = getSizeInDp(R.dimen.required_width_for_medium) - 1;
|
||||
RemoteViews smallView = getPeopleTileViewHelper(tileWithStatusTemplate).getViews();
|
||||
@@ -448,6 +461,10 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
assertEquals(View.GONE, smallResult.findViewById(R.id.name).getVisibility());
|
||||
assertEquals(View.VISIBLE,
|
||||
smallResult.findViewById(R.id.predefined_icon).getVisibility());
|
||||
assertThat(smallResult.findViewById(
|
||||
R.id.predefined_icon).getContentDescription().toString()).isEqualTo(
|
||||
mContext.getString(R.string.new_status_content_description, NAME,
|
||||
GAME_DESCRIPTION));
|
||||
// Has person icon.
|
||||
assertEquals(View.VISIBLE,
|
||||
smallResult.findViewById(R.id.person_icon).getVisibility());
|
||||
@@ -491,6 +508,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||
assertEquals(statusContent.getText(), GAME_DESCRIPTION);
|
||||
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
||||
assertThat(statusContent.getContentDescription().toString()).isEqualTo(
|
||||
mContext.getString(R.string.new_status_content_description, NAME,
|
||||
GAME_DESCRIPTION));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -515,6 +535,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
// Has status.
|
||||
TextView statusContent = (TextView) result.findViewById(R.id.name);
|
||||
assertEquals(statusContent.getText(), "Anniversary");
|
||||
// Since the image is showing which removes name, we need to manually include the name.
|
||||
assertThat(statusContent.getContentDescription().toString()).isEqualTo(
|
||||
mContext.getString(R.string.new_status_content_description, NAME, "Anniversary"));
|
||||
assertThat(statusContent.getMaxLines()).isEqualTo(1);
|
||||
|
||||
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||
@@ -536,6 +559,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
statusContent = (TextView) largeResult.findViewById(R.id.text_content);
|
||||
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||
assertEquals(statusContent.getText(), "Anniversary");
|
||||
// Since the image is showing which removes name, we need to manually include the name.
|
||||
assertThat(statusContent.getContentDescription().toString()).isEqualTo(
|
||||
mContext.getString(R.string.new_status_content_description, NAME, "Anniversary"));
|
||||
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@@ -684,6 +710,8 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
TextView statusContent = (TextView) result.findViewById(R.id.text_content);
|
||||
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||
assertEquals(statusContent.getText(), MISSED_CALL);
|
||||
assertEquals(statusContent.getContentDescription(), mContext.getString(
|
||||
R.string.new_notification_text_content_description, NAME, MISSED_CALL));
|
||||
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
||||
|
||||
mWidth = getSizeInDp(R.dimen.required_width_for_medium) - 1;
|
||||
@@ -695,6 +723,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
assertEquals(View.GONE, smallResult.findViewById(R.id.name).getVisibility());
|
||||
assertEquals(View.VISIBLE,
|
||||
smallResult.findViewById(R.id.predefined_icon).getVisibility());
|
||||
assertEquals(smallResult.findViewById(R.id.predefined_icon).getContentDescription(),
|
||||
mContext.getString(
|
||||
R.string.new_notification_text_content_description, NAME, MISSED_CALL));
|
||||
// Has person icon.
|
||||
assertEquals(View.VISIBLE, smallResult.findViewById(R.id.person_icon).getVisibility());
|
||||
// No messages count.
|
||||
@@ -718,6 +749,8 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
statusContent = (TextView) largeResult.findViewById(R.id.text_content);
|
||||
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||
assertEquals(statusContent.getText(), MISSED_CALL);
|
||||
assertEquals(statusContent.getContentDescription(), mContext.getString(
|
||||
R.string.new_notification_text_content_description, NAME, MISSED_CALL));
|
||||
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@@ -744,6 +777,8 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
TextView statusContent = (TextView) result.findViewById(R.id.text_content);
|
||||
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||
assertEquals(statusContent.getText(), NOTIFICATION_CONTENT);
|
||||
assertEquals(statusContent.getContentDescription(), mContext.getString(
|
||||
R.string.new_notification_text_content_description, NAME, NOTIFICATION_CONTENT));
|
||||
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
||||
|
||||
// Has a single message, no count shown.
|
||||
@@ -758,6 +793,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
assertEquals(View.GONE, smallResult.findViewById(R.id.name).getVisibility());
|
||||
assertEquals(View.VISIBLE,
|
||||
smallResult.findViewById(R.id.predefined_icon).getVisibility());
|
||||
assertEquals(smallResult.findViewById(R.id.predefined_icon).getContentDescription(),
|
||||
mContext.getString(R.string.new_notification_text_content_description, NAME,
|
||||
NOTIFICATION_CONTENT));
|
||||
// Has person icon.
|
||||
assertEquals(View.VISIBLE,
|
||||
smallResult.findViewById(R.id.person_icon).getVisibility());
|
||||
@@ -785,8 +823,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
statusContent = (TextView) largeResult.findViewById(R.id.text_content);
|
||||
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||
assertEquals(statusContent.getText(), NOTIFICATION_CONTENT);
|
||||
assertEquals(statusContent.getContentDescription(), mContext.getString(
|
||||
R.string.new_notification_text_content_description, NAME, NOTIFICATION_CONTENT));
|
||||
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
||||
|
||||
// Has a single message, no count shown.
|
||||
assertEquals(View.GONE, largeResult.findViewById(R.id.messages_count).getVisibility());
|
||||
|
||||
@@ -816,6 +855,8 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
TextView statusContent = (TextView) result.findViewById(R.id.text_content);
|
||||
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||
assertEquals(statusContent.getText(), NOTIFICATION_CONTENT);
|
||||
assertEquals(statusContent.getContentDescription(), mContext.getString(
|
||||
R.string.new_notification_text_content_description, SENDER, NOTIFICATION_CONTENT));
|
||||
|
||||
// Subtract one from lines because sender is included.
|
||||
assertThat(statusContent.getMaxLines()).isEqualTo(1);
|
||||
@@ -832,6 +873,10 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
assertEquals(View.GONE, smallResult.findViewById(R.id.name).getVisibility());
|
||||
assertEquals(View.VISIBLE,
|
||||
smallResult.findViewById(R.id.predefined_icon).getVisibility());
|
||||
assertEquals(smallResult.findViewById(R.id.predefined_icon).getContentDescription(),
|
||||
mContext.getString(
|
||||
R.string.new_notification_text_content_description, SENDER,
|
||||
NOTIFICATION_CONTENT));
|
||||
// Has person icon.
|
||||
assertEquals(View.VISIBLE,
|
||||
smallResult.findViewById(R.id.person_icon).getVisibility());
|
||||
@@ -860,6 +905,8 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
||||
statusContent = (TextView) largeResult.findViewById(R.id.text_content);
|
||||
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||
assertEquals(statusContent.getText(), NOTIFICATION_CONTENT);
|
||||
assertEquals(statusContent.getContentDescription(), mContext.getString(
|
||||
R.string.new_notification_text_content_description, SENDER, NOTIFICATION_CONTENT));
|
||||
|
||||
// Subtract one from lines because sender is included.
|
||||
assertThat(statusContent.getMaxLines()).isEqualTo(1);
|
||||
|
||||
Reference in New Issue
Block a user