Skip to content

Commit cba7f85

Browse files
committed
base: Allow overriding SysUI notification scrim alpha
by using a resource and doing logically the same changes as it's done with regular scrim. TODO: Fix the statusbar transparency on keyguard which is broken
1 parent c2f4292 commit cba7f85

2 files changed

Lines changed: 31 additions & 6 deletions

File tree

packages/SystemUI/res/values/bootleg_config.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,15 @@
7676
<!-- The CPUs to display in CPUInfoService view -->
7777
<string name="config_displayCpus" translatable="false"></string>
7878

79+
<!-- This value is used when notification_scrim_transparent is set to true.
80+
Allows to change how transparent is the scrim notification area -->
81+
<item name="config_notification_scrim_transparency_amount" translatable="false" format="float" type="dimen">
82+
0
83+
</item>
84+
85+
<!-- This value is used when notification_scrim_transparent is set to true.
86+
Allows to change how transparent is the scrim background area (for example, in the header) -->
87+
<item name="config_behind_scrim_transparency_amount" translatable="false" format="float" type="dimen">
88+
0
89+
</item>
7990
</resources>

packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ public void setUnocclusionAnimationRunning(boolean unocclusionAnimationRunning)
256256
private boolean mWallpaperSupportsAmbientMode;
257257
private boolean mScreenOn;
258258
private boolean mTransparentScrimBackground;
259+
private float mTransparentBehindScrimAmount;
260+
private float mTransparentNotifScrimAmount;
259261

260262
// Scrim blanking callbacks
261263
private Runnable mPendingFrameCallback;
@@ -349,8 +351,6 @@ public void attachViews(ScrimView behindScrim, ScrimView notificationsScrim,
349351
mScrimBehind.setDefaultFocusHighlightEnabled(false);
350352
mNotificationsScrim.setDefaultFocusHighlightEnabled(false);
351353
mScrimInFront.setDefaultFocusHighlightEnabled(false);
352-
mTransparentScrimBackground = notificationsScrim.getResources()
353-
.getBoolean(R.bool.notification_scrim_transparent);
354354
updateScrims();
355355
mKeyguardUpdateMonitor.registerCallback(mKeyguardVisibilityCallback);
356356

@@ -795,16 +795,21 @@ private void applyState() {
795795
float behindFraction = getInterpolatedFraction();
796796
behindFraction = (float) Math.pow(behindFraction, 0.8f);
797797
if (mClipsQsScrim) {
798-
mBehindAlpha = mTransparentScrimBackground ? 0 : 1;
798+
mBehindAlpha = mTransparentScrimBackground ?
799+
mTransparentBehindScrimAmount : 1;
799800
mNotificationsAlpha =
800-
mTransparentScrimBackground ? 0 : behindFraction * mDefaultScrimAlpha;
801+
mTransparentScrimBackground ? behindFraction * mTransparentNotifScrimAmount
802+
: behindFraction * mDefaultScrimAlpha;
801803
} else {
802804
mBehindAlpha =
803-
mTransparentScrimBackground ? 0 : behindFraction * mDefaultScrimAlpha;
805+
mTransparentScrimBackground ? behindFraction * mTransparentBehindScrimAmount
806+
: behindFraction * mDefaultScrimAlpha;
804807
// Delay fade-in of notification scrim a bit further, to coincide with the
805808
// view fade in. Otherwise the empty panel can be quite jarring.
806809
mNotificationsAlpha = mTransparentScrimBackground
807-
? 0 : MathUtils.constrainedMap(0f, 1f, 0.3f, 0.75f,
810+
? MathUtils.constrainedMap(0f, mTransparentNotifScrimAmount,
811+
mTransparentNotifScrimAmount * 0.3f, mTransparentNotifScrimAmount * 0.75f,
812+
mPanelExpansionFraction) : MathUtils.constrainedMap(0f, 1f, 0.3f, 0.75f,
808813
mPanelExpansionFraction);
809814
}
810815
mBehindTint = mState.getBehindTint();
@@ -1026,6 +1031,14 @@ protected void scheduleUpdate() {
10261031
}
10271032

10281033
protected void updateScrims() {
1034+
// Let's update this resources after setting the overlays
1035+
mTransparentScrimBackground = mNotificationsScrim.getResources()
1036+
.getBoolean(R.bool.notification_scrim_transparent);
1037+
mTransparentBehindScrimAmount = mNotificationsScrim.getResources()
1038+
.getFloat(R.dimen.config_behind_scrim_transparency_amount);
1039+
mTransparentNotifScrimAmount = mNotificationsScrim.getResources()
1040+
.getFloat(R.dimen.config_notification_scrim_transparency_amount);
1041+
10291042
// Make sure we have the right gradients and their opacities will satisfy GAR.
10301043
if (mNeedsDrawableColorUpdate) {
10311044
mNeedsDrawableColorUpdate = false;
@@ -1421,6 +1434,7 @@ private void updateThemeColors() {
14211434

14221435
private void onThemeChanged() {
14231436
updateThemeColors();
1437+
updateScrims();
14241438
scheduleUpdate();
14251439
}
14261440

0 commit comments

Comments
 (0)