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

Commit f3ed0114 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Revert^2 "Basic setup of BundleHeaderView (Compose) in NCC"" into main

parents 076b333d 920ef3d3
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.view.NotificationHeaderView;
import android.view.View;
import android.widget.RemoteViews;

import androidx.compose.ui.platform.ComposeView;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

@@ -35,7 +36,9 @@ import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation;
import com.android.systemui.statusbar.notification.row.ui.viewmodel.BundleHeaderViewModelImpl;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationHeaderViewWrapper;
import com.android.systemui.statusbar.notification.shared.NotificationBundleUi;

import org.junit.Assert;
import org.junit.Before;
@@ -273,6 +276,22 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
        Assert.assertEquals(1f, header.getTopRoundness(), 0.001f);
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    public void initBundleHeader_composeview_is_initialized_once() {
        View currentView = mChildrenContainer.getChildAt(mChildrenContainer.getChildCount() - 1);
        Assert.assertFalse(currentView instanceof ComposeView);

        BundleHeaderViewModelImpl viewModel = new BundleHeaderViewModelImpl();
        mChildrenContainer.initBundleHeader(viewModel);
        currentView = mChildrenContainer.getChildAt(mChildrenContainer.getChildCount() - 1);
        Assert.assertTrue(currentView instanceof ComposeView);

        mChildrenContainer.initBundleHeader(viewModel);
        View finalView = mChildrenContainer.getChildAt(mChildrenContainer.getChildCount() - 1);
        Assert.assertEquals(currentView, finalView);
    }

    private NotificationHeaderView createHeaderView(boolean lowPriority) {
        Notification notification = mNotificationTestHelper.createNotification();
        final Notification.Builder builder = Notification.Builder.recoverBuilder(getContext(),
+18 −1
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ import com.android.systemui.statusbar.notification.people.PeopleNotificationIden
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUiForceExpanded;
import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation;
import com.android.systemui.statusbar.notification.row.shared.LockscreenOtpRedaction;
import com.android.systemui.statusbar.notification.row.ui.viewmodel.BundleHeaderViewModelImpl;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationCompactMessagingTemplateViewWrapper;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper;
import com.android.systemui.statusbar.notification.shared.NotificationAddXOnHoverToDismiss;
@@ -430,7 +431,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                onExpansionChanged(true /* userAction */, wasExpanded);
            }
        } else if (mEnableNonGroupedNotificationExpand) {
            if (v.isAccessibilityFocused()) {
            if (v != null && v.isAccessibilityFocused()) {
                mPrivateLayout.setFocusOnVisibilityChange();
            }
            boolean nowExpanded;
@@ -1820,6 +1821,22 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        );
    }

    /**
     * Init the bundle header view. The ComposeView is initialized within with the passed viewModel.
     * This can only be init once and not in conjunction with any other header view.
     */
    public void initBundleHeader(@NonNull BundleHeaderViewModelImpl bundleHeaderViewModel) {
        if (NotificationBundleUi.isUnexpectedlyInLegacyMode()) return;
        NotificationChildrenContainer childrenContainer = getChildrenContainerNonNull();
        bundleHeaderViewModel.setOnExpandClickListener(mExpandClickListener);

        childrenContainer.initBundleHeader(bundleHeaderViewModel);

        if (TransparentHeaderFix.isEnabled()) {
            updateBackgroundForGroupState();
        }
    }

    public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
        boolean wasAboveShelf = isAboveShelf();
        boolean changed = headsUpAnimatingAway != mHeadsupDisappearRunning;
