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

Commit c60c76ca authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Minimize exposure of NotificationHeaderView; prefer NotificationViewWrapper."

parents 311a1510 8be7d6e3
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.graphics.Outline;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RemoteViews;

import com.android.internal.R;
@@ -344,14 +343,6 @@ public class NotificationHeaderView extends ViewGroup {
        }
    }

    public View getWorkProfileIcon() {
        return mProfileBadge;
    }

    public CachingIconView getIcon() {
        return mIcon;
    }

    /**
     * Sets the margin end for the text portion of the header, excluding right-aligned elements
     * @param headerTextMarginEnd margin size
@@ -490,10 +481,6 @@ public class NotificationHeaderView extends ViewGroup {
        return this;
    }

    public ImageView getExpandButton() {
        return mExpandButton;
    }

    @Override
    public boolean hasOverlappingRendering() {
        return false;
+6 −7
Original line number Diff line number Diff line
@@ -68,10 +68,8 @@ public class NotificationHeaderUtil {
        @Override
        public void apply(View parent, View view, boolean apply, boolean reset) {
            NotificationHeaderView header = (NotificationHeaderView) view;
            ImageView icon = (ImageView) view.findViewById(
                    com.android.internal.R.id.icon);
            ImageView expand = (ImageView) view.findViewById(
                    com.android.internal.R.id.expand_button);
            ImageView icon = view.findViewById(com.android.internal.R.id.icon);
            ImageView expand = view.findViewById(com.android.internal.R.id.expand_button);
            applyToChild(icon, apply, header.getOriginalIconColor());
            applyToChild(expand, apply, header.getOriginalNotificationColor());
        }
@@ -178,7 +176,7 @@ public class NotificationHeaderUtil {

    private void sanitizeHeaderViews(ExpandableNotificationRow row) {
        if (row.isSummaryWithChildren()) {
            sanitizeHeader(row.getNotificationHeader());
            sanitizeHeader(row.getNotificationViewWrapper().getNotificationHeader());
            return;
        }
        final NotificationContentView layout = row.getPrivateLayout();
@@ -275,7 +273,8 @@ public class NotificationHeaderUtil {
        }

        public void init() {
            mParentView = mParentRow.getNotificationHeader().findViewById(mId);
            mParentView = mParentRow.getNotificationViewWrapper().getNotificationHeader()
                    .findViewById(mId);
            mParentData = mExtractor == null ? null : mExtractor.extractData(mParentRow);
            mApply = !mComparator.isEmpty(mParentView);
        }
@@ -305,7 +304,7 @@ public class NotificationHeaderUtil {
        public void apply(ExpandableNotificationRow row, boolean reset) {
            boolean apply = mApply && !reset;
            if (row.isSummaryWithChildren()) {
                applyToView(apply, reset, row.getNotificationHeader());
                applyToView(apply, reset, row.getNotificationViewWrapper().getNotificationHeader());
                return;
            }
            applyToView(apply, reset, row.getPrivateLayout().getContractedChild());
+4 −12
Original line number Diff line number Diff line
@@ -106,12 +106,8 @@ public class ViewTransformationHelper implements TransformableView,
            mViewTransformationAnimation.cancel();
        }
        mViewTransformationAnimation = ValueAnimator.ofFloat(0.0f, 1.0f);
        mViewTransformationAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                transformTo(notification, animation.getAnimatedFraction());
            }
        });
        mViewTransformationAnimation.addUpdateListener(
                animation -> transformTo(notification, animation.getAnimatedFraction()));
        mViewTransformationAnimation.setInterpolator(Interpolators.LINEAR);
        mViewTransformationAnimation.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
        mViewTransformationAnimation.addListener(new AnimatorListenerAdapter() {
@@ -167,12 +163,8 @@ public class ViewTransformationHelper implements TransformableView,
            mViewTransformationAnimation.cancel();
        }
        mViewTransformationAnimation = ValueAnimator.ofFloat(0.0f, 1.0f);
        mViewTransformationAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                transformFrom(notification, animation.getAnimatedFraction());
            }
        });
        mViewTransformationAnimation.addUpdateListener(
                animation -> transformFrom(notification, animation.getAnimatedFraction()));
        mViewTransformationAnimation.addListener(new AnimatorListenerAdapter() {
            public boolean mCancelled;

+50 −50
Original line number Diff line number Diff line
@@ -409,8 +409,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            setIconAnimationRunning(running, l);
        }
        if (mIsSummaryWithChildren) {
            setIconAnimationRunningForChild(running, mChildrenContainer.getHeaderView());
            setIconAnimationRunningForChild(running, mChildrenContainer.getLowPriorityHeaderView());
            NotificationViewWrapper viewWrapper = mChildrenContainer.getNotificationViewWrapper();
            if (viewWrapper != null) {
                setIconAnimationRunningForChild(running, viewWrapper.getIcon());
            }
            NotificationViewWrapper lowPriWrapper = mChildrenContainer.getLowPriorityViewWrapper();
            if (lowPriWrapper != null) {
                setIconAnimationRunningForChild(running, lowPriWrapper.getIcon());
            }
            List<ExpandableNotificationRow> notificationChildren =
                    mChildrenContainer.getAttachedChildren();
            for (int i = 0; i < notificationChildren.size(); i++) {
@@ -434,10 +440,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

    private void setIconAnimationRunningForChild(boolean running, View child) {
        if (child != null) {
            ImageView icon = (ImageView) child.findViewById(com.android.internal.R.id.icon);
            ImageView icon = child.findViewById(com.android.internal.R.id.icon);
            setIconRunning(icon, running);
            ImageView rightIcon = (ImageView) child.findViewById(
                    com.android.internal.R.id.right_icon);
            ImageView rightIcon = child.findViewById(com.android.internal.R.id.right_icon);
            setIconRunning(rightIcon, running);
        }
    }
@@ -593,7 +598,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

    public int getOriginalIconColor() {
        if (mIsSummaryWithChildren && !shouldShowPublic()) {
            return mChildrenContainer.getVisibleHeader().getOriginalIconColor();
            return mChildrenContainer.getVisibleWrapper().getOriginalIconColor();
        }
        int color = getShowingLayout().getOriginalIconColor();
        if (color != Notification.COLOR_INVALID) {
@@ -1039,22 +1044,25 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
    }

    public NotificationHeaderView getNotificationHeader() {
    /**
     * @return the main notification view wrapper.
     */
    public NotificationViewWrapper getNotificationViewWrapper() {
        if (mIsSummaryWithChildren) {
            return mChildrenContainer.getHeaderView();
            return mChildrenContainer.getNotificationViewWrapper();
        }
        return mPrivateLayout.getNotificationHeader();
        return mPrivateLayout.getNotificationViewWrapper();
    }

    /**
     * @return the currently visible notification header. This can be different from
     * {@link #getNotificationHeader()} in case it is a low-priority group.
     * @return the currently visible notification view wrapper. This can be different from
     * {@link #getNotificationViewWrapper()} in case it is a low-priority group.
     */
    public NotificationHeaderView getVisibleNotificationHeader() {
    public NotificationViewWrapper getVisibleNotificationViewWrapper() {
        if (mIsSummaryWithChildren && !shouldShowPublic()) {
            return mChildrenContainer.getVisibleHeader();
            return mChildrenContainer.getVisibleWrapper();
        }
        return getShowingLayout().getVisibleNotificationHeader();
        return getShowingLayout().getVisibleWrapper();
    }

    public void setLongPressListener(LongPressListener longPressListener) {
@@ -1411,7 +1419,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    @Override
    public View getShelfTransformationTarget() {
        if (mIsSummaryWithChildren && !shouldShowPublic()) {
            return mChildrenContainer.getVisibleHeader().getIcon();
            return mChildrenContainer.getVisibleWrapper().getShelfTransformationTarget();
        }
        return getShowingLayout().getShelfTransformationTarget();
    }
@@ -1682,29 +1690,23 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
        mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);
        mPublicLayout = findViewById(R.id.expandedPublic);
        mPrivateLayout = findViewById(R.id.expanded);
        mLayouts = new NotificationContentView[] {mPrivateLayout, mPublicLayout};

        for (NotificationContentView l : mLayouts) {
            l.setExpandClickListener(mExpandClickListener);
            l.setContainingNotification(this);
        }
        mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub);
        mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() {
            @Override
            public void onInflate(ViewStub stub, View inflated) {
        mGutsStub = findViewById(R.id.notification_guts_stub);
        mGutsStub.setOnInflateListener((stub, inflated) -> {
            mGuts = (NotificationGuts) inflated;
            mGuts.setClipTopAmount(getClipTopAmount());
            mGuts.setActualHeight(getActualHeight());
            mGutsStub = null;
            }
        });
        mChildrenContainerStub = (ViewStub) findViewById(R.id.child_container_stub);
        mChildrenContainerStub.setOnInflateListener(new ViewStub.OnInflateListener() {

            @Override
            public void onInflate(ViewStub stub, View inflated) {
        mChildrenContainerStub = findViewById(R.id.child_container_stub);
        mChildrenContainerStub.setOnInflateListener((stub, inflated) -> {
            mChildrenContainer = (NotificationChildrenContainer) inflated;
            mChildrenContainer.setIsLowPriority(mIsLowPriority);
            mChildrenContainer.setContainingNotification(ExpandableNotificationRow.this);
@@ -1713,7 +1715,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            if (mShouldTranslateContents) {
                mTranslateableViews.add(mChildrenContainer);
            }
            }
        });

        if (mShouldTranslateContents) {
@@ -2292,8 +2293,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private void onAttachedChildrenCountChanged() {
        mIsSummaryWithChildren = mChildrenContainer != null
                && mChildrenContainer.getNotificationChildCount() > 0;
        if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() == null) {
            mChildrenContainer.recreateNotificationHeader(mExpandClickListener, isConversation());
        if (mIsSummaryWithChildren) {
            NotificationViewWrapper wrapper = mChildrenContainer.getNotificationViewWrapper();
            if (wrapper == null || wrapper.getNotificationHeader() == null) {
                mChildrenContainer.recreateNotificationHeader(mExpandClickListener,
                        isConversation());
            }
        }
        getShowingLayout().updateBackgroundColor(false /* animate */);
        mPrivateLayout.updateExpandButtons(isExpandable());
@@ -2403,9 +2408,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
     * the top.
     */
    private void updateContentShiftHeight() {
        NotificationHeaderView notificationHeader = getVisibleNotificationHeader();
        if (notificationHeader != null) {
            CachingIconView icon = notificationHeader.getIcon();
        NotificationViewWrapper wrapper = getVisibleNotificationViewWrapper();
        CachingIconView icon = wrapper == null ? null : wrapper.getIcon();
        if (icon != null) {
            mIconTransformContentShift = getRelativeTopPadding(icon) + icon.getHeight();
        } else {
            mIconTransformContentShift = mContentShift;
@@ -2493,12 +2498,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                    .alpha(0f)
                    .setStartDelay(delay)
                    .setDuration(duration)
                    .withEndAction(new Runnable() {
                        @Override
                        public void run() {
                            hiddenView.setVisibility(View.INVISIBLE);
                        }
                    });
                    .withEndAction(() -> hiddenView.setVisibility(View.INVISIBLE));
        }
        for (View showView : shownChildren) {
            showView.setVisibility(View.VISIBLE);
@@ -2856,7 +2856,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
        float x = event.getX();
        float y = event.getY();
        NotificationHeaderView header = getVisibleNotificationHeader();
        NotificationHeaderView header = getVisibleNotificationViewWrapper().getNotificationHeader();
        if (header != null && header.isInTouchRect(x - getTranslation(), y)) {
            return true;
        }
+15 −14
Original line number Diff line number Diff line
@@ -1018,6 +1018,10 @@ public class NotificationContentView extends FrameLayout {
                mSingleLineView };
    }

    public NotificationViewWrapper getVisibleWrapper() {
        return getVisibleWrapper(mVisibleType);
    }

    public NotificationViewWrapper getVisibleWrapper(int visibleType) {
        switch (visibleType) {
            case VISIBLE_TYPE_EXPANDED:
@@ -1541,18 +1545,20 @@ public class NotificationContentView extends FrameLayout {
        mIsContentExpandable = expandable;
    }

    public NotificationHeaderView getNotificationHeader() {
        NotificationHeaderView header = null;
        if (mContractedChild != null) {
            header = mContractedWrapper.getNotificationHeader();
    /**
     * @return a view wrapper for one of the inflated states of the notification.
     */
    public NotificationViewWrapper getNotificationViewWrapper() {
        if (mContractedChild != null && mContractedWrapper != null) {
            return mContractedWrapper;
        }
        if (header == null && mExpandedChild != null) {
            header = mExpandedWrapper.getNotificationHeader();
        if (mExpandedChild != null && mExpandedWrapper != null) {
            return mExpandedWrapper;
        }
        if (header == null && mHeadsUpChild != null) {
            header = mHeadsUpWrapper.getNotificationHeader();
        if (mHeadsUpChild != null && mHeadsUpWrapper != null) {
            return mHeadsUpWrapper;
        }
        return header;
        return null;
    }

    public void showFeedbackIcon(boolean show) {
@@ -1580,11 +1586,6 @@ public class NotificationContentView extends FrameLayout {
        }
    }

    public NotificationHeaderView getVisibleNotificationHeader() {
        NotificationViewWrapper wrapper = getVisibleWrapper(mVisibleType);
        return wrapper == null ? null : wrapper.getNotificationHeader();
    }

    public void setContainingNotification(ExpandableNotificationRow containingNotification) {
        mContainingNotification = containingNotification;
    }
Loading