summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java19
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java29
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java16
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/ScrimViewTest.java14
4 files changed, 65 insertions, 13 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
index c811fdd2fe2a..a537299d4979 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
@@ -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);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index 7032aefc7a4d..70ad0d8427d9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -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)) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index 58488ef8ffd2..5e9c758da07a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -487,6 +487,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.
*
* @param expansionFraction From 0 to 1 where 0 means collapsed and 1 expanded.
@@ -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) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/ScrimViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/ScrimViewTest.java
index 87a77577841a..c2e58efe1328 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/ScrimViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/ScrimViewTest.java
@@ -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());
+ }
}