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

Commit dc874b43 authored by Steve Elliott's avatar Steve Elliott
Browse files

Remove dead code from NIC + SBIV

Flag: NA
Test: mp sysuig
Bug: 278765923

Change-Id: I607d96f95f6d1a3b36e0516c3dfa1249def8457c
parent ac3d097a
Loading
Loading
Loading
Loading
+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);
    }

}