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

Commit cafac050 authored by Steve Elliott's avatar Steve Elliott Committed by Android (Google) Code Review
Browse files

Merge changes I607d96f9,I5e0fca2f,Ife5d4d89 into main

* changes:
  Remove dead code from NIC + SBIV
  Replace NIC#setInNotifIconShelf
  SysUITestModule utilities
parents c76ba155 dc874b43
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.statusbar.notification.stack.AmbientState;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
@@ -151,7 +152,11 @@ public class NotificationShelf extends ActivatableNotificationView {
                R.dimen.notification_corner_animation_distance);
        mEnableNotificationClipping = res.getBoolean(R.bool.notification_enable_clipping);

        if (NotificationIconContainerRefactor.isEnabled()) {
            mShelfIcons.setOverrideIconColor(true);
        } else {
            mShelfIcons.setInNotificationIconShelf(true);
        }
        if (!mShowNotificationShelf) {
            setVisibility(GONE);
        }
+3 −4
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.statusbar.StatusBarIcon;
import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.notification.NotificationIconDozeHelper;
import com.android.systemui.statusbar.notification.NotificationDozeHelper;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.util.drawable.DrawableSize;

@@ -174,7 +174,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
                animation.getAnimatedFraction());
        setColorInternal(newColor);
    };
    private final NotificationIconDozeHelper mDozer;
    private final NotificationDozeHelper mDozer;
    private int mContrastedDrawableColor;
    private int mCachedContrastBackgroundColor = NO_COLOR;
    private float[] mMatrix;
