Skip to content

Commit

Permalink
Recents screen improvements (LawnchairLauncher#4338)
Browse files Browse the repository at this point in the history
* Allow changing Recents translucency
* Fix wrong Android version (from Q to P) in overlay priority
* Fix QuickSwitch warning not being shown

Signed-off-by: validcube <pun.butrach@gmail.com>
Co-authored-by: Zongle Wang <wangzongler@gmail.com>
Co-authored-by: SuperDragonXD <70206496+SuperDragonXD@users.noreply.github.com>
  • Loading branch information
3 people committed May 4, 2024
1 parent c758f79 commit 1294e9c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions lawnchair/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@
<string name="quickswitch_ignored_warning">These settings will be ignored as Lawnchair is not set as the Recents provider.</string>

<string name="translucent_background">Translucent Background</string>
<string name="translucent_background_alpha">Background Opacity</string>

<string name="recents_actions_label">Quick Actions</string>
<string name="action_share">Share</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,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 @@ -21,6 +21,7 @@ import app.lawnchair.ui.preferences.components.controls.WarningPreference
import app.lawnchair.ui.preferences.components.layout.ExpandAndShrink
import app.lawnchair.ui.preferences.components.layout.PreferenceGroup
import app.lawnchair.ui.preferences.components.layout.PreferenceLayout
import app.lawnchair.ui.util.PreviewLawnchair
import app.lawnchair.util.isOnePlusStock
import com.android.launcher3.R
import com.android.launcher3.Utilities
Expand All @@ -36,17 +37,26 @@ fun QuickstepPreferences(
context.packageManager.getLaunchIntentForPackage("com.google.ar.lens") != null
}

if (!LawnchairApp.isRecentsEnabled) QuickSwitchIgnoredWarning()

PreferenceLayout(
label = stringResource(id = R.string.quickstep_label),
modifier = modifier,
) {
if (!LawnchairApp.isRecentsEnabled) QuickSwitchIgnoredWarning()
PreferenceGroup(heading = stringResource(id = R.string.general_label)) {
SwitchPreference(
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 = 0.05f,
valueRange = 0f..0.95f,
showAsPercentage = true,
)
}
}
PreferenceGroup(heading = stringResource(id = R.string.recents_actions_label)) {
if (!isOnePlusStock) {
Expand Down Expand Up @@ -103,8 +113,9 @@ fun QuickstepPreferences(
}
}

@PreviewLawnchair
@Composable
fun QuickSwitchIgnoredWarning(
private fun QuickSwitchIgnoredWarning(
modifier: Modifier = Modifier,
) {
Surface(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected void init(Context context) {

// Elevate GPU priority for Quickstep and Remote animations.
try {
if (!Utilities.ATLEAST_Q) return;
if (!Utilities.ATLEAST_P) return;
ThreadedRenderer.setContextPriority(
ThreadedRenderer.EGL_CONTEXT_PRIORITY_HIGH_IMG);
} catch (Exception e) {
Expand Down

0 comments on commit 1294e9c

Please sign in to comment.