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

Commit bcb5f2dc authored by Alexander Roederer's avatar Alexander Roederer Committed by Automerger Merge Worker
Browse files

Merge changes from topic "b215583339-AnimBigPic" into tm-qpr-dev am: 70140880 am: 1c76f47c

parents f00cd59a 1c76f47c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -102,6 +102,10 @@ object Flags {
    val FILTER_UNSEEN_NOTIFS_ON_KEYGUARD =
        unreleasedFlag(254647461, "filter_unseen_notifs_on_keyguard", teamfood = true)

    // TODO(b/263414400): Tracking Bug
    @JvmField
    val NOTIFICATION_ANIMATE_BIG_PICTURE = unreleasedFlag(120, "notification_animate_big_picture")

    // 200 - keyguard/lockscreen
    // ** Flag retired **
    // public static final BooleanFlag KEYGUARD_LAYOUT =
+60 −13
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ import com.android.internal.widget.CallLayout;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
@@ -177,6 +179,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private PeopleNotificationIdentifier mPeopleNotificationIdentifier;
    private Optional<BubblesManager> mBubblesManagerOptional;
    private MetricsLogger mMetricsLogger;
    private FeatureFlags mFeatureFlags;
    private int mIconTransformContentShift;
    private int mMaxHeadsUpHeightBeforeN;
    private int mMaxHeadsUpHeightBeforeP;
@@ -277,7 +280,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private boolean mChildIsExpanding;

    private boolean mJustClicked;
    private boolean mIconAnimationRunning;
    private boolean mAnimationRunning;
    private boolean mShowNoBackground;
    private ExpandableNotificationRow mNotificationParent;
    private OnExpandClickListener mOnExpandClickListener;
@@ -451,10 +454,26 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        return mPublicLayout;
    }

    public void setIconAnimationRunning(boolean running) {
    /**
     * Sets animations running in the layouts of this row, including public, private, and children.
     * @param running whether the animations should be started running or stopped.
     */
    public void setAnimationRunning(boolean running) {
        // Sets animations running in the private/public layouts.
        if (mFeatureFlags.isEnabled(Flags.NOTIFICATION_ANIMATE_BIG_PICTURE)) {
            for (NotificationContentView l : mLayouts) {
                if (l != null) {
                    l.setContentAnimationRunning(running);
                    setIconAnimationRunning(running, l);
                }
            }
        } else {
            for (NotificationContentView l : mLayouts) {
                setIconAnimationRunning(running, l);
            }
        }
        // For groups summaries with children, we want to set the children containers
        // animating as well.
        if (mIsSummaryWithChildren) {
            NotificationViewWrapper viewWrapper = mChildrenContainer.getNotificationViewWrapper();
            if (viewWrapper != null) {
@@ -468,12 +487,18 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                    mChildrenContainer.getAttachedChildren();
            for (int i = 0; i < notificationChildren.size(); i++) {
                ExpandableNotificationRow child = notificationChildren.get(i);
                child.setIconAnimationRunning(running);
                child.setAnimationRunning(running);
            }
        }
        mIconAnimationRunning = running;
        mAnimationRunning = running;
    }

    /**
     * Starts or stops animations of the icons in all potential content views (regardless of
     * whether they're contracted, expanded, etc).
     *
     * @param running whether to start or stop the icon's animation.
     */
    private void setIconAnimationRunning(boolean running, NotificationContentView layout) {
        if (layout != null) {
            View contractedChild = layout.getContractedChild();
@@ -485,16 +510,29 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
    }

    /**
     * Starts or stops animations of the icon in the provided view's icon and right icon.
     *
     * @param running whether to start or stop the icon's animation.
     * @param child   the view with the icon to start or stop.
     */
    private void setIconAnimationRunningForChild(boolean running, View child) {
        if (child != null) {
            ImageView icon = child.findViewById(com.android.internal.R.id.icon);
            setIconRunning(icon, running);
            setImageViewAnimationRunning(icon, running);
            ImageView rightIcon = child.findViewById(com.android.internal.R.id.right_icon);
            setIconRunning(rightIcon, running);
            setImageViewAnimationRunning(rightIcon, running);
        }
    }

    private void setIconRunning(ImageView imageView, boolean running) {
    /**
     * Starts or stops the animation of a provided image view if it's an AnimationDrawable or an
     * AnimatedVectorDrawable.
     *
     * @param imageView the image view on which to start/stop animation.
     * @param running   whether to start or stop the view's animation.
     */
    private void setImageViewAnimationRunning(ImageView imageView, boolean running) {
        if (imageView != null) {
            Drawable drawable = imageView.getDrawable();
            if (drawable instanceof AnimationDrawable) {
@@ -561,8 +599,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            mChildrenContainer.recreateNotificationHeader(mExpandClickListener, isConversation());
            mChildrenContainer.onNotificationUpdated();
        }
        if (mIconAnimationRunning) {
            setIconAnimationRunning(true);
        if (mAnimationRunning) {
            setAnimationRunning(true);
        }
        if (mLastChronometerRunning) {
            setChronometerRunning(true);
@@ -1038,7 +1076,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            notifyHeightChanged(false /* needsAnimation */);
        }
        if (pinned) {
            setIconAnimationRunning(true);
            setAnimationRunning(true);
            mExpandedWhenPinned = false;
        } else if (mExpandedWhenPinned) {
            setUserExpanded(true);
@@ -1627,6 +1665,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        );
    }

    /**
     * Constructs an ExpandableNotificationRow.
     * @param context context passed to image resolver
     * @param attrs attributes used to initialize parent view
     */
    public ExpandableNotificationRow(Context context, AttributeSet attrs) {
        super(context, attrs);
        mImageResolver = new NotificationInlineImageResolver(context,
@@ -1662,7 +1705,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            NotificationGutsManager gutsManager,
            MetricsLogger metricsLogger,
            SmartReplyConstants smartReplyConstants,
            SmartReplyController smartReplyController) {
            SmartReplyController smartReplyController,
            FeatureFlags featureFlags) {
        mEntry = entry;
        mAppName = appName;
        if (mMenuRow == null) {
@@ -1697,6 +1741,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mBubblesManagerOptional = bubblesManagerOptional;
        mNotificationGutsManager = gutsManager;
        mMetricsLogger = metricsLogger;
        mFeatureFlags = featureFlags;
    }

    private void initDimens() {
@@ -3588,11 +3633,13 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    @VisibleForTesting
    protected void setPrivateLayout(NotificationContentView privateLayout) {
        mPrivateLayout = privateLayout;
        mLayouts = new NotificationContentView[]{mPrivateLayout, mPublicLayout};
    }

    @VisibleForTesting
    protected void setPublicLayout(NotificationContentView publicLayout) {
        mPublicLayout = publicLayout;
        mLayouts = new NotificationContentView[]{mPrivateLayout, mPublicLayout};
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -219,7 +219,8 @@ public class ExpandableNotificationRowController implements NotifViewController
                mNotificationGutsManager,
                mMetricsLogger,
                mSmartReplyConstants,
                mSmartReplyController
                mSmartReplyController,
                mFeatureFlags
        );
        mView.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
        if (mAllowLongPress) {
+43 −0
Original line number Diff line number Diff line
@@ -184,6 +184,8 @@ public class NotificationContentView extends FrameLayout implements Notification
    private boolean mRemoteInputVisible;
    private int mUnrestrictedContentHeight;

    private boolean mContentAnimating;

    public NotificationContentView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mHybridGroupManager = new HybridGroupManager(getContext());
@@ -2129,8 +2131,49 @@ public class NotificationContentView extends FrameLayout implements Notification
        return false;
    }

    /**
     * Starts and stops animations in the underlying views.
     * Avoids restarting the animations by checking whether they're already running first.
     * Return value is used for testing.
     *
     * @param running whether to start animations running, or stop them.
     * @return true if the state of animations changed.
     */
    public boolean setContentAnimationRunning(boolean running) {
        boolean stateChangeRequired = (running != mContentAnimating);
        if (stateChangeRequired) {
            // Starts or stops the animations in the potential views.
            if (mContractedWrapper != null) {
                mContractedWrapper.setAnimationsRunning(running);
            }
            if (mExpandedWrapper != null) {
                mExpandedWrapper.setAnimationsRunning(running);
            }
            if (mHeadsUpWrapper != null) {
                mHeadsUpWrapper.setAnimationsRunning(running);
            }
            // Updates the state tracker.
            mContentAnimating = running;
            return true;
        }
        return false;
    }

    private static class RemoteInputViewData {
        @Nullable RemoteInputView mView;
        @Nullable RemoteInputViewController mController;
    }

    @VisibleForTesting
    protected void setContractedWrapper(NotificationViewWrapper contractedWrapper) {
        mContractedWrapper = contractedWrapper;
    }
    @VisibleForTesting
    protected void setExpandedWrapper(NotificationViewWrapper expandedWrapper) {
        mExpandedWrapper = expandedWrapper;
    }
    @VisibleForTesting
    protected void setHeadsUpWrapper(NotificationViewWrapper headsUpWrapper) {
        mHeadsUpWrapper = headsUpWrapper;
    }
}
+32 −0
Original line number Diff line number Diff line
@@ -18,11 +18,15 @@ package com.android.systemui.statusbar.notification.row.wrapper;

import android.app.Notification;
import android.content.Context;
import android.graphics.drawable.AnimatedImageDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import android.view.View;

import com.android.internal.R;
import com.android.internal.widget.BigPictureNotificationImageView;
import com.android.systemui.statusbar.notification.ImageTransformState;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;

@@ -31,6 +35,8 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
 */
public class NotificationBigPictureTemplateViewWrapper extends NotificationTemplateViewWrapper {

    private BigPictureNotificationImageView mImageView;

    protected NotificationBigPictureTemplateViewWrapper(Context ctx, View view,
            ExpandableNotificationRow row) {
        super(ctx, view, row);
@@ -39,9 +45,14 @@ public class NotificationBigPictureTemplateViewWrapper extends NotificationTempl
    @Override
    public void onContentUpdated(ExpandableNotificationRow row) {
        super.onContentUpdated(row);
        resolveViews();
        updateImageTag(row.getEntry().getSbn());
    }

    private void resolveViews() {
        mImageView = mView.findViewById(R.id.big_picture);
    }

    private void updateImageTag(StatusBarNotification sbn) {
        final Bundle extras = sbn.getNotification().extras;
        Icon bigLargeIcon = extras.getParcelable(Notification.EXTRA_LARGE_ICON_BIG, Icon.class);
@@ -54,4 +65,25 @@ public class NotificationBigPictureTemplateViewWrapper extends NotificationTempl
            mRightIcon.setTag(ImageTransformState.ICON_TAG, getLargeIcon(sbn.getNotification()));
        }
    }

    /**
     * Starts or stops the animations in any drawables contained in this BigPicture Notification.
     *
     * @param running Whether the animations should be set to run.
     */
    @Override
    public void setAnimationsRunning(boolean running) {
        if (mImageView == null) {
            return;
        }
        Drawable d = mImageView.getDrawable();
        if (d instanceof AnimatedImageDrawable) {
            AnimatedImageDrawable animatedImageDrawable = (AnimatedImageDrawable) d;
            if (running) {
                animatedImageDrawable.start();
            } else {
                animatedImageDrawable.stop();
            }
        }
    }
}
Loading