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

Commit 06693f0a authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge "Notify the NotificationViewWrappers whether they are shown" into main

parents 59a677b5 926e1002
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ public class NotificationContentView extends FrameLayout implements Notification
    private NotificationViewWrapper mContractedWrapper;
    private NotificationViewWrapper mExpandedWrapper;
    private NotificationViewWrapper mHeadsUpWrapper;
    @Nullable private NotificationViewWrapper mShownWrapper = null;
    private final HybridGroupManager mHybridGroupManager;
    private int mClipTopAmount;
    private int mContentHeight;
@@ -417,6 +418,8 @@ public class NotificationContentView extends FrameLayout implements Notification
        mContractedChild = child;
        mContractedWrapper = NotificationViewWrapper.wrap(getContext(), child,
                mContainingNotification);
        // The contracted wrapper has changed. If this is the shown wrapper, we need to update it.
        updateShownWrapper(mVisibleType);
    }

    private NotificationViewWrapper getWrapperForView(View child) {
@@ -480,6 +483,8 @@ public class NotificationContentView extends FrameLayout implements Notification
        if (mContainingNotification != null) {
            applySystemActions(mExpandedChild, mContainingNotification.getEntry());
        }
        // The expanded wrapper has changed. If this is the shown wrapper, we need to update it.
        updateShownWrapper(mVisibleType);
    }

    /**
@@ -530,6 +535,8 @@ public class NotificationContentView extends FrameLayout implements Notification
        if (mContainingNotification != null) {
            applySystemActions(mHeadsUpChild, mContainingNotification.getEntry());
        }
        // The heads up wrapper has changed. If this is the shown wrapper, we need to update it.
        updateShownWrapper(mVisibleType);
    }

    @Override
@@ -886,6 +893,7 @@ public class NotificationContentView extends FrameLayout implements Notification
        forceUpdateVisibility(VISIBLE_TYPE_EXPANDED, mExpandedChild, mExpandedWrapper);
        forceUpdateVisibility(VISIBLE_TYPE_HEADSUP, mHeadsUpChild, mHeadsUpWrapper);
        forceUpdateVisibility(VISIBLE_TYPE_SINGLELINE, mSingleLineView, mSingleLineView);
        updateShownWrapper(mVisibleType);
        fireExpandedVisibleListenerIfVisible();
        // forceUpdateVisibilities cancels outstanding animations without updating the
        // mAnimationStartVisibleType. Do so here instead.
@@ -967,6 +975,7 @@ public class NotificationContentView extends FrameLayout implements Notification
                mHeadsUpChild, mHeadsUpWrapper);
        updateViewVisibility(visibleType, VISIBLE_TYPE_SINGLELINE,
                mSingleLineView, mSingleLineView);
        updateShownWrapper(visibleType);
        fireExpandedVisibleListenerIfVisible();
        // updateViewVisibilities cancels outstanding animations without updating the
        // mAnimationStartVisibleType. Do so here instead.
@@ -980,6 +989,28 @@ public class NotificationContentView extends FrameLayout implements Notification
        }
    }

    /**
     * Called when the currently shown wrapper is potentially affected by a change to the
     * {mVisibleType} or the user-visibility of this view.
     *
     * @see View#isShown()
     */
    private void updateShownWrapper(int visibleType) {
        final NotificationViewWrapper shownWrapper = isShown() ? getVisibleWrapper(visibleType)
                : null;

        if (mShownWrapper != shownWrapper) {
            NotificationViewWrapper hiddenWrapper = mShownWrapper;
            mShownWrapper = shownWrapper;
            if (hiddenWrapper != null) {
                hiddenWrapper.onContentShown(false);
            }
            if (shownWrapper != null) {
                shownWrapper.onContentShown(true);
            }
        }
    }

    private void animateToVisibleType(int visibleType) {
        final TransformableView shownView = getTransformableViewForVisibleType(visibleType);
        final TransformableView hiddenView = getTransformableViewForVisibleType(mVisibleType);
@@ -990,6 +1021,7 @@ public class NotificationContentView extends FrameLayout implements Notification
        mAnimationStartVisibleType = mVisibleType;
        shownView.transformFrom(hiddenView);
        getViewForVisibleType(visibleType).setVisibility(View.VISIBLE);
        updateShownWrapper(visibleType);
        hiddenView.transformTo(shownView, new Runnable() {
            @Override
            public void run() {
@@ -1837,6 +1869,7 @@ public class NotificationContentView extends FrameLayout implements Notification
    @Override
    public void onVisibilityAggregated(boolean isVisible) {
        super.onVisibilityAggregated(isVisible);
        updateShownWrapper(mVisibleType);
        if (isVisible) {
            fireExpandedVisibleListenerIfVisible();
        }
@@ -2216,6 +2249,21 @@ public class NotificationContentView extends FrameLayout implements Notification
        @Nullable RemoteInputViewController mController;
    }

    @VisibleForTesting
    protected NotificationViewWrapper getContractedWrapper() {
        return mContractedWrapper;
    }

    @VisibleForTesting
    protected NotificationViewWrapper getExpandedWrapper() {
        return mExpandedWrapper;
    }

    @VisibleForTesting
    protected NotificationViewWrapper getHeadsUpWrapper() {
        return mHeadsUpWrapper;
    }

    @VisibleForTesting
    protected void setContractedWrapper(NotificationViewWrapper contractedWrapper) {
        mContractedWrapper = contractedWrapper;
+3 −5
Original line number Diff line number Diff line
@@ -68,13 +68,11 @@ public class NotificationBigPictureTemplateViewWrapper extends NotificationTempl
    }

    @Override
    public void setVisible(boolean visible) {
        super.setVisible(visible);

    public void onContentShown(boolean shown) {
        super.onContentShown(shown);
        BigPictureIconManager imageManager = mRow.getBigPictureIconManager();
        if (imageManager != null) {
            // TODO(b/283082473) call it a bit earlier for true, as soon as the row starts to expand
            imageManager.onViewShown(visible);
            imageManager.onViewShown(shown);
        }
    }

+11 −0
Original line number Diff line number Diff line
@@ -310,6 +310,17 @@ public abstract class NotificationViewWrapper implements TransformableView {
        mView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
    }

    /**
     * Called when the user-visibility of this content wrapper has changed.
     *
     * @param shown true if the content of this wrapper is user-visible, meaning that the wrapped
     *              view and all of its ancestors are visible.
     *
     * @see View#isShown()
     */
    public void onContentShown(boolean shown) {
    }

    /**
     * Called to indicate this view is removed
     */
+333 −124

File changed.

Preview size limit exceeded, changes collapsed.