Skip to content

Commit

Permalink
feat : implementation overlay mode
Browse files Browse the repository at this point in the history
This implementation allows users to configure their preferred overlay animation mode when closing app

Enabled seamless switching between `FADE_IN` and `SUCK_IN`

- closes : LawnchairLauncher#5094
- closes : LawnchairLauncher#5219
- closes : LawnchairLauncher#4377
  • Loading branch information
MrSluffy authored and nulldrf committed Feb 14, 2025
1 parent aa1576b commit 0fa1901
Show file tree
Hide file tree
Showing 10 changed files with 784 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lawnchair/res/layout/floating_surface_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<app.lawnchair.views.LawnchairFloatingSurfaceView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
5 changes: 4 additions & 1 deletion lawnchair/res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
<!-- which web search provider to use by default -->
<string name="config_default_web_suggestion_provider" translatable="false">google</string>

<!-- which overlay to use by default -->
<string name="config_default_overlay" translatable="false">suck_in</string>

<bool name="config_default_show_hotseat">true</bool>
<bool name="config_default_always_reload_icons">true</bool>
<bool name="config_default_dark_status_bar">false</bool>
Expand Down Expand Up @@ -127,7 +130,7 @@
<bool name="config_default_show_icon_labels_in_drawer">true</bool>
<bool name="config_default_enable_fuzzy_search">false</bool>
<bool name="config_default_enable_smartspace">true</bool>
<bool name="config_default_enable_feed">true</bool>
<bool name="config_default_enable_feed">false</bool>
<bool name="config_default_enable_icon_selection">false</bool>
<bool name="config_default_show_component_names">false</bool>
<bool name="config_default_smartspace_show_date">true</bool>
Expand Down
6 changes: 6 additions & 0 deletions lawnchair/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@
<string name="recents_lock_unlock">Lock/unlock</string>
<string name="recents_lock_unlock_description">Prevent selected app from closing when pressing \"Clear all\"</string>

<!--Overlay-->
<string name="overlay_fade_in">Fade In</string>
<string name="overlay_suck_in">Suck In</string>
<string name="app_closing_animation">App closing animation</string>
<string name="overlay_label">Overlay</string>

<!--
Notifications
Expand Down
10 changes: 7 additions & 3 deletions lawnchair/src/app/lawnchair/LawnchairLauncher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import android.util.Pair
import android.view.Display
import android.view.View
import android.view.ViewTreeObserver
import android.window.SplashScreen
import androidx.activity.SystemBarStyle
import androidx.activity.enableEdgeToEdge
import androidx.core.view.WindowInsetsCompat
Expand All @@ -51,6 +52,7 @@ import app.lawnchair.ui.popup.LauncherOptionsPopup
import app.lawnchair.ui.popup.LawnchairShortcut
import app.lawnchair.util.getThemedIconPacksInstalled
import app.lawnchair.util.unsafeLazy
import app.lawnchair.views.LawnchairFloatingSurfaceView
import com.android.launcher3.AbstractFloatingView
import com.android.launcher3.BaseActivity
import com.android.launcher3.BubbleTextView
Expand All @@ -75,7 +77,6 @@ import com.android.launcher3.util.SystemUiController.UI_STATE_BASE_WINDOW
import com.android.launcher3.util.Themes
import com.android.launcher3.util.TouchController
import com.android.launcher3.views.ActivityContext
import com.android.launcher3.views.FloatingSurfaceView
import com.android.launcher3.views.OptionsPopupView
import com.android.launcher3.views.OptionsPopupView.OptionItem
import com.android.launcher3.widget.LauncherWidgetHolder
Expand Down Expand Up @@ -300,7 +301,7 @@ class LawnchairLauncher : QuickstepLauncher() {
false,
AbstractFloatingView.TYPE_ICON_SURFACE,
)
FloatingSurfaceView.show(this, gnc)
LawnchairFloatingSurfaceView.show(this, gnc)
}
}
}
Expand Down Expand Up @@ -349,7 +350,7 @@ class LawnchairLauncher : QuickstepLauncher() {
view.iconView.setBackgroundDrawable(item.icon)
view.bubbleText.text = item.label
view.setOnClickListener(popup)
// view.onLongClickListener = popup
view.onLongClickListener = popup
popup.mItemMap[view] = item
}