+53 −0
Original line number Diff line number Diff line
@@ -39,9 +39,11 @@ import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.compose.ui.platform.ComposeView;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.NotificationExpandButton;
import com.android.systemui.notifications.ui.composable.row.BundleHeaderKt;
import com.android.systemui.res.R;
import com.android.systemui.scene.shared.flag.SceneContainerFlag;
import com.android.systemui.statusbar.CrossFadeHelper;
@@ -58,6 +60,7 @@ import com.android.systemui.statusbar.notification.row.HybridGroupManager;
import com.android.systemui.statusbar.notification.row.HybridNotificationView;
import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation;
import com.android.systemui.statusbar.notification.row.shared.AsyncHybridViewInflation;
import com.android.systemui.statusbar.notification.row.ui.viewmodel.BundleHeaderViewModelImpl;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationHeaderViewWrapper;
import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper;
import com.android.systemui.statusbar.notification.shared.NotificationBundleUi;
@@ -119,6 +122,13 @@ public class NotificationChildrenContainer extends ViewGroup
     */
    private boolean mEnableShadowOnChildNotifications;

    /**
     * This view is only set when this NCC is a bundle. If this view is set, all other header
     * view variants have to be null.
     */
    private ComposeView mBundleHeaderView;
    private BundleHeaderViewModelImpl mBundleHeaderViewModel;

    private NotificationHeaderView mGroupHeader;
    private NotificationHeaderViewWrapper mGroupHeaderWrapper;
    private NotificationHeaderView mMinimizedGroupHeader;
@@ -189,6 +199,9 @@ public class NotificationChildrenContainer extends ViewGroup
                    R.dimen.notification_children_container_top_padding);
            mHeaderHeight = mCollapsedHeaderMargin + mAdditionalExpandedHeaderMargin;
        }
        if (mBundleHeaderView != null) {
            initBundleDimens();
        }
        mCollapsedBottomPadding = res.getDimensionPixelOffset(
                R.dimen.notification_children_collapsed_bottom_padding);
        mEnableShadowOnChildNotifications =
@@ -244,6 +257,10 @@ public class NotificationChildrenContainer extends ViewGroup
                    mMinimizedGroupHeader.getMeasuredWidth(),
                    mMinimizedGroupHeader.getMeasuredHeight());
        }
        if (mBundleHeaderView != null) {
            mBundleHeaderView.layout(0, 0, mBundleHeaderView.getMeasuredWidth(),
                    mBundleHeaderView.getMeasuredHeight());
        }
    }

    @Override
@@ -295,6 +312,9 @@ public class NotificationChildrenContainer extends ViewGroup
        if (mMinimizedGroupHeader != null) {
            mMinimizedGroupHeader.measure(widthMeasureSpec, headerHeightSpec);
        }
        if (mBundleHeaderView != null) {
            mBundleHeaderView.measure(widthMeasureSpec, headerHeightSpec);
        }

        setMeasuredDimension(width, height);
        Trace.endSection();
@@ -488,6 +508,28 @@ public class NotificationChildrenContainer extends ViewGroup
        mMinimizedGroupHeaderWrapper = null;
    }

    /**
     * Init the bundle header view. The ComposeView is initialized within with the passed viewModel.
     * This can only be init once and not in conjunction with any other header view.
     */
    public void initBundleHeader(@NonNull BundleHeaderViewModelImpl viewModel) {
        if (NotificationBundleUi.isUnexpectedlyInLegacyMode()) return;
        if (mBundleHeaderView != null) return;
        initBundleDimens();

        mBundleHeaderViewModel = viewModel;
        mBundleHeaderView = BundleHeaderKt.createComposeView(mBundleHeaderViewModel, getContext());
        addView(mBundleHeaderView);
        invalidate();
    }

    private void initBundleDimens() {
        NotificationBundleUi.unsafeAssertInNewMode();
        mCollapsedHeaderMargin = mHeaderHeight;
        mAdditionalExpandedHeaderMargin = 0;
        mCollapsedBottomPadding = 0;
    }

    /**
     * Set the group header view
     * @param headerView view to set
@@ -1311,6 +1353,17 @@ public class NotificationChildrenContainer extends ViewGroup
                mGroupHeader.setHeaderBackgroundDrawable(null);
            }
        }
        if (mBundleHeaderView != null) {
            if (expanded) {
                ColorDrawable cd = new ColorDrawable();
                cd.setColor(mContainingNotification.calculateBgColor());
                // TODO(b/389839492): The backgroundDrawable needs an outline like in the original:
                //  setOutlineProvider(mProvider);
                mBundleHeaderViewModel.setBackgroundDrawable(cd);
            } else {
                mBundleHeaderViewModel.setBackgroundDrawable(null);
            }
        }
    }

    public int getMaxContentHeight() {