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

Commit c41d7a7d authored by Todd Frederick's avatar Todd Frederick Committed by Android (Google) Code Review
Browse files

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

parents d4a7e9d7 d09c47c1
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ 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;

@@ -36,9 +35,7 @@ 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;
@@ -276,22 +273,6 @@ 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(),
+1 −18
Original line number Diff line number Diff line
@@ -120,7 +120,6 @@ 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;
@@ -427,7 +426,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                onExpansionChanged(true /* userAction */, wasExpanded);
            }
        } else if (mEnableNonGroupedNotificationExpand) {
            if (v != null && v.isAccessibilityFocused()) {
            if (v.isAccessibilityFocused()) {
                mPrivateLayout.setFocusOnVisibilityChange();
            }
            boolean nowExpanded;
@@ -1817,22 +1816,6 @@ 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;
+0 −53
Original line number Diff line number Diff line
@@ -39,11 +39,9 @@ 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;
@@ -60,7 +58,6 @@ 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;
@@ -122,13 +119,6 @@ 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;
@@ -199,9 +189,6 @@ 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 =
@@ -257,10 +244,6 @@ public class NotificationChildrenContainer extends ViewGroup
                    mMinimizedGroupHeader.getMeasuredWidth(),
                    mMinimizedGroupHeader.getMeasuredHeight());
        }
        if (mBundleHeaderView != null) {
            mBundleHeaderView.layout(0, 0, mBundleHeaderView.getMeasuredWidth(),
                    mBundleHeaderView.getMeasuredHeight());
        }
    }

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

        setMeasuredDimension(width, height);
        Trace.endSection();
@@ -508,28 +488,6 @@ 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.assertInNewMode();
        mCollapsedHeaderMargin = mHeaderHeight;
        mAdditionalExpandedHeaderMargin = 0;
        mCollapsedBottomPadding = 0;
    }

    /**
     * Set the group header view
     * @param headerView view to set
@@ -1353,17 +1311,6 @@ 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() {