Fixed the background for low-priority legacy notifications

The background color could be calculated wrong in case we
Had a legacy notification with a dark background.

Test: install legacy custom notification with background, observe
Change-Id: Ie2a8ba4012f30719c05115f51bfddbdc8e33e551
Fixes: 34856700
This commit is contained in:
Selim Cinek
2017-02-01 11:43:18 -08:00
parent 7d1009b3bd
commit f868efedd5
4 changed files with 23 additions and 23 deletions

View File

@@ -38,7 +38,6 @@ import com.android.systemui.R;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.statusbar.notification.FakeShadowView;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.policy.AccessibilityController;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.StackStateAnimator;
@@ -140,8 +139,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
private ValueAnimator mBackgroundColorAnimator;
private float mAppearAnimationFraction = -1.0f;
private float mAppearAnimationTranslation;
private boolean mShowingLegacyBackground;
private final int mLegacyColor;
private final int mNormalColor;
private final int mLowPriorityColor;
private boolean mIsBelowSpeedBump;
@@ -192,7 +189,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
mSlowOutLinearInInterpolator = new PathInterpolator(0.8f, 0.0f, 1.0f, 1.0f);
setClipChildren(false);
setClipToPadding(false);
mLegacyColor = context.getColor(R.color.notification_legacy_background_color);
mNormalColor = context.getColor(R.color.notification_material_background_color);
mLowPriorityColor = context.getColor(
R.color.notification_material_background_low_priority_color);
@@ -489,11 +485,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
updateOutlineAlpha();
}
public void setShowingLegacyBackground(boolean showing) {
mShowingLegacyBackground = showing;
updateBackgroundTint();
}
@Override
public void setBelowSpeedBump(boolean below) {
super.setBelowSpeedBump(below);
@@ -950,8 +941,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
}
if (withTint && mBgTint != NO_COLOR) {
return mBgTint;
} else if (mShowingLegacyBackground) {
return mLegacyColor;
} else if (mIsBelowSpeedBump) {
return mLowPriorityColor;
} else {
@@ -962,8 +951,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
protected int getRippleColor() {
if (mBgTint != 0) {
return mTintedRippleColor;
} else if (mShowingLegacyBackground) {
return mTintedRippleColor;
} else if (mIsBelowSpeedBump) {
return mLowPriorityRippleColor;
} else {
@@ -1009,7 +996,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
public void reset() {
setTintColor(0);
resetBackgroundAlpha();
setShowingLegacyBackground(false);
setBelowSpeedBump(false);
}

View File

@@ -1796,9 +1796,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
return mShowingPublic ? mPublicLayout : mPrivateLayout;
}
@Override
public void setShowingLegacyBackground(boolean showing) {
super.setShowingLegacyBackground(showing);
for (NotificationContentView l : mLayouts) {
l.setShowingLegacyBackground(showing);
}

View File

@@ -41,10 +41,12 @@ public class NotificationCustomViewWrapper extends NotificationViewWrapper {
private final ViewInvertHelper mInvertHelper;
private final Paint mGreyPaint = new Paint();
private boolean mShowingLegacyBackground;
private int mLegacyColor;
protected NotificationCustomViewWrapper(View view, ExpandableNotificationRow row) {
super(view, row);
mInvertHelper = new ViewInvertHelper(view, NotificationPanelView.DOZE_ANIMATION_DURATION);
mLegacyColor = row.getContext().getColor(R.color.notification_legacy_background_color);
}
@Override
@@ -102,6 +104,15 @@ public class NotificationCustomViewWrapper extends NotificationViewWrapper {
mView.setAlpha(visible ? 1.0f : 0.0f);
}
@Override
public int getCustomBackgroundColor() {
int customBackgroundColor = super.getCustomBackgroundColor();
if (customBackgroundColor == 0 && mShowingLegacyBackground) {
return mLegacyColor;
}
return customBackgroundColor;
}
@Override
public void setShowingLegacyBackground(boolean showing) {
super.setShowingLegacyBackground(showing);

View File

@@ -16,9 +16,6 @@
package com.android.systemui.statusbar;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.annotation.UiThreadTest;
@@ -31,6 +28,11 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
@SmallTest
@RunWith(AndroidJUnit4.class)
public class NotificationContentViewTest {
@@ -39,13 +41,16 @@ public class NotificationContentViewTest {
Context mContext;
@Before
@UiThreadTest
public void setup() {
ExpandableNotificationRow rowMock = mock(ExpandableNotificationRow.class);
when(rowMock.getIntrinsicHeight()).thenReturn(10);
mContext = InstrumentationRegistry.getTargetContext();
mView = new NotificationContentView(mContext, null);
mView.setContainingNotification(rowMock);
ExpandableNotificationRow row = new ExpandableNotificationRow(mContext, null);
ExpandableNotificationRow mockRow = spy(row);
doNothing().when(mockRow).updateBackgroundAlpha(anyFloat());
doReturn(10).when(mockRow).getIntrinsicHeight();
mView.setContainingNotification(mockRow);
mView.setHeights(10, 20, 30, 40);
mView.setContractedChild(createViewWithHeight(10));