@@ -192,7 +192,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
    public StatusBarIconView(Context context, String slot, StatusBarNotification sbn,
            boolean blocked) {
        super(context);
        mDozer = new NotificationIconDozeHelper(context);
        mDozer = new NotificationDozeHelper();
        mBlocked = blocked;
        mSlot = slot;
        mNumberPain = new Paint();
@@ -712,7 +712,6 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
        setColorInternal(color);
        updateContrastedStaticColor();
        mIconColor = color;
        mDozer.setColor(color);
    }

    private void setColorInternal(int color) {
+2 −31
Original line number Diff line number Diff line
@@ -36,26 +36,6 @@ public class NotificationDozeHelper {
    private static final int DOZE_ANIMATOR_TAG = R.id.doze_intensity_tag;
    private final ColorMatrix mGrayscaleColorMatrix = new ColorMatrix();

    public void fadeGrayscale(final ImageView target, final boolean dark, long delay) {
        startIntensityAnimation(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                updateGrayscale(target, (float) animation.getAnimatedValue());
            }
        }, dark, delay, new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (!dark) {
                    target.setColorFilter(null);
                }
            }
        });
    }

    public void updateGrayscale(ImageView target, boolean dark) {
        updateGrayscale(target, dark ? 1 : 0);
    }

    public void updateGrayscale(ImageView target, float darkAmount) {
        if (darkAmount > 0) {
            updateGrayscaleMatrix(darkAmount);
@@ -66,7 +46,7 @@ public class NotificationDozeHelper {
    }

    // TODO: this should be using StatusBarStateController#getDozeAmount
    public void startIntensityAnimation(ValueAnimator.AnimatorUpdateListener updateListener,
    private void startIntensityAnimation(ValueAnimator.AnimatorUpdateListener updateListener,
            boolean dark, long delay, Animator.AnimatorListener listener) {
        float startIntensity = dark ? 0f : 1f;
        float endIntensity = dark ? 1f : 0f;
@@ -81,11 +61,6 @@ public class NotificationDozeHelper {
        animator.start();
    }

    public void setDozing(Consumer<Float> listener, boolean dozing,
            boolean animate, long delay, View view) {
        setDozing(listener, dozing, animate, delay, view, /* endRunnable= */ null);
    }

    public void setDozing(Consumer<Float> listener, boolean dozing,
            boolean animate, long delay, View view, @Nullable Runnable endRunnable) {
        if (animate) {
@@ -118,11 +93,7 @@ public class NotificationDozeHelper {
        }
    }

    public void updateGrayscaleMatrix(float intensity) {
    private void updateGrayscaleMatrix(float intensity) {
        mGrayscaleColorMatrix.setSaturation(1 - intensity);
    }

    public ColorMatrix getGrayscaleColorMatrix() {
        return mGrayscaleColorMatrix;
    }
}
+0 −105
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.statusbar.notification;

import android.annotation.Nullable;
import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

import com.android.systemui.res.R;

public class NotificationIconDozeHelper extends NotificationDozeHelper {

    private final int mImageDarkAlpha;
    private final int mImageDarkColor = 0xffffffff;

    @Nullable
    private PorterDuffColorFilter mImageColorFilter = null;

    private int mColor = Color.BLACK;

    public NotificationIconDozeHelper(Context ctx) {
        mImageDarkAlpha = ctx.getResources().getInteger(R.integer.doze_small_icon_alpha);
    }

    public void setColor(int color) {
        mColor = color;
    }

    public void setImageDark(ImageView target, boolean dark, boolean fade, long delay,
            boolean useGrayscale) {
        if (fade) {
            if (!useGrayscale) {
                fadeImageColorFilter(target, dark, delay);
                fadeImageAlpha(target, dark, delay);
            } else {
                fadeGrayscale(target, dark, delay);
            }
        } else {
            if (!useGrayscale) {
                updateImageColorFilter(target, dark);
                updateImageAlpha(target, dark);
            } else {
                updateGrayscale(target, dark);
            }
        }
    }

    private void fadeImageColorFilter(final ImageView target, boolean dark, long delay) {
        startIntensityAnimation(animation -> {
            updateImageColorFilter(target, (Float) animation.getAnimatedValue());
        }, dark, delay, null /* listener */);
    }

    private void fadeImageAlpha(final ImageView target, boolean dark, long delay) {
        startIntensityAnimation(animation -> {
            float t = (float) animation.getAnimatedValue();
            target.setImageAlpha((int) (255 * (1f - t) + mImageDarkAlpha * t));
        }, dark, delay, null /* listener */);
    }

    private void updateImageColorFilter(ImageView target, boolean dark) {
        updateImageColorFilter(target, dark ? 1f : 0f);
    }

    private void updateImageColorFilter(ImageView target, float intensity) {
        int color = NotificationUtils.interpolateColors(mColor, mImageDarkColor, intensity);
        if (mImageColorFilter == null || mImageColorFilter.getColor() != color) {
            mImageColorFilter = new PorterDuffColorFilter(color, Mode.SRC_ATOP);
        }
        Drawable imageDrawable = target.getDrawable();

        // Also, the notification might have been modified during the animation, so background
        // might be null here.
        if (imageDrawable != null) {
            Drawable d = imageDrawable.mutate();
            // DrawableContainer ignores the color filter if it's already set, so clear it first to
            // get it set and invalidated properly.
            d.setColorFilter(null);
            d.setColorFilter(mImageColorFilter);
        }
    }

    private void updateImageAlpha(ImageView target, boolean dark) {
        target.setImageAlpha(dark ? mImageDarkAlpha : 255);
    }

}
+14 −7
Original line number Diff line number Diff line
@@ -132,13 +132,16 @@ public class NotificationIconContainer extends ViewGroup {
        }
    }.setDuration(CONTENT_FADE_DURATION);

    // TODO(b/278765923): Replace these with domain-agnostic state
    /* Maximum number of icons on AOD when also showing overflow dot. */
    private int mMaxIconsOnAod;

    /* Maximum number of icons in short shelf on lockscreen when also showing overflow dot. */
    private int mMaxIconsOnLockscreen;
    /* Maximum number of icons in the status bar when also showing overflow dot. */
    private int mMaxStaticIcons;
    private boolean mDozing;
    private boolean mOnLockScreen;
    private boolean mOverrideIconColor;

    private boolean mIsStaticLayout = true;
    private final HashMap<View, IconState> mIconStates = new HashMap<>();
@@ -147,9 +150,6 @@ public class NotificationIconContainer extends ViewGroup {
    private int mActualLayoutWidth = NO_VALUE;
    private float mActualPaddingEnd = NO_VALUE;
    private float mActualPaddingStart = NO_VALUE;
    private boolean mDozing;
    private boolean mOnLockScreen;
    private boolean mInNotificationIconShelf;
    private boolean mChangingViewPositions;
    private int mAddAnimationStartIndex = -1;
    private int mCannedAnimationStartIndex = -1;
@@ -284,7 +284,7 @@ public class NotificationIconContainer extends ViewGroup {
    public String toString() {
        return "NotificationIconContainer("
                + "dozing=" + mDozing + " onLockScreen=" + mOnLockScreen
                + " inNotificationIconShelf=" + mInNotificationIconShelf
                + " overrideIconColor=" + mOverrideIconColor
                + " speedBumpIndex=" + mSpeedBumpIndex
                + " themedTextColorPrimary=#" + Integer.toHexString(mThemedTextColorPrimary) + ')';
    }
@@ -739,8 +739,15 @@ public class NotificationIconContainer extends ViewGroup {
        mOnLockScreen = onLockScreen;
    }

    @Deprecated
    public void setInNotificationIconShelf(boolean inShelf) {
        mInNotificationIconShelf = inShelf;
        NotificationIconContainerRefactor.assertInLegacyMode();
        mOverrideIconColor = inShelf;
    }

    public void setOverrideIconColor(boolean override) {
        if (NotificationIconContainerRefactor.isUnexpectedlyInLegacyMode()) return;
        mOverrideIconColor = override;
    }

    public class IconState extends ViewState {
@@ -858,7 +865,7 @@ public class NotificationIconContainer extends ViewGroup {
                    }
                }
                icon.setVisibleState(visibleState, animationsAllowed);
                icon.setIconColor(mInNotificationIconShelf ? mThemedTextColorPrimary : iconColor,
                icon.setIconColor(mOverrideIconColor ? mThemedTextColorPrimary : iconColor,
                        needsCannedAnimation && animationsAllowed);
                if (animate) {
                    animateTo(icon, animationProperties);
Loading