Fixing dual tone shade in split shade mode
Instead of reacting only on quick settings height change, now NotificationPanelViewController sets bounds (both x and y) where notification background should appear Test: Manual + NotificationPanelViewTest + Presubmit Bug: 185110525 Change-Id: I4e00d75174ace08edbda40e803907edcee73a5bf
This commit is contained in:
@@ -25,12 +25,14 @@ import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Looper;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.DimenRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
@@ -66,6 +68,8 @@ public class ScrimView extends View {
|
||||
private Executor mChangeRunnableExecutor;
|
||||
private Executor mExecutor;
|
||||
private Looper mExecutorLooper;
|
||||
@Nullable
|
||||
private Rect mDrawableBounds;
|
||||
|
||||
public ScrimView(Context context) {
|
||||
this(context, null);
|
||||
@@ -125,7 +129,9 @@ public class ScrimView extends View {
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
if (changed) {
|
||||
if (mDrawableBounds != null) {
|
||||
mDrawable.setBounds(mDrawableBounds);
|
||||
} else if (changed) {
|
||||
mDrawable.setBounds(left, top, right, bottom);
|
||||
invalidate();
|
||||
}
|
||||
@@ -288,4 +294,15 @@ public class ScrimView extends View {
|
||||
((ScrimDrawable) mDrawable).setRoundedCorners(radius);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bounds for the view, all coordinates are absolute
|
||||
*/
|
||||
public void setDrawableBounds(float left, float top, float right, float bottom) {
|
||||
if (mDrawableBounds == null) {
|
||||
mDrawableBounds = new Rect();
|
||||
}
|
||||
mDrawableBounds.set((int) left, (int) top, (int) right, (int) bottom);
|
||||
mDrawable.setBounds(mDrawableBounds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1985,12 +1985,35 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
float qsExpansionFraction = getQsExpansionFraction();
|
||||
mQs.setQsExpansion(qsExpansionFraction, getHeaderTranslation());
|
||||
mMediaHierarchyManager.setQsExpansion(qsExpansionFraction);
|
||||
mScrimController.setQsPosition(qsExpansionFraction,
|
||||
calculateQsBottomPosition(qsExpansionFraction));
|
||||
int qsPanelBottomY = calculateQsBottomPosition(qsExpansionFraction);
|
||||
mScrimController.setQsPosition(qsExpansionFraction, qsPanelBottomY);
|
||||
setNotificationBounds(qsExpansionFraction, qsPanelBottomY);
|
||||
mNotificationStackScrollLayoutController.setQsExpansionFraction(qsExpansionFraction);
|
||||
mDepthController.setQsPanelExpansion(qsExpansionFraction);
|
||||
}
|
||||
|
||||
private void setNotificationBounds(float qsExpansionFraction, int qsPanelBottomY) {
|
||||
float top = 0;
|
||||
float bottom = 0;
|
||||
float left = 0;
|
||||
float right = 0;
|
||||
if (qsPanelBottomY > 0) {
|
||||
// notification shade is expanding/expanded
|
||||
if (!mShouldUseSplitNotificationShade) {
|
||||
top = qsPanelBottomY;
|
||||
bottom = getView().getBottom();
|
||||
left = getView().getLeft();
|
||||
right = getView().getRight();
|
||||
} else {
|
||||
top = Math.min(qsPanelBottomY, mSplitShadeNotificationsTopPadding);
|
||||
bottom = getExpandedHeight() - mSplitShadeNotificationsTopPadding;
|
||||
left = mNotificationStackScrollLayoutController.getLeft();
|
||||
right = mNotificationStackScrollLayoutController.getRight();
|
||||
}
|
||||
}
|
||||
mScrimController.setNotificationsBounds(left, top, right, bottom);
|
||||
}
|
||||
|
||||
private int calculateQsBottomPosition(float qsExpansionFraction) {
|
||||
int qsBottomY = (int) getHeaderTranslation() + mQs.getQsMinExpansionHeight();
|
||||
if (qsExpansionFraction != 0.0) {
|
||||
@@ -2018,7 +2041,7 @@ public class NotificationPanelViewController extends PanelViewController {
|
||||
|
||||
private float calculateNotificationsTopPadding() {
|
||||
if (mShouldUseSplitNotificationShade && !mKeyguardShowing) {
|
||||
return mSplitShadeNotificationsTopPadding;
|
||||
return mSplitShadeNotificationsTopPadding + mQsNotificationTopPadding;
|
||||
}
|
||||
if (mKeyguardShowing && (mQsExpandImmediate
|
||||
|| mIsExpanding && mQsExpandedWhenExpandingStarted)) {
|
||||
|
||||
@@ -486,6 +486,13 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bounds for notifications background, all coordinates are absolute
|
||||
*/
|
||||
public void setNotificationsBounds(float left, float top, float right, float bottom) {
|
||||
mNotificationsScrim.setDrawableBounds(left, top, right, bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Current state of the QuickSettings when pulling it from the top.
|
||||
*
|
||||
@@ -496,7 +503,6 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
|
||||
if (isNaN(expansionFraction)) {
|
||||
return;
|
||||
}
|
||||
shiftNotificationsScrim(qsPanelBottomY);
|
||||
updateNotificationsScrimAlpha(expansionFraction, qsPanelBottomY);
|
||||
if (mQsExpansion != expansionFraction) {
|
||||
mQsExpansion = expansionFraction;
|
||||
@@ -511,14 +517,6 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
|
||||
}
|
||||
}
|
||||
|
||||
private void shiftNotificationsScrim(int qsPanelBottomY) {
|
||||
if (qsPanelBottomY > 0) {
|
||||
mNotificationsScrim.setTranslationY(qsPanelBottomY);
|
||||
} else {
|
||||
mNotificationsScrim.setTranslationY(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNotificationsScrimAlpha(float qsExpansion, int qsPanelBottomY) {
|
||||
float newAlpha = 0;
|
||||
if (qsPanelBottomY > 0) {
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
@@ -89,4 +90,17 @@ public class ScrimViewTest extends LeakCheckedTest {
|
||||
mView.setTint(tint);
|
||||
assertEquals(mView.getTint(), tint);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setDrawableBounds_propagatesToDrawable() {
|
||||
ColorDrawable drawable = new ColorDrawable();
|
||||
Rect expectedBounds = new Rect(100, 100, 100, 100);
|
||||
mView.setDrawable(drawable);
|
||||
mView.setDrawableBounds(100, 100, 100, 100);
|
||||
|
||||
assertEquals(expectedBounds, drawable.getBounds());
|
||||
// set bounds that are different from expected drawable bounds
|
||||
mView.onLayout(true, 200, 200, 200, 200);
|
||||
assertEquals(expectedBounds, drawable.getBounds());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user