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

Commit 112e5147 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Fix invisible notification backgrounds."

parents 23a42810 3c3c3fc3
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        super.onFinishInflate();
        mBackgroundNormal = (NotificationBackgroundView) findViewById(R.id.backgroundNormal);
        mBackgroundDimmed = (NotificationBackgroundView) findViewById(R.id.backgroundDimmed);
        updateBackgroundResource();
        updateBackgroundResources();
    }

    private final Runnable mTapTimeoutRunnable = new Runnable() {
@@ -215,9 +215,9 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        if (mDimmed != dimmed) {
            mDimmed = dimmed;
            if (fade) {
                fadeBackgroundResource();
                fadeBackground();
            } else {
                updateBackgroundResource();
                updateBackground();
            }
        }
    }
@@ -233,14 +233,14 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        mBgTint = bgTint;
        mDimmedBgResId = dimmedBgResId;
        mDimmedBgTint = dimmedTint;
        updateBackgroundResource();
        updateBackgroundResources();
    }

    public void setBackgroundResourceIds(int bgResId, int dimmedBgResId) {
        setBackgroundResourceIds(bgResId, 0, dimmedBgResId, 0);
    }

    private void fadeBackgroundResource() {
    private void fadeBackground() {
        if (mDimmed) {
            mBackgroundDimmed.setVisibility(View.VISIBLE);
        } else {
@@ -256,7 +256,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
            mBackgroundAnimator.removeAllListeners();
            mBackgroundAnimator.cancel();
            if (duration <= 0) {
                updateBackgroundResource();
                updateBackground();
                return;
            }
        }
@@ -279,19 +279,22 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        mBackgroundAnimator.start();
    }

    private void updateBackgroundResource() {
    private void updateBackground() {
        if (mDimmed) {
            mBackgroundDimmed.setVisibility(View.VISIBLE);
            mBackgroundDimmed.setCustomBackground(mDimmedBgResId, mDimmedBgTint);
            mBackgroundNormal.setVisibility(View.INVISIBLE);
        } else {
            mBackgroundDimmed.setVisibility(View.INVISIBLE);
            mBackgroundNormal.setVisibility(View.VISIBLE);
            mBackgroundNormal.setCustomBackground(mBgResId, mBgTint);
            mBackgroundNormal.setAlpha(1f);
        }
    }

    private void updateBackgroundResources() {
        mBackgroundDimmed.setCustomBackground(mDimmedBgResId, mDimmedBgTint);
        mBackgroundNormal.setCustomBackground(mBgResId, mBgTint);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
+2 −2
Original line number Diff line number Diff line
@@ -90,9 +90,8 @@ public abstract class ExpandableView extends FrameLayout {
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        if (!mActualHeightInitialized && mActualHeight == 0) {
            mActualHeight = getInitialHeight();
            setActualHeight(getInitialHeight());
        }
        mActualHeightInitialized = true;
    }

    protected int getInitialHeight() {
@@ -127,6 +126,7 @@ public abstract class ExpandableView extends FrameLayout {
    }

    public void setActualHeight(int actualHeight) {
        mActualHeightInitialized = true;
        setActualHeight(actualHeight, true);
    }

+0 −10
Original line number Diff line number Diff line
@@ -31,22 +31,12 @@ public class NotificationBackgroundView extends View {
    private Drawable mBackground;
    private int mClipTopAmount;
    private int mActualHeight;
    private boolean mActualHeightInitialized;

    public NotificationBackgroundView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setWillNotDraw(false);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        if (!mActualHeightInitialized && mActualHeight == 0) {
            mActualHeight = getHeight();
        }
        mActualHeightInitialized = true;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        draw(canvas, mBackground);