Merge "Add messages count to all layouts" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0c1e189278
@@ -22,27 +22,50 @@
|
|||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="start|top"
|
android:gravity="start|top">
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
android:id="@+id/person_icon"
|
|
||||||
android:layout_marginStart="-2dp"
|
|
||||||
android:layout_marginTop="-2dp"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1" />
|
android:layout_alignParentStart="true"
|
||||||
|
android:gravity="start|top"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/availability"
|
android:id="@+id/person_icon"
|
||||||
android:layout_marginStart="-2dp"
|
android:layout_marginStart="-2dp"
|
||||||
android:layout_width="10dp"
|
android:layout_marginTop="-2dp"
|
||||||
android:layout_height="10dp"
|
android:layout_width="wrap_content"
|
||||||
android:background="@drawable/circle_green_10dp" />
|
android:layout_height="wrap_content"
|
||||||
</LinearLayout>
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/availability"
|
||||||
|
android:layout_marginStart="-2dp"
|
||||||
|
android:layout_width="10dp"
|
||||||
|
android:layout_height="10dp"
|
||||||
|
android:background="@drawable/circle_green_10dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/messages_count"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:background="@drawable/people_space_messages_count_background"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
|||||||
@@ -33,20 +33,36 @@
|
|||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1"
|
||||||
|
android:paddingBottom="4dp"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/predefined_icon"
|
android:id="@+id/predefined_icon"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:paddingTop="4dp"
|
|
||||||
android:layout_width="18dp"
|
android:layout_width="18dp"
|
||||||
android:layout_height="22dp"
|
android:layout_height="22dp"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/messages_count"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:background="@drawable/people_space_messages_count_background"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_weight="1"
|
||||||
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/name"
|
android:id="@+id/name"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:paddingTop="4dp"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
|||||||
@@ -361,10 +361,13 @@ class PeopleTileViewHelper {
|
|||||||
views.setViewVisibility(R.id.image, View.GONE);
|
views.setViewVisibility(R.id.image, View.GONE);
|
||||||
views.setImageViewResource(R.id.predefined_icon, R.drawable.ic_message);
|
views.setImageViewResource(R.id.predefined_icon, R.drawable.ic_message);
|
||||||
}
|
}
|
||||||
if (mTile.getMessagesCount() > 1 && mLayoutSize == LAYOUT_MEDIUM) {
|
if (mTile.getMessagesCount() > 1) {
|
||||||
views.setViewVisibility(R.id.messages_count, View.VISIBLE);
|
views.setViewVisibility(R.id.messages_count, View.VISIBLE);
|
||||||
views.setTextViewText(R.id.messages_count,
|
views.setTextViewText(R.id.messages_count,
|
||||||
getMessagesCountText(mTile.getMessagesCount()));
|
getMessagesCountText(mTile.getMessagesCount()));
|
||||||
|
if (mLayoutSize == LAYOUT_SMALL) {
|
||||||
|
views.setViewVisibility(R.id.predefined_icon, View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO: Set subtext as Group Sender name once storing the name in PeopleSpaceTile and
|
// TODO: Set subtext as Group Sender name once storing the name in PeopleSpaceTile and
|
||||||
// subtract 1 from maxLines when present.
|
// subtract 1 from maxLines when present.
|
||||||
|
|||||||
@@ -453,6 +453,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
assertEquals(statusContent.getText(), NOTIFICATION_CONTENT);
|
assertEquals(statusContent.getText(), NOTIFICATION_CONTENT);
|
||||||
assertThat(statusContent.getMaxLines()).isEqualTo(3);
|
assertThat(statusContent.getMaxLines()).isEqualTo(3);
|
||||||
|
|
||||||
|
// Has a single message, no count shown.
|
||||||
|
assertEquals(View.GONE, result.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
||||||
getSizeInDp(R.dimen.required_width_for_medium) - 1);
|
getSizeInDp(R.dimen.required_width_for_medium) - 1);
|
||||||
RemoteViews smallView = new PeopleTileViewHelper(mContext,
|
RemoteViews smallView = new PeopleTileViewHelper(mContext,
|
||||||
@@ -492,6 +495,10 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||||
assertEquals(statusContent.getText(), NOTIFICATION_CONTENT);
|
assertEquals(statusContent.getText(), NOTIFICATION_CONTENT);
|
||||||
assertThat(statusContent.getMaxLines()).isEqualTo(3);
|
assertThat(statusContent.getMaxLines()).isEqualTo(3);
|
||||||
|
|
||||||
|
// Has a single message, no count shown.
|
||||||
|
assertEquals(View.GONE, result.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -507,19 +514,62 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
|
|
||||||
TextView name = (TextView) result.findViewById(R.id.name);
|
TextView name = (TextView) result.findViewById(R.id.name);
|
||||||
assertEquals(name.getText(), NAME);
|
assertEquals(name.getText(), NAME);
|
||||||
TextView subtext = (TextView) result.findViewById(R.id.subtext);
|
assertEquals(View.GONE, result.findViewById(R.id.subtext).getVisibility());
|
||||||
assertEquals(View.GONE, subtext.getVisibility());
|
assertEquals(View.GONE, result.findViewById(R.id.predefined_icon).getVisibility());
|
||||||
// Has availability.
|
// Has availability.
|
||||||
View availability = result.findViewById(R.id.availability);
|
assertEquals(View.VISIBLE, result.findViewById(R.id.availability).getVisibility());
|
||||||
assertEquals(View.VISIBLE, availability.getVisibility());
|
|
||||||
// Has person icon.
|
// Has person icon.
|
||||||
View personIcon = result.findViewById(R.id.person_icon);
|
assertEquals(View.VISIBLE, result.findViewById(R.id.person_icon).getVisibility());
|
||||||
assertEquals(View.VISIBLE, personIcon.getVisibility());
|
|
||||||
// Has notification content.
|
// Has notification content.
|
||||||
TextView statusContent = (TextView) result.findViewById(R.id.text_content);
|
TextView statusContent = (TextView) result.findViewById(R.id.text_content);
|
||||||
|
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||||
assertEquals(statusContent.getText(), NOTIFICATION_CONTENT);
|
assertEquals(statusContent.getText(), NOTIFICATION_CONTENT);
|
||||||
|
assertThat(statusContent.getMaxLines()).isEqualTo(3);
|
||||||
|
|
||||||
// Has 2 messages, show count.
|
// Has two messages, show count.
|
||||||
|
assertEquals(View.VISIBLE, result.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
|
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
||||||
|
getSizeInDp(R.dimen.required_width_for_medium) - 1);
|
||||||
|
RemoteViews smallView = new PeopleTileViewHelper(mContext,
|
||||||
|
tileWithStatusAndNotification, 0, mOptions).getViews();
|
||||||
|
View smallResult = smallView.apply(mContext, null);
|
||||||
|
|
||||||
|
// Show icon instead of name.
|
||||||
|
assertEquals(View.GONE, smallResult.findViewById(R.id.name).getVisibility());
|
||||||
|
assertEquals(View.GONE,
|
||||||
|
smallResult.findViewById(R.id.predefined_icon).getVisibility());
|
||||||
|
// Has person icon.
|
||||||
|
assertEquals(View.VISIBLE,
|
||||||
|
smallResult.findViewById(R.id.person_icon).getVisibility());
|
||||||
|
|
||||||
|
// Has two messages, show count.
|
||||||
|
assertEquals(View.VISIBLE, result.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
|
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
||||||
|
getSizeInDp(R.dimen.required_width_for_large));
|
||||||
|
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
||||||
|
getSizeInDp(R.dimen.required_height_for_large));
|
||||||
|
RemoteViews largeView = new PeopleTileViewHelper(mContext,
|
||||||
|
tileWithStatusAndNotification, 0, mOptions).getViews();
|
||||||
|
View largeResult = largeView.apply(mContext, null);
|
||||||
|
|
||||||
|
name = (TextView) largeResult.findViewById(R.id.name);
|
||||||
|
assertEquals(name.getText(), NAME);
|
||||||
|
assertEquals(View.GONE, largeResult.findViewById(R.id.subtext).getVisibility());
|
||||||
|
assertEquals(View.GONE, largeResult.findViewById(R.id.predefined_icon).getVisibility());
|
||||||
|
// Has availability.
|
||||||
|
assertEquals(View.VISIBLE, largeResult.findViewById(R.id.availability).getVisibility());
|
||||||
|
// Has person icon.
|
||||||
|
View personIcon = largeResult.findViewById(R.id.person_icon);
|
||||||
|
assertEquals(View.VISIBLE, personIcon.getVisibility());
|
||||||
|
// Has notification content.
|
||||||
|
statusContent = (TextView) largeResult.findViewById(R.id.text_content);
|
||||||
|
assertEquals(View.VISIBLE, statusContent.getVisibility());
|
||||||
|
assertEquals(statusContent.getText(), NOTIFICATION_CONTENT);
|
||||||
|
assertThat(statusContent.getMaxLines()).isEqualTo(3);
|
||||||
|
|
||||||
|
// Has two messages, show count.
|
||||||
assertEquals(View.VISIBLE, result.findViewById(R.id.messages_count).getVisibility());
|
assertEquals(View.VISIBLE, result.findViewById(R.id.messages_count).getVisibility());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user