Expand Down Expand Up @@ -424,6 +425,9 @@ class LawnchairLauncher : QuickstepLauncher() {
height,
),
)
if (Utilities.ATLEAST_T) {
options.splashScreenStyle = SplashScreen.SPLASH_SCREEN_STYLE_ICON
}
options.launchDisplayId = if (v.display != null) v.display.displayId else Display.DEFAULT_DISPLAY
val callback = RunnableList()
return ActivityOptionsWrapper(options, callback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import app.lawnchair.theme.color.ColorStyle
import app.lawnchair.ui.popup.LauncherOptionsPopup
import app.lawnchair.ui.preferences.components.HiddenAppsInSearch
import app.lawnchair.util.kotlinxJson
import app.lawnchair.views.overlay.FullScreenOverlayMode
import com.android.launcher3.InvariantDeviceProfile
import com.android.launcher3.InvariantDeviceProfile.INDEX_DEFAULT
import com.android.launcher3.LauncherAppState
Expand Down Expand Up @@ -460,6 +461,14 @@ class PreferenceManager2 private constructor(private val context: Context) :
defaultValue = context.resources.getBoolean(R.bool.config_default_enable_fuzzy_search),
)

val closingAppOverlay = preference(
key = stringPreferencesKey(name = "closing_app_overlay"),
defaultValue = FullScreenOverlayMode.fromValue(context.resources.getString(R.string.config_default_overlay)),
parse = { FullScreenOverlayMode.fromValue(it) },
save = { it.value },
onSet = { reloadHelper.reloadGrid() },
)

val matchHotseatQsbStyle = preference(
key = booleanPreferencesKey(name = "use_drawer_search_icon"),
defaultValue = false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package app.lawnchair.ui.preferences.components

import android.R as AndroidR
import androidx.compose.foundation.clickable
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import app.lawnchair.preferences.PreferenceAdapter
import app.lawnchair.ui.ModalBottomSheetContent
import app.lawnchair.ui.preferences.components.layout.PreferenceDivider
import app.lawnchair.ui.preferences.components.layout.PreferenceTemplate
import app.lawnchair.ui.util.LocalBottomSheetHandler
import app.lawnchair.views.overlay.FullScreenOverlayMode
import kotlinx.coroutines.launch

val overlayOptions = listOf(
FullScreenOverlayMode.SUCK_IN,
FullScreenOverlayMode.FADE_IN,
)

@Composable
fun OverlayHandlerPreference(
adapter: PreferenceAdapter<FullScreenOverlayMode>,
label: String,
modifier: Modifier = Modifier,
) {
val scope = rememberCoroutineScope()
val bottomSheetHandler = LocalBottomSheetHandler.current

val currentConfig = adapter.state.value

fun onSelect(option: FullScreenOverlayMode) {
scope.launch {
adapter.onChange(option)
}
}

PreferenceTemplate(
title = { Text(text = label) },
description = { Text(text = stringResource(currentConfig.labelRes)) },
modifier = modifier.clickable {
bottomSheetHandler.show {
ModalBottomSheetContent(
title = { Text(label) },
buttons = {
OutlinedButton(onClick = { bottomSheetHandler.hide() }) {
Text(text = stringResource(id = AndroidR.string.cancel))
}
},
) {
LazyColumn {
itemsIndexed(overlayOptions) { index, option ->
if (index > 0) {
PreferenceDivider(startIndent = 40.dp)
}
val selected = currentConfig == option
PreferenceTemplate(
title = { Text(text = stringResource(option.labelRes)) },
modifier = Modifier.clickable {
bottomSheetHandler.hide()
onSelect(option)
},
startWidget = {
RadioButton(
selected = selected,
onClick = null,
)
},
)
}
}
}
}
},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import app.lawnchair.ui.preferences.LocalIsExpandedScreen
import app.lawnchair.ui.preferences.components.FeedPreference
import app.lawnchair.ui.preferences.components.GestureHandlerPreference
import app.lawnchair.ui.preferences.components.NavigationActionPreference
import app.lawnchair.ui.preferences.components.OverlayHandlerPreference
import app.lawnchair.ui.preferences.components.controls.ClickablePreference
import app.lawnchair.ui.preferences.components.controls.ListPreference
import app.lawnchair.ui.preferences.components.controls.SliderPreference
Expand Down Expand Up @@ -93,6 +94,13 @@ fun HomeScreenPreferences(
FeedPreference()
}
}
PreferenceGroup(heading = stringResource(R.string.overlay_label)) {
val overlayAdapter = prefs2.closingAppOverlay.getAdapter()
OverlayHandlerPreference(
adapter = overlayAdapter,
label = stringResource(id = R.string.app_closing_animation),
)
}
PreferenceGroup(heading = stringResource(id = R.string.wallpaper)) {
SwitchPreference(
prefs.wallpaperScrolling.getAdapter(),
Expand Down
Loading

0 comments on commit 0fa1901

Please sign in to comment.