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

Commit c360a6d3 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB][Chips] Update call chip to use icon from notification.

This changes updates the ongoing phone call chip to use the
`Notification.getSmallIcon()` as the icon inside the chip, instead of
hard-coding it to be a phone icon.

This includes:
1) For each notification, creating a new `statusBarChipIcon` in addition
   to creating the other location-specific icons (status bar, shelf,
   aod)
2) Updating the paddings in the chip layout, since the notification icon
   is required to come with its own padding

Bug: 354930838
Flag: NONE required for imminent release

Test: Start call without timer -> verify chip has icon only, icon is
centered
Test: Start ongoing call -> verify chip has icon and time
Test: Chip UI at various font and display sizes
Test: Theme changes (chip text updates to both white and black
correctly)
Test: Accessibility for chip

Test: Enable com.android.systemui.status_bar_screen_sharing_chips flag
-> verify call and screen chips still work okay (the paddings are off
but general functionality still works)

Test: atest OngoingCallControllerTest

Change-Id: Id7ad51ad3a590e6556987cba4f2639870c422f92
parent 92c92ce3
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -23,8 +23,7 @@
    android:layout_gravity="center_vertical|start"
    android:layout_marginStart="5dp"
>
    <!-- TODO(b/332662551): Update this content description when this supports more than just
         phone calls. -->
    <!-- TODO(b/354930838): Fix these paddings for the new screen chips. -->
    <com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer
        android:id="@+id/ongoing_activity_chip_background"
        android:layout_width="wrap_content"
@@ -32,18 +31,18 @@
        android:layout_gravity="center_vertical"
        android:gravity="center"
        android:background="@drawable/ongoing_activity_chip_bg"
        android:paddingStart="@dimen/ongoing_activity_chip_side_padding"
        android:paddingEnd="@dimen/ongoing_activity_chip_side_padding"
        android:paddingStart="@dimen/ongoing_activity_chip_side_padding_with_notif_icon"
        android:paddingEnd="@dimen/ongoing_activity_chip_side_padding_with_notif_icon"
        android:minWidth="@dimen/min_clickable_item_size"
    >

        <ImageView
            android:src="@*android:drawable/ic_phone"
            android:id="@+id/ongoing_activity_chip_icon"
            android:contentDescription="@string/ongoing_phone_call_content_description"
            android:layout_width="@dimen/ongoing_activity_chip_icon_size"
            android:layout_height="@dimen/ongoing_activity_chip_icon_size"
            android:tint="?android:attr/colorPrimary"
            android:visibility="gone"
        />

        <!-- Only one of [ongoing_activity_chip_time, ongoing_activity_chip_text] will ever
@@ -54,7 +53,7 @@
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:gravity="center|start"
            android:paddingStart="@dimen/ongoing_activity_chip_icon_text_padding"
            android:paddingEnd="@dimen/ongoing_activity_chip_text_end_padding_with_notif_icon"
            android:textAppearance="@android:style/TextAppearance.Material.Small"
            android:fontFamily="@*android:string/config_headlineFontFamily"
            android:textColor="?android:attr/colorPrimary"
+6 −0
Original line number Diff line number Diff line
@@ -1730,9 +1730,15 @@

    <!-- Ongoing activity chip -->
    <dimen name="ongoing_activity_chip_side_padding">12dp</dimen>
    <!-- The start padding to use on the activity chip if the icon comes from the notification's smallIcon field (the small notif icons embed their own padding, so the chip itself can have less padding) -->
    <dimen name="ongoing_activity_chip_side_padding_with_notif_icon">6dp</dimen>
    <dimen name="ongoing_activity_chip_icon_size">16dp</dimen>
    <!-- The size to use for the icon in the ongoing activity chip if the icon comes from the notification's smallIcon field -->
    <dimen name="ongoing_activity_chip_notif_icon_size">22dp</dimen>

    <!-- The padding between the icon and the text. -->
    <dimen name="ongoing_activity_chip_icon_text_padding">4dp</dimen>
    <dimen name="ongoing_activity_chip_text_end_padding_with_notif_icon">6dp</dimen>
    <dimen name="ongoing_activity_chip_corner_radius">28dp</dimen>

    <!-- Status bar user chip -->
