Don't reset the launcher if the feed was open on pause

This commit is contained in:
MM20
2026-01-11 14:38:16 +01:00
parent a816e18e14
commit 7536ae76ad
4 changed files with 13 additions and 8 deletions

View File

@@ -6,7 +6,6 @@ import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.content.res.Resources
import android.os.Bundle
import android.view.WindowManager
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
@@ -273,7 +272,6 @@ abstract class SharedLauncherActivity(
openKeyboard = searchBarAutofocus,
)
val widgetComponent by lazy { WidgetsComponent }
val feedComponent by lazy { FeedComponent(this@SharedLauncherActivity) }
fun getScaffoldGesture(
action: GestureAction?,
@@ -327,7 +325,7 @@ abstract class SharedLauncherActivity(
)
is GestureAction.Feed -> ScaffoldGesture(
component = FeedComponent(this@SharedLauncherActivity),
component = FeedComponent,
animation = if (gesture.orientation == null) ScaffoldAnimation.ZoomIn else ScaffoldAnimation.Push,
)

View File

@@ -1,7 +1,6 @@
package de.mm20.launcher2.ui.launcher.scaffold
import android.annotation.SuppressLint
import android.content.Context
import androidx.activity.compose.LocalActivity
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.Arrangement
@@ -37,15 +36,15 @@ import kotlinx.coroutines.flow.flowOf
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
internal class FeedComponent(
private val context: Context,
) : ScaffoldComponent(), KoinComponent {
internal object FeedComponent : ScaffoldComponent(), KoinComponent {
private val feedSettings: FeedSettings by inject()
private val feedService: FeedService by inject()
override val permanent: Boolean = true
override val survivesPause: Boolean = true
private var state = mutableIntStateOf(0)
@Composable

View File

@@ -1243,7 +1243,9 @@ internal fun LauncherScaffold(
}
} else if (activity.pauseTime > 0L && System.currentTimeMillis() - activity.pauseTime > 5000L) {
if (!state.isLocked) {
state.reset()
if (state.currentComponent?.survivesPause != true) {
state.reset()
}
searchVM.reset()
}
}

View File

@@ -46,6 +46,12 @@ internal abstract class ScaffoldComponent {
*/
open val hasIme: Boolean = false
/**
* If true, the component stays open when the launcher is resumed. If false, the launcher resets
* to its default position.
*/
open val survivesPause = false
/**
* Whether the component is scrolled all the way up
* null, if the component does not provide content