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

Commit 1e23f6f1 authored by Bart Sears's avatar Bart Sears Committed by Android (Google) Code Review
Browse files

Merge "Revert "[SB][Chips] Update call chip to use icon from notification."" into 24Q3-release

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

@@ -42,7 +44,6 @@
            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"
        />

        <com.android.systemui.statusbar.chips.ui.view.ChipChronometer
@@ -51,7 +52,7 @@
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:gravity="center|start"
            android:paddingEnd="@dimen/ongoing_activity_chip_text_end_padding_with_notif_icon"
            android:paddingStart="@dimen/ongoing_activity_chip_icon_text_padding"
            android:textAppearance="@android:style/TextAppearance.Material.Small"
            android:fontFamily="@*android:string/config_headlineFontFamily"
            android:textColor="?android:attr/colorPrimary"
+0 −6
Original line number Diff line number Diff line
@@ -1727,15 +1727,9 @@

    <!-- 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 -->
+1 −11
Original line number Diff line number Diff line
@@ -123,8 +123,6 @@ 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)
@@ -141,17 +139,9 @@ constructor(

            try {
                setIcon(entry, normalIconDescriptor, sbIcon)
                setIcon(entry, normalIconDescriptor, sbChipIcon)
                setIcon(entry, sensitiveIconDescriptor, shelfIcon)
                setIcon(entry, sensitiveIconDescriptor, aodIcon)
                entry.icons =
                    IconPack.buildPack(
                        sbIcon,
                        sbChipIcon,
                        shelfIcon,
                        aodIcon,
                        entry.icons,
                    )
                entry.icons = IconPack.buildPack(sbIcon, shelfIcon, aodIcon, entry.icons)
            } catch (e: InflationException) {
                entry.icons = IconPack.buildEmptyPack(entry.icons)
                throw e
+2 −18
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ 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;

@@ -44,7 +43,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, null, fromSource);
        return new IconPack(false, null, null, null, fromSource);
    }

    /**
@@ -52,24 +51,20 @@ 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, statusBarChipIcon, shelfIcon, aodIcon, source);
        return new IconPack(true, statusBarIcon, 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) {
@@ -83,17 +78,6 @@ 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
+4 −56
Original line number Diff line number Diff line
@@ -25,12 +25,8 @@ import android.app.UidObserver
import android.content.Context
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.annotation.IdRes
import androidx.annotation.VisibleForTesting
import com.android.internal.jank.InteractionJankMonitor
import com.android.settingslib.Utils
import com.android.systemui.CoreStartable
import com.android.systemui.Dumpable
import com.android.systemui.Flags
@@ -41,7 +37,6 @@ import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dump.DumpManager
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.res.R
import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer
import com.android.systemui.statusbar.chips.ui.view.ChipChronometer
import com.android.systemui.statusbar.data.repository.StatusBarModeRepositoryStore
@@ -119,7 +114,6 @@ constructor(
                                Notification.EXTRA_CALL_TYPE,
                                -1
                            ) == CALL_TYPE_ONGOING,
                            entry.icons.statusBarChipIcon,
                            statusBarSwipedAway = callNotificationInfo?.statusBarSwipedAway ?: false
                        )
                    if (newOngoingCallInfo == callNotificationInfo) {
@@ -162,7 +156,8 @@ constructor(
    fun setChipView(chipView: View) {
        tearDownChipView()
        this.chipView = chipView
        val backgroundView: ChipBackgroundContainer? = chipView.getBackgroundView()
        val backgroundView: ChipBackgroundContainer? =
            chipView.findViewById(R.id.ongoing_activity_chip_background)
        backgroundView?.maxHeightFetcher = { statusBarWindowController.statusBarHeight }
        if (hasOngoingCall()) {
            updateChip()
@@ -241,8 +236,6 @@ constructor(
                    timeView.setShouldHideText(true)
                    timeView.stop()
                }

                updateChipIcon(currentCallNotificationInfo, currentChipView)
                updateChipClickListener()
            }

@@ -268,38 +261,6 @@ constructor(
        }
    }

    private fun updateChipIcon(callInfo: CallNotificationInfo, currentChipView: View) {
        val backgroundView = currentChipView.getBackgroundView() ?: return
        backgroundView.removeView(currentChipView.getIconView())

        val iconView = callInfo.iconView ?: return
        with(iconView) {
            id = ICON_ID
            imageTintList = Utils.getColorAttr(context, android.R.attr.colorPrimary)
            // TODO(b/354930838): Update the content description to not include "phone".
            contentDescription =
                context.resources.getString(R.string.ongoing_phone_call_content_description)
        }

        val currentParent = iconView.parent as? ViewGroup
        // If we're reinflating the view, we may need to detach the icon view from the
        // old chip before we reattach it to the new one.
        // See also: NotificationIconContainerViewBinder#bindIcons.
        if (currentParent != null && currentParent != backgroundView) {
            currentParent.removeView(iconView)
            currentParent.removeTransientView(iconView)
        }
        backgroundView.addView(iconView, /* index= */ 0, generateIconLayoutParams())
    }

    private fun generateIconLayoutParams(): FrameLayout.LayoutParams {
        return FrameLayout.LayoutParams(iconSize, iconSize)
    }

    private val iconSize: Int
        get() =
            context.resources.getDimensionPixelSize(R.dimen.ongoing_activity_chip_notif_icon_size)

    private fun updateChipClickListener() {
        if (Flags.statusBarScreenSharingChips()) {
            return
@@ -309,7 +270,8 @@ constructor(
            return
        }
        val currentChipView = chipView
        val backgroundView = currentChipView?.getBackgroundView()
        val backgroundView =
            currentChipView?.findViewById<View>(R.id.ongoing_activity_chip_background)
        val intent = callNotificationInfo?.intent
        if (currentChipView != null && backgroundView != null && intent != null) {
            currentChipView.setOnClickListener {
@@ -362,14 +324,6 @@ constructor(
        return this.findViewById(R.id.ongoing_activity_chip_time)
    }

    private fun View.getBackgroundView(): ChipBackgroundContainer? {
        return this.findViewById(R.id.ongoing_activity_chip_background)
    }

    private fun View.getIconView(): View? {
        return this.findViewById(ICON_ID)
    }

    /**
     * If there's an active ongoing call, then we will force the status bar to always show, even if
     * the user is in immersive mode. However, we also want to give users the ability to swipe away
@@ -399,8 +353,6 @@ constructor(
        val uid: Int,
        /** True if the call is currently ongoing (as opposed to incoming, screening, etc.). */
        val isOngoing: Boolean,
        /** The view that contains the icon to display in the chip. */
        val iconView: StatusBarIconView?,
        /** True if the user has swiped away the status bar while in this phone call. */
        val statusBarSwipedAway: Boolean
    ) {
@@ -485,10 +437,6 @@ constructor(
            }
        }
    }

    companion object {
        @IdRes private val ICON_ID = R.id.ongoing_activity_chip_icon
    }
}

private fun isCallNotification(entry: NotificationEntry): Boolean {
Loading