+2 −0
Original line number Diff line number Diff line
@@ -105,6 +105,8 @@ constructor(
    }

    companion object {
        // TODO(b/354930838): Use the icon from the call notification instead of hard-coding the
        // icon to always be a phone.
        private val phoneIcon =
            Icon.Resource(
                com.android.internal.R.drawable.ic_phone,
+11 −1
Original line number Diff line number Diff line
@@ -123,6 +123,8 @@ constructor(
            // Construct the status bar icon view.
            val sbIcon = iconBuilder.createIconView(entry)
            sbIcon.scaleType = ImageView.ScaleType.CENTER_INSIDE
            val sbChipIcon = iconBuilder.createIconView(entry)
            sbChipIcon.scaleType = ImageView.ScaleType.CENTER_INSIDE

            // Construct the shelf icon view.
            val shelfIcon = iconBuilder.createIconView(entry)
@@ -139,9 +141,17 @@ constructor(

            try {
                setIcon(entry, normalIconDescriptor, sbIcon)
                setIcon(entry, normalIconDescriptor, sbChipIcon)
                setIcon(entry, sensitiveIconDescriptor, shelfIcon)
                setIcon(entry, sensitiveIconDescriptor, aodIcon)
                entry.icons = IconPack.buildPack(sbIcon, shelfIcon, aodIcon, entry.icons)
                entry.icons =
                    IconPack.buildPack(
                        sbIcon,
                        sbChipIcon,
                        shelfIcon,
                        aodIcon,
                        entry.icons,
                    )
            } catch (e: InflationException) {
                entry.icons = IconPack.buildEmptyPack(entry.icons)
                throw e
+18 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ public final class IconPack {

    private final boolean mAreIconsAvailable;
    @Nullable private final StatusBarIconView mStatusBarIcon;
    @Nullable private final StatusBarIconView mStatusBarChipIcon;
    @Nullable private final StatusBarIconView mShelfIcon;
    @Nullable private final StatusBarIconView mAodIcon;

@@ -43,7 +44,7 @@ public final class IconPack {
     * haven't been inflated yet or there was an error while inflating them).
     */
    public static IconPack buildEmptyPack(@Nullable IconPack fromSource) {
        return new IconPack(false, null, null, null, fromSource);
        return new IconPack(false, null, null, null, null, fromSource);
    }

    /**
@@ -51,20 +52,24 @@ public final class IconPack {
     */
    public static IconPack buildPack(
            @NonNull StatusBarIconView statusBarIcon,
            @NonNull StatusBarIconView statusBarChipIcon,
            @NonNull StatusBarIconView shelfIcon,
            @NonNull StatusBarIconView aodIcon,
            @Nullable IconPack source) {
        return new IconPack(true, statusBarIcon, shelfIcon, aodIcon, source);
        return new IconPack(
                true, statusBarIcon, statusBarChipIcon, shelfIcon, aodIcon, source);
    }

    private IconPack(
            boolean areIconsAvailable,
            @Nullable StatusBarIconView statusBarIcon,
            @Nullable StatusBarIconView statusBarChipIcon,
            @Nullable StatusBarIconView shelfIcon,
            @Nullable StatusBarIconView aodIcon,
            @Nullable IconPack source) {
        mAreIconsAvailable = areIconsAvailable;
        mStatusBarIcon = statusBarIcon;
        mStatusBarChipIcon = statusBarChipIcon;
        mShelfIcon = shelfIcon;
        mAodIcon = aodIcon;
        if (source != null) {
@@ -78,6 +83,17 @@ public final class IconPack {
        return mStatusBarIcon;
    }

    /**
     * The version of the notification icon that appears inside a chip within the status bar.
     *
     * Separate from {@link #getStatusBarIcon()} so that we don't have to worry about detaching and
     * re-attaching the same view when the chip appears and hides.
     */
    @Nullable
    public StatusBarIconView getStatusBarChipIcon() {
        return mStatusBarChipIcon;
    }

    /**
     * The version of the icon that appears in the "shelf" at the bottom of the notification shade.
     * In general, this icon also appears somewhere on the notification and is "sucked" into the
Loading