Skip to content

Commit

Permalink
Set background translucent intensity
Browse files Browse the repository at this point in the history
Signed-off-by: Pun Butrach <pun.butrach@gmail.com>
Signed-off-by: validcube <pun.butrach@gmail.com>
  • Loading branch information
validcube committed Apr 29, 2024
1 parent 5516ec6 commit 0159766
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lawnchair/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
<string name="pick_app_for_gesture">Pick App</string>

<!-- QuickstepPreferences -->
<string name="quickswitch_ignored_warning">These settings will be ignored as Lawnchair is not set as the Recents provider.</string>
<string name="quickswitch_ignored_warning">These settings will be ignored as Lawnchair Launcher is not set as the Recents provider.</string>

<string name="translucent_background">Translucent Background</string>
<string name="translucent_background_alpha">Translucent Intensity</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class PreferenceManager private constructor(private val context: Context) : Base
val recentsActionClearAll = BoolPref("pref_clearAllAsAction", false)
val recentsActionLocked = BoolPref("pref_lockedAsAction", false)
val recentsTranslucentBackground = BoolPref("pref_recentsTranslucentBackground", false, recreate)
val recentsTranslucentBackgroundAlpha = FloatPref("pref_recentTranslucentBackgroundAlpha", .8F, recreate)

init {
sp.registerOnSharedPreferenceChangeListener(this)
Expand Down
3 changes: 2 additions & 1 deletion lawnchair/src/app/lawnchair/theme/color/ColorTokens.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ object ColorTokens {
@JvmField val OverviewScrim = DayNightColorToken(Neutral2_500.setLStar(87.0), Neutral1_800)
.withPreferences { prefs ->
val translucent = prefs.recentsTranslucentBackground.get()
if (translucent) setAlpha(0.8f) else this
val translucentIntensity = prefs.recentsTranslucentBackgroundAlpha.get()
if (translucent) setAlpha(translucentIntensity) else this
}

@JvmField val SearchboxHighlight = DayNightColorToken(SurfaceVariantLight, Neutral1_800)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ fun QuickstepPreferences(
adapter = prefs.recentsTranslucentBackground.getAdapter(),
label = stringResource(id = R.string.translucent_background),
)
val recentsTranslucentBackground by prefs.recentsTranslucentBackground.observeAsState()
ExpandAndShrink(visible = recentsTranslucentBackground) {
SliderPreference(
adapter = prefs.recentsTranslucentBackgroundAlpha.getAdapter(),
label = stringResource(id = R.string.translucent_background_alpha),
step = 0f,
valueRange = 0f..1f,
showAsPercentage = true,
)
}
}
PreferenceGroup(heading = stringResource(id = R.string.recents_actions_label)) {
if (!isOnePlusStock) {
Expand Down

0 comments on commit 0159766

Please sign in to comment.