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

Commit f7188b88 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge "Convert typecasting to new syntax" into main

parents 17ce26c6 a2901a7b
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -513,15 +513,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private void setImageViewAnimationRunning(ImageView imageView, boolean running) {
        if (imageView != null) {
            Drawable drawable = imageView.getDrawable();
            if (drawable instanceof AnimationDrawable) {
                AnimationDrawable animationDrawable = (AnimationDrawable) drawable;
            if (drawable instanceof AnimationDrawable animationDrawable) {
                if (running) {
                    animationDrawable.start();
                } else {
                    animationDrawable.stop();
                }
            } else if (drawable instanceof AnimatedVectorDrawable) {
                AnimatedVectorDrawable animationDrawable = (AnimatedVectorDrawable) drawable;
            } else if (drawable instanceof AnimatedVectorDrawable animationDrawable) {
                if (running) {
                    animationDrawable.start();
                } else {
@@ -3439,8 +3437,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

    @Override
    protected boolean childNeedsClipping(View child) {
        if (child instanceof NotificationContentView) {
            NotificationContentView contentView = (NotificationContentView) child;
        if (child instanceof NotificationContentView contentView) {
            if (isClippingNeeded()) {
                return true;
            } else if (hasRoundedCorner()
@@ -3522,8 +3519,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

        @Override
        public void applyToView(View view) {
            if (view instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) view;
            if (view instanceof ExpandableNotificationRow row) {
                if (row.isExpandAnimationRunning()) {
                    return;
                }
@@ -3543,8 +3539,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        @Override
        protected void onYTranslationAnimationFinished(View view) {
            super.onYTranslationAnimationFinished(view);
            if (view instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) view;
            if (view instanceof ExpandableNotificationRow row) {
                if (row.isHeadsUpAnimatingAway()) {
                    row.setHeadsUpAnimatingAway(false);
                }
@@ -3553,8 +3548,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

        @Override
        public void animateTo(View child, AnimationProperties properties) {
            if (child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            if (child instanceof ExpandableNotificationRow row) {
                if (row.isExpandAnimationRunning()) {
                    return;
                }
+1 −2
Original line number Diff line number Diff line
@@ -676,8 +676,7 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable, Ro
        mViewState.headsUpIsVisible = false;

        // handling reset for child notifications
        if (this instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) this;
        if (this instanceof ExpandableNotificationRow row) {
            List<ExpandableNotificationRow> children = row.getAttachedChildren();
            if (row.isSummaryWithChildren() && children != null) {
                for (ExpandableNotificationRow childRow : children) {
+1 −2
Original line number Diff line number Diff line
@@ -869,8 +869,7 @@ public class NotificationChildrenContainer extends ViewGroup
        Path clipPath = mChildClipPath;
        if (clipPath != null) {
            final float translation;
            if (child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow notificationRow = (ExpandableNotificationRow) child;
            if (child instanceof ExpandableNotificationRow notificationRow) {
                translation = notificationRow.getTranslation();
            } else {
                translation = child.getTranslationX();
+25 −51
Original line number Diff line number Diff line
@@ -993,8 +993,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);
            if (child.getVisibility() != View.GONE
                    && child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
                    && child instanceof ExpandableNotificationRow row) {
                if ((row.isPinned() || row.isHeadsUpAnimatingAway()) && row.getTranslation() < 0
                        && row.getProvider().shouldShowGutsOnSnapOpen()) {
                    top = Math.min(top, row.getTranslationY());
@@ -1129,10 +1128,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            for (int i = 0; i < n; i++) {
                View view = getChildAt(i);
                if (view.getVisibility() == View.GONE
                        || !(view instanceof ExpandableNotificationRow)) {
                        || !(view instanceof ExpandableNotificationRow row)) {
                    continue;
                }
                ExpandableNotificationRow row = (ExpandableNotificationRow) view;
                currentIndex++;
                boolean beforeSpeedBump;
                if (mHighPriorityBeforeSpeedBump) {
@@ -1769,16 +1767,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    public static boolean isPinnedHeadsUp(View v) {
        if (v instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) v;
        if (v instanceof ExpandableNotificationRow row) {
            return row.isHeadsUp() && row.isPinned();
        }
        return false;
    }

    private boolean isHeadsUp(View v) {
        if (v instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) v;
        if (v instanceof ExpandableNotificationRow row) {
            return row.isHeadsUp();
        }
        return false;
@@ -1820,8 +1816,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable

            if ((bottom - top >= mMinInteractionHeight || !requireMinHeight)
                    && touchY >= top && touchY <= bottom && touchX >= left && touchX <= right) {
                if (slidingChild instanceof ExpandableNotificationRow) {
                    ExpandableNotificationRow row = (ExpandableNotificationRow) slidingChild;
                if (slidingChild instanceof ExpandableNotificationRow row) {
                    NotificationEntry entry = row.getEntry();
                    if (!mIsExpanded && row.isHeadsUp() && row.isPinned()
                            && mTopHeadsUpEntry.getRow() != row
@@ -2364,8 +2359,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            float rowTranslation = child.getTranslationY();
            if (rowTranslation >= translationY) {
                return child;
            } else if (!ignoreChildren && child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            } else if (!ignoreChildren && child instanceof ExpandableNotificationRow row) {
                if (row.isSummaryWithChildren() && row.areChildrenExpanded()) {
                    List<ExpandableNotificationRow> notificationChildren =
                            row.getAttachedChildren();
@@ -2886,8 +2880,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    private void focusNextViewIfFocused(View view) {
        if (view instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) view;
        if (view instanceof ExpandableNotificationRow row) {
            if (row.shouldRefocusOnDismiss()) {
                View nextView = row.getChildAfterViewWhenDismissed();
                if (nextView == null) {
@@ -3035,8 +3028,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    private int getIntrinsicHeight(View view) {
        if (view instanceof ExpandableView) {
            ExpandableView expandableView = (ExpandableView) view;
        if (view instanceof ExpandableView expandableView) {
            return expandableView.getIntrinsicHeight();
        }
        return view.getHeight();
@@ -3126,8 +3118,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        generateAddAnimation(child, false /* fromMoreCard */);
        updateAnimationState(child);
        updateChronometerForChild(child);
        if (child instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) child;
        if (child instanceof ExpandableNotificationRow row) {
            row.setDismissUsingRowTranslationX(mDismissUsingRowTranslationX);

        }
@@ -3196,8 +3187,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    private void updateAnimationState(boolean running, View child) {
        if (child instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) child;
        if (child instanceof ExpandableNotificationRow row) {
            row.setAnimationRunning(running);
        }
    }
@@ -3394,8 +3384,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            // we need to know the view after this one
            float removedTranslation = child.getTranslationY();
            boolean ignoreChildren = true;
            if (child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            if (child instanceof ExpandableNotificationRow row) {
                if (row.isRemoved() && row.wasChildInGroupWhenRemoved()) {
                    removedTranslation = row.getTranslationWhenRemoved();
                    ignoreChildren = false;
@@ -3437,8 +3426,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private void generatePositionChangeEvents() {
        for (ExpandableView child : mChildrenChangingPositions) {
            Integer duration = null;
            if (child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            if (child instanceof ExpandableNotificationRow row) {
                if (row.getEntry().isMarkedForUserTriggeredMovement()) {
                    duration = StackStateAnimator.ANIMATION_DURATION_PRIORITY_CHANGE;
                    row.getEntry().markForUserTriggeredMovement(false);
@@ -4122,8 +4110,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private void clearUserLockedViews() {
        for (int i = 0; i < getChildCount(); i++) {
            ExpandableView child = getChildAtIndex(i);
            if (child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            if (child instanceof ExpandableNotificationRow row) {
                row.setUserLocked(false);
            }
        }
@@ -4137,8 +4124,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        );
        for (int i = 0; i < getChildCount(); i++) {
            ExpandableView child = getChildAtIndex(i);
            if (child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
            if (child instanceof ExpandableNotificationRow row) {
                clearTemporaryViewsInGroup(
                        /* viewGroup = */ row.getChildrenContainer(),
                        /* reason = */ "clearTemporaryViewsInGroup(row.getChildrenContainer())"
@@ -4223,8 +4209,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    void updateChronometerForChild(View child) {
        if (child instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) child;
        if (child instanceof ExpandableNotificationRow row) {
            row.setChronometerRunning(mIsExpanded);
        }
    }
@@ -4263,8 +4248,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    private void updateScrollPositionOnExpandInBottom(ExpandableView view) {
        if (view instanceof ExpandableNotificationRow && !onKeyguard()) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) view;
        if (view instanceof ExpandableNotificationRow row && !onKeyguard()) {
            // TODO: once we're recycling this will need to check the adapter position of the child
            if (row.isUserLocked() && row != getFirstChildNotGone()) {
                if (row.isSummaryWithChildren()) {
@@ -4323,8 +4307,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private void clearHeadsUpDisappearRunning() {
        for (int i = 0; i < getChildCount(); i++) {
            View view = getChildAt(i);
            if (view instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) view;
            if (view instanceof ExpandableNotificationRow row) {
                row.setHeadsUpAnimatingAway(false);
                if (row.isSummaryWithChildren()) {
                    for (ExpandableNotificationRow child : row.getAttachedChildren()) {
@@ -5208,8 +5191,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                    }
                    View swipedView = mSwipeHelper.getSwipedView();
                    pw.println("Swiped view: " + swipedView);
                    if (swipedView instanceof ExpandableView) {
                        ExpandableView expandableView = (ExpandableView) swipedView;
                    if (swipedView instanceof ExpandableView expandableView) {
                        expandableView.dump(pw, args);
                    }
                });
@@ -5292,8 +5274,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        if (view instanceof SectionHeaderView && silentSectionWillBeGone) {
            return true;
        }
        if (view instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) view;
        if (view instanceof ExpandableNotificationRow row) {
            if (isVisible(row) && includeChildInClearAll(row, selection)) {
                return true;
            }
@@ -5319,9 +5300,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            if (shouldHideParent(view, selection)) {
                viewsToHide.add(view);
            }
            if (view instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow parent = (ExpandableNotificationRow) view;

            if (view instanceof ExpandableNotificationRow parent) {
                if (isChildrenVisible(parent)) {
                    for (ExpandableNotificationRow child : parent.getAttachedChildren()) {
                        if (isVisible(child) && includeChildInClearAll(child, selection)) {
@@ -5341,10 +5320,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable

        for (int i = 0; i < childCount; i++) {
            final View view = getChildAt(i);
            if (!(view instanceof ExpandableNotificationRow)) {
            if (!(view instanceof ExpandableNotificationRow parent)) {
                continue;
            }
            ExpandableNotificationRow parent = (ExpandableNotificationRow) view;
            if (includeChildInClearAll(parent, selection)) {
                viewsToRemove.add(parent);
            }
@@ -5983,8 +5961,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        for (int i = 0; i < getChildCount(); i++) {
            View child = getChildAt(i);
            mSwipeHelper.forceResetSwipeState(child);
            if (child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow childRow = (ExpandableNotificationRow) child;
            if (child instanceof ExpandableNotificationRow childRow) {
                List<ExpandableNotificationRow> grandchildren = childRow.getAttachedChildren();
                if (grandchildren != null) {
                    for (ExpandableNotificationRow grandchild : grandchildren) {
@@ -6270,8 +6247,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    static boolean canChildBeDismissed(View v) {
        if (v instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) v;
        if (v instanceof ExpandableNotificationRow row) {
            if (row.areGutsExposed() || !row.getEntry().hasFinishedInitialization()) {
                return false;
            }
@@ -6281,8 +6257,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    static boolean canChildBeCleared(View v) {
        if (v instanceof ExpandableNotificationRow) {
            ExpandableNotificationRow row = (ExpandableNotificationRow) v;
        if (v instanceof ExpandableNotificationRow row) {
            if (row.areGutsExposed() || !row.getEntry().hasFinishedInitialization()) {
                return false;
            }
@@ -6377,8 +6352,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        /* Only ever called as a consequence of an expansion gesture in the shade. */
        @Override
        public void setUserExpandedChild(View v, boolean userExpanded) {
            if (v instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) v;
            if (v instanceof ExpandableNotificationRow row) {
                if (userExpanded && onKeyguard()) {
                    // Due to a race when locking the screen while touching, a notification may be
                    // expanded even after we went back to keyguard. An example of this happens if
+7 −14
Original line number Diff line number Diff line
@@ -405,8 +405,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {
            if (!mAllowLongPress) {
                return;
            }
            if (view instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) view;
            if (view instanceof ExpandableNotificationRow row) {
                mMetricsLogger.write(row.getEntry().getSbn().getLogMaker()
                        .setCategory(MetricsEvent.ACTION_TOUCH_GEAR)
                        .setType(MetricsEvent.TYPE_ACTION)
@@ -426,8 +425,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {

        @Override
        public void onMenuShown(View row) {
            if (row instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow notificationRow = (ExpandableNotificationRow) row;
            if (row instanceof ExpandableNotificationRow notificationRow) {
                mMetricsLogger.write(notificationRow.getEntry().getSbn().getLogMaker()
                        .setCategory(MetricsEvent.ACTION_REVEAL_GEAR)
                        .setType(MetricsEvent.TYPE_ACTION));
@@ -492,10 +490,9 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                 */
                @Override
                public void onChildDismissed(View view) {
                    if (!(view instanceof ActivatableNotificationView)) {
                    if (!(view instanceof ActivatableNotificationView row)) {
                        return;
                    }
                    ActivatableNotificationView row = (ActivatableNotificationView) view;
                    if (!row.isDismissed()) {
                        handleChildViewDismissed(view);
                    }
@@ -519,8 +516,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                    if (mView.getClearAllInProgress()) {
                        return;
                    }
                    if (view instanceof ExpandableNotificationRow) {
                        ExpandableNotificationRow row = (ExpandableNotificationRow) view;
                    if (view instanceof ExpandableNotificationRow row) {
                        if (row.isHeadsUp()) {
                            mHeadsUpManager.addSwipedOutNotification(
                                    row.getEntry().getSbn().getKey());
@@ -551,8 +547,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                            ev.getY(),
                            true /* requireMinHeight */,
                            false /* ignoreDecors */);
                    if (child instanceof ExpandableNotificationRow) {
                        ExpandableNotificationRow row = (ExpandableNotificationRow) child;
                    if (child instanceof ExpandableNotificationRow row) {
                        ExpandableNotificationRow parent = row.getNotificationParent();
                        if (parent != null && parent.areChildrenExpanded()
                                && (parent.areGutsExposed()
@@ -582,8 +577,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                @Override
                public void onChildSnappedBack(View animView, float targetLeft) {
                    mView.onSwipeEnd();
                    if (animView instanceof ExpandableNotificationRow) {
                        ExpandableNotificationRow row = (ExpandableNotificationRow) animView;
                    if (animView instanceof ExpandableNotificationRow row) {
                        if (row.isPinned() && !canChildBeDismissed(row)
                                && row.getEntry().getSbn().getNotification().fullScreenIntent
                                == null) {
@@ -1980,8 +1974,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {

            // Check if we need to clear any snooze leavebehinds
            if (guts != null && !NotificationSwipeHelper.isTouchInView(ev, guts)
                    && guts.getGutsContent() instanceof NotificationSnooze) {
                NotificationSnooze ns = (NotificationSnooze) guts.getGutsContent();
                    && guts.getGutsContent() instanceof NotificationSnooze ns) {
                if ((ns.isExpanded() && isCancelOrUp)
                        || (!horizontalSwipeWantsIt && scrollerWantsIt)) {
                    // If the leavebehind is expanded we clear it on the next up event, otherwise we
Loading