Loading packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java +18 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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(); } Loading Loading @@ -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); } } packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +26 −3 Original line number Diff line number Diff line Loading @@ -1997,12 +1997,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) { Loading Loading @@ -2030,7 +2053,7 @@ public class NotificationPanelViewController extends PanelViewController { private float calculateNotificationsTopPadding() { if (mShouldUseSplitNotificationShade && !mKeyguardShowing) { return mSplitShadeNotificationsTopPadding; return mSplitShadeNotificationsTopPadding + mQsNotificationTopPadding; } if (mKeyguardShowing && (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted)) { Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +7 −9 Original line number Diff line number Diff line Loading @@ -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. * Loading @@ -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; Loading @@ -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) { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/ScrimViewTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java +18 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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(); } Loading Loading @@ -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); } }
packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +26 −3 Original line number Diff line number Diff line Loading @@ -1997,12 +1997,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) { Loading Loading @@ -2030,7 +2053,7 @@ public class NotificationPanelViewController extends PanelViewController { private float calculateNotificationsTopPadding() { if (mShouldUseSplitNotificationShade && !mKeyguardShowing) { return mSplitShadeNotificationsTopPadding; return mSplitShadeNotificationsTopPadding + mQsNotificationTopPadding; } if (mKeyguardShowing && (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted)) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +7 −9 Original line number Diff line number Diff line Loading @@ -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. * Loading @@ -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; Loading @@ -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) { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/ScrimViewTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); } }