Skip to content

Commit c5c0adb

Browse files
neobuddy89momenabdulrazek
authored andcommitted
SystemUI: Add toggle for translucent notifications on lockscreen
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
1 parent 20c0d64 commit c5c0adb

File tree

9 files changed

+62
-1
lines changed

9 files changed

+62
-1
lines changed

core/java/android/provider/Settings.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14406,6 +14406,12 @@ public static boolean putFloatForUser(ContentResolver cr, String name, float val
1440614406
*/
1440714407
public static final String NOTIFICATION_ROW_TRANSPARENCY = "notification_row_transparency";
1440814408

14409+
/**
14410+
* Translucent lockscreen notifications
14411+
* @hide
14412+
*/
14413+
public static final String NOTIFICATION_ROW_TRANSPARENCY_LOCKSCREEN = "notification_row_transparency_lockscreen";
14414+
1440914415
/**
1441014416
* Keys we no longer back up under the current schema, but want to continue to
1441114417
* process when restoring historical backup datasets.

packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum
138138
"lineagesystem:" + LineageSettings.System.STATUS_BAR_QUICK_QS_PULLDOWN;
139139
private static final String NOTIFICATION_ROW_TRANSPARENCY =
140140
Settings.Secure.NOTIFICATION_ROW_TRANSPARENCY;
141+
private static final String NOTIFICATION_ROW_TRANSPARENCY_LOCKSCREEN =
142+
Settings.Secure.NOTIFICATION_ROW_TRANSPARENCY_LOCKSCREEN;
141143

142144
private QS mQs;
143145
private final Lazy<NotificationPanelViewController> mPanelViewControllerLazy;
@@ -2336,6 +2338,7 @@ public void onFragmentViewCreated(String tag, Fragment fragment) {
23362338
mQs.setScrollListener(mQsScrollListener);
23372339
mTunerService.addTunable(this, STATUS_BAR_QUICK_QS_PULLDOWN);
23382340
mTunerService.addTunable(this, NOTIFICATION_ROW_TRANSPARENCY);
2341+
mTunerService.addTunable(this, NOTIFICATION_ROW_TRANSPARENCY_LOCKSCREEN);
23392342
updateExpansion();
23402343
}
23412344

@@ -2365,7 +2368,8 @@ public void onFragmentViewDestroyed(String tag, Fragment fragment) {
23652368
public void onTuningChanged(String key, String newValue) {
23662369
if (STATUS_BAR_QUICK_QS_PULLDOWN.equals(key)) {
23672370
mOneFingerQuickSettingsIntercept = TunerService.parseInteger(newValue, 0);
2368-
} else if (NOTIFICATION_ROW_TRANSPARENCY.equals(key)) {
2371+
} else if (NOTIFICATION_ROW_TRANSPARENCY.equals(key) ||
2372+
NOTIFICATION_ROW_TRANSPARENCY_LOCKSCREEN.equals(key)) {
23692373
updateTransparencyIfNeeded();
23702374
}
23712375
}

packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
129129
*/
130130
protected boolean mOnKeyguard;
131131
protected boolean mIsBlurSupported;
132+
protected boolean mIsLockscreenBlurSupported;
132133
protected boolean mUseTransparent;
133134

134135
public ActivatableNotificationView(Context context, AttributeSet attrs) {
@@ -363,6 +364,11 @@ public void setIsBlurSupported(boolean isBlurSupported) {
363364
updateIfNeeded();
364365
}
365366

367+
public void setIsLockscreenBlurSupported(boolean isBlurSupported) {
368+
mIsLockscreenBlurSupported = isBlurSupported;
369+
updateIfNeeded();
370+
}
371+
366372
/** Updates background blur/transparency when transparent state changes. */
367373
public void updateIfNeeded() {
368374
boolean transparent = usesTransparentBackground();

packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4930,6 +4930,7 @@ protected boolean usesTransparentBackground() {
49304930
// Row background should be opaque when it's displayed as a heads-up notification or
49314931
// displayed on keyguard.
49324932
// Also, for an unpinned HUN on the unlocked shade, the row bg should be transparent.
4933+
if (mOnKeyguard) return mIsLockscreenBlurSupported;
49334934
return super.usesTransparentBackground()
49344935
&& !mustStayOnScreen()
49354936
&& !(isChildInGroup() && !mNotificationParent.usesTransparentBackground())

packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,10 @@ public void onViewDetachedFromWindow(View v) {
466466
mView,
467467
mWindowRootViewBlurInteractor.isTranslucentSupported(),
468468
mView::setIsBlurSupported);
469+
collectFlow(
470+
mView,
471+
mWindowRootViewBlurInteractor.isLockscreenTranslucentSupported(),
472+
mView::setIsLockscreenBlurSupported);
469473
}
470474

471475
private final StatusBarStateController.StateListener mStatusBarStateListener =

packages/SystemUI/src/com/android/systemui/window/data/repository/NoopWindowRootViewBlurRepository.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class NoopWindowRootViewBlurRepository @Inject constructor() : WindowRootViewBlu
2525
override val scaleRequestedByShade: MutableStateFlow<Float> = MutableStateFlow(1.0f)
2626
override val isBlurSupported: StateFlow<Boolean> = MutableStateFlow(false)
2727
override val isTranslucentSupported: StateFlow<Boolean> = MutableStateFlow(false)
28+
override val isLockscreenTranslucentSupported: StateFlow<Boolean> = MutableStateFlow(false)
2829
override var blurAppliedListener: BlurAppliedListener? = null
2930
override val trackingShadeMotion: MutableStateFlow<Boolean> = MutableStateFlow(false)
3031
}

packages/SystemUI/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepository.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ interface WindowRootViewBlurRepository {
5353
/** Whether notification row translucency is enabled via user setting. */
5454
val isTranslucentSupported: StateFlow<Boolean>
5555

56+
/** Whether lockscreen notification translucency is enabled via user setting. */
57+
val isLockscreenTranslucentSupported: StateFlow<Boolean>
58+
5659
var blurAppliedListener: BlurAppliedListener?
5760

5861
/** true when tracking shade motion that might lead to a shade expansion. */
@@ -126,6 +129,32 @@ constructor(
126129
}
127130
.stateIn(scope, SharingStarted.WhileSubscribed(), isTranslucentEnabled())
128131

132+
override val isLockscreenTranslucentSupported: StateFlow<Boolean> =
133+
conflatedCallbackFlow {
134+
val sendUpdate = {
135+
trySendWithFailureLogging(
136+
isLockscreenTranslucentEnabled(),
137+
TAG,
138+
"unable to send notificationRowTransparency lockscreen state change",
139+
)
140+
}
141+
val observer =
142+
object : ContentObserver(null) {
143+
override fun onChange(selfChange: Boolean) = sendUpdate()
144+
}
145+
val resolver = context.contentResolver
146+
resolver.registerContentObserver(
147+
Settings.Secure.getUriFor(
148+
Settings.Secure.NOTIFICATION_ROW_TRANSPARENCY_LOCKSCREEN,
149+
),
150+
true,
151+
observer,
152+
)
153+
sendUpdate()
154+
awaitClose { resolver.unregisterContentObserver(observer) }
155+
}
156+
.stateIn(scope, SharingStarted.WhileSubscribed(), isLockscreenTranslucentEnabled())
157+
129158
override var blurAppliedListener: BlurAppliedListener? = null
130159

131160
private fun isTranslucentEnabled(): Boolean =
@@ -136,6 +165,12 @@ constructor(
136165
UserHandle.USER_CURRENT,
137166
) == 1
138167

168+
private fun isLockscreenTranslucentEnabled(): Boolean =
169+
Settings.Secure.getIntForUser(
170+
context.contentResolver,
171+
Settings.Secure.NOTIFICATION_ROW_TRANSPARENCY_LOCKSCREEN,
172+
1, UserHandle.USER_CURRENT) == 1
173+
139174
private fun isBlurAllowed(): Boolean {
140175
return ActivityManager.isHighEndGfx() && !isDisableBlurSysPropSet()
141176
}

packages/SystemUI/src/com/android/systemui/window/domain/interactor/WindowRootViewBlurInteractor.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ constructor(
9898
/** Whether notification row translucency is enabled via user setting. */
9999
val isTranslucentSupported: StateFlow<Boolean> = repository.isTranslucentSupported
100100

101+
/** Whether lockscreen notification translucency is enabled via user setting. */
102+
val isLockscreenTranslucentSupported: StateFlow<Boolean> = repository.isLockscreenTranslucentSupported
103+
101104
/** Whether the blurred wallpaper is supported. This feature is disabled on desktop. */
102105
val isBlurredWallpaperSupported: Boolean =
103106
resources.getBoolean(R.bool.config_supportBlurredWallpaper)

packages/SystemUI/tests/utils/src/com/android/systemui/window/data/repository/WindowRootViewBlurRepositoryKosmos.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class FakeWindowRootViewBlurRepository : WindowRootViewBlurRepository {
3030
override val scaleRequestedByShade: MutableStateFlow<Float> = MutableStateFlow(1.0f)
3131
override val isBlurSupported: MutableStateFlow<Boolean> = MutableStateFlow(false)
3232
override val isTranslucentSupported: MutableStateFlow<Boolean> = MutableStateFlow(false)
33+
override val isLockscreenTranslucentSupported: MutableStateFlow<Boolean> = MutableStateFlow(false)
3334
override var blurAppliedListener: BlurAppliedListener? = null
3435
override val trackingShadeMotion: MutableStateFlow<Boolean> = MutableStateFlow(false)
3536
}

0 commit comments

Comments
 (0)