Add flags to enable QS clipping / Scrim transparency.

For some devices where we rather just not clip anything, give the
ability for the devices to override and disable clipping. Similarly for
scrim transparency - allow device to forever set the alpha to 0.

Bug: 251207888
Test: Build

Change-Id: I3fb63309da1cb6d88d980ab57672062893c1a678
This commit is contained in:
Ben Lin
2022-09-14 16:23:01 -07:00
parent 8664c9501c
commit 5713d10f4e
3 changed files with 24 additions and 6 deletions

View File

@@ -18,6 +18,13 @@
<resources>
<!-- Whether to show the user switcher in quick settings when only a single user is present. -->
<bool name="qs_show_user_switcher_for_single_user">false</bool>
<!-- Whether to show a custom biometric prompt size-->
<bool name="use_custom_bp_size">false</bool>
<!-- Whether to enable clipping on Quick Settings -->
<bool name="qs_enable_clipping">true</bool>
<!-- Whether to enable transparent background for notification scrims -->
<bool name="notification_scrim_transparent">false</bool>
</resources>

View File

@@ -632,6 +632,7 @@ public final class NotificationPanelViewController extends PanelViewController {
private int mScreenCornerRadius;
private boolean mQSAnimatingHiddenFromCollapsed;
private boolean mUseLargeScreenShadeHeader;
private boolean mEnableQsClipping;
private int mQsClipTop;
private int mQsClipBottom;
@@ -1149,6 +1150,8 @@ public final class NotificationPanelViewController extends PanelViewController {
mSplitShadeFullTransitionDistance =
mResources.getDimensionPixelSize(R.dimen.split_shade_full_transition_distance);
mEnableQsClipping = mResources.getBoolean(R.bool.qs_enable_clipping);
}
private void onSplitShadeEnabledChanged() {
@@ -2680,8 +2683,10 @@ public final class NotificationPanelViewController extends PanelViewController {
mQsTranslationForFullShadeTransition = qsTranslation;
updateQsFrameTranslation();
float currentTranslation = mQsFrame.getTranslationY();
mQsClipTop = (int) (top - currentTranslation - mQsFrame.getTop());
mQsClipBottom = (int) (bottom - currentTranslation - mQsFrame.getTop());
mQsClipTop = mEnableQsClipping
? (int) (top - currentTranslation - mQsFrame.getTop()) : 0;
mQsClipBottom = mEnableQsClipping
? (int) (bottom - currentTranslation - mQsFrame.getTop()) : 0;
mQsVisible = qsVisible;
mQs.setQsVisible(mQsVisible);
mQs.setFancyClipping(

View File

@@ -249,6 +249,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
private Callback mCallback;
private boolean mWallpaperSupportsAmbientMode;
private boolean mScreenOn;
private boolean mTransparentScrimBackground;
// Scrim blanking callbacks
private Runnable mPendingFrameCallback;
@@ -341,6 +342,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
mScrimBehind.setDefaultFocusHighlightEnabled(false);
mNotificationsScrim.setDefaultFocusHighlightEnabled(false);
mScrimInFront.setDefaultFocusHighlightEnabled(false);
mTransparentScrimBackground = notificationsScrim.getResources()
.getBoolean(R.bool.notification_scrim_transparent);
updateScrims();
mKeyguardUpdateMonitor.registerCallback(mKeyguardVisibilityCallback);
}
@@ -777,13 +780,16 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
float behindFraction = getInterpolatedFraction();
behindFraction = (float) Math.pow(behindFraction, 0.8f);
if (mClipsQsScrim) {
mBehindAlpha = 1;
mNotificationsAlpha = behindFraction * mDefaultScrimAlpha;
mBehindAlpha = mTransparentScrimBackground ? 0 : 1;
mNotificationsAlpha =
mTransparentScrimBackground ? 0 : behindFraction * mDefaultScrimAlpha;
} else {
mBehindAlpha = behindFraction * mDefaultScrimAlpha;
mBehindAlpha =
mTransparentScrimBackground ? 0 : behindFraction * mDefaultScrimAlpha;
// Delay fade-in of notification scrim a bit further, to coincide with the
// view fade in. Otherwise the empty panel can be quite jarring.
mNotificationsAlpha = MathUtils.constrainedMap(0f, 1f, 0.3f, 0.75f,
mNotificationsAlpha = mTransparentScrimBackground
? 0 : MathUtils.constrainedMap(0f, 1f, 0.3f, 0.75f,
mPanelExpansionFraction);
}
mBehindTint = mState.getBehindTint();