Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5785c5c6 authored by Flavio Fiszman's avatar Flavio Fiszman Committed by Android (Google) Code Review
Browse files

Merge "Show messages count in People Tile" into sc-dev

parents 2c691e8d 87eec504
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ public class PeopleSpaceTile implements Parcelable {
    private CharSequence mNotificationContent;
    private String mNotificationCategory;
    private Uri mNotificationDataUri;
    private int mMessagesCount;
    private Intent mIntent;
    private long mNotificationTimestamp;
    private List<ConversationStatus> mStatuses;
@@ -74,6 +75,7 @@ public class PeopleSpaceTile implements Parcelable {
        mNotificationContent = b.mNotificationContent;
        mNotificationCategory = b.mNotificationCategory;
        mNotificationDataUri = b.mNotificationDataUri;
        mMessagesCount = b.mMessagesCount;
        mIntent = b.mIntent;
        mNotificationTimestamp = b.mNotificationTimestamp;
        mStatuses = b.mStatuses;
@@ -140,6 +142,10 @@ public class PeopleSpaceTile implements Parcelable {
        return mNotificationDataUri;
    }

    public int getMessagesCount() {
        return mMessagesCount;
    }

    /**
     * Provides an intent to launch. If present, we should manually launch the intent on tile
     * click, rather than calling {@link android.content.pm.LauncherApps} to launch the shortcut ID.
@@ -175,6 +181,7 @@ public class PeopleSpaceTile implements Parcelable {
        builder.setNotificationContent(mNotificationContent);
        builder.setNotificationCategory(mNotificationCategory);
        builder.setNotificationDataUri(mNotificationDataUri);
        builder.setMessagesCount(mMessagesCount);
        builder.setIntent(mIntent);
        builder.setNotificationTimestamp(mNotificationTimestamp);
        builder.setStatuses(mStatuses);
@@ -196,6 +203,7 @@ public class PeopleSpaceTile implements Parcelable {
        private CharSequence mNotificationContent;
        private String mNotificationCategory;
        private Uri mNotificationDataUri;
        private int mMessagesCount;
        private Intent mIntent;
        private long mNotificationTimestamp;
        private List<ConversationStatus> mStatuses;
@@ -320,6 +328,12 @@ public class PeopleSpaceTile implements Parcelable {
            return this;
        }

        /** Sets the number of messages associated with the Tile. */
        public Builder setMessagesCount(int messagesCount) {
            mMessagesCount = messagesCount;
            return this;
        }

        /** Sets an intent to launch on click. */
        public Builder setIntent(Intent intent) {
            mIntent = intent;
@@ -359,6 +373,7 @@ public class PeopleSpaceTile implements Parcelable {
        mNotificationContent = in.readCharSequence();
        mNotificationCategory = in.readString();
        mNotificationDataUri = in.readParcelable(Uri.class.getClassLoader());
        mMessagesCount = in.readInt();
        mIntent = in.readParcelable(Intent.class.getClassLoader());
        mNotificationTimestamp = in.readLong();
        mStatuses = new ArrayList<>();
@@ -385,6 +400,7 @@ public class PeopleSpaceTile implements Parcelable {
        dest.writeCharSequence(mNotificationContent);
        dest.writeString(mNotificationCategory);
        dest.writeParcelable(mNotificationDataUri, flags);
        dest.writeInt(mMessagesCount);
        dest.writeParcelable(mIntent, flags);
        dest.writeLong(mNotificationTimestamp);
        dest.writeParcelableList(mStatuses, flags);
+13 −0
Original line number Diff line number Diff line
@@ -235,6 +235,7 @@ public class PeopleSpaceTileTest {
                .setStatuses(statusList).setNotificationKey("key")
                .setNotificationContent("content")
                .setNotificationDataUri(Uri.parse("data"))
                .setMessagesCount(2)
                .setIntent(new Intent())
                .build();

@@ -256,6 +257,7 @@ public class PeopleSpaceTileTest {
        assertThat(readTile.getNotificationKey()).isEqualTo(tile.getNotificationKey());
        assertThat(readTile.getNotificationContent()).isEqualTo(tile.getNotificationContent());
        assertThat(readTile.getNotificationDataUri()).isEqualTo(tile.getNotificationDataUri());
        assertThat(readTile.getMessagesCount()).isEqualTo(tile.getMessagesCount());
        assertThat(readTile.getIntent().toString()).isEqualTo(tile.getIntent().toString());
    }

@@ -290,6 +292,17 @@ public class PeopleSpaceTileTest {
        assertThat(tile.getNotificationDataUri()).isEqualTo(Uri.parse("test"));
    }

    @Test
    public void testMessagesCount() {
        PeopleSpaceTile tile =
                new PeopleSpaceTile.Builder(new ShortcutInfo.Builder(mContext, "123").build(),
                        mLauncherApps)
                        .setMessagesCount(2)
                        .build();

        assertThat(tile.getMessagesCount()).isEqualTo(2);
    }

    @Test
    public void testIntent() {
        PeopleSpaceTile tile = new PeopleSpaceTile.Builder(
+20 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2021 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid android:color="#9ED582" />
    <corners android:radius="@dimen/people_space_messages_count_radius" />
</shape>
+17 −3
Original line number Diff line number Diff line
@@ -98,8 +98,8 @@
            android:orientation="horizontal"
            android:paddingTop="4dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            android:layout_height="wrap_content"
            android:clipToOutline="true">
            <TextView
                android:id="@+id/name"
                android:gravity="center_vertical"
@@ -112,7 +112,21 @@
                android:ellipsize="end"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <TextView
                android:id="@+id/messages_count"
                android:gravity="end"
                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"
                />
            <ImageView
                android:id="@+id/predefined_icon"
                android:gravity="end|center_vertical"
+1 −0
Original line number Diff line number Diff line
@@ -1353,6 +1353,7 @@

    <dimen name="people_space_widget_radius">28dp</dimen>
    <dimen name="people_space_image_radius">20dp</dimen>
    <dimen name="people_space_messages_count_radius">12dp</dimen>
    <dimen name="people_space_widget_background_padding">6dp</dimen>
    <dimen name="required_width_for_medium">146dp</dimen>
    <dimen name="required_width_for_large">138dp</dimen>
